Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sd/consul/instancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = &Instancer{} // API check
var _ sd.Instancer = (*Instancer)(nil) // API check

var consulState = []*consul.ServiceEntry{
{
Expand Down
2 changes: 1 addition & 1 deletion sd/dnssrv/instancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = &Instancer{} // API check
var _ sd.Instancer = (*Instancer)(nil) // API check

func TestRefresh(t *testing.T) {
name := "some.service.internal"
Expand Down
20 changes: 2 additions & 18 deletions sd/endpointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ func TestDefaultEndpointer(t *testing.T) {
f = func(instance string) (endpoint.Endpoint, io.Closer, error) {
return endpoint.Nop, c[instance], nil
}
instancer = &mockInstancer{
cache: instance.NewCache(),
}
instancer = &mockInstancer{instance.NewCache()}
)
// set initial state
instancer.Update(sd.Event{Instances: []string{"a", "b"}})
Expand Down Expand Up @@ -59,21 +57,7 @@ func TestDefaultEndpointer(t *testing.T) {
// and therefore does not have access to the endpointer's private members.
}

type mockInstancer struct {
cache *instance.Cache
}

func (m *mockInstancer) Update(event sd.Event) {
m.cache.Update(event)
}

func (m *mockInstancer) Register(ch chan<- sd.Event) {
m.cache.Register(ch)
}

func (m *mockInstancer) Deregister(ch chan<- sd.Event) {
m.cache.Deregister(ch)
}
type mockInstancer struct{ *instance.Cache }

type closer chan struct{}

Expand Down
2 changes: 2 additions & 0 deletions sd/etcd/instancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = (*Instancer)(nil) // API check

var (
node = &stdetcd.Node{
Key: "/foo",
Expand Down
2 changes: 1 addition & 1 deletion sd/eureka/instancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = &Instancer{} // API check
var _ sd.Instancer = (*Instancer)(nil) // API check

func TestInstancer(t *testing.T) {
connection := &testConnection{
Expand Down
4 changes: 4 additions & 0 deletions sd/instancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Event struct {
type Instancer interface {
Register(chan<- Event)
Deregister(chan<- Event)
Stop()
}

// FixedInstancer yields a fixed set of instances.
Expand All @@ -32,3 +33,6 @@ func (d FixedInstancer) Register(ch chan<- Event) { ch <- Event{Instances: d} }

// Deregister implements Instancer.
func (d FixedInstancer) Deregister(ch chan<- Event) {}

// Stop implements Instancer.
func (d FixedInstancer) Stop() {}
4 changes: 4 additions & 0 deletions sd/internal/instance/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (c *Cache) State() sd.Event {
return c.state
}

// Stop implements Instancer. Since the cache is just a plain-old store of data,
// Stop is a no-op.
func (c *Cache) Stop() {}

// Register implements Instancer.
func (c *Cache) Register(ch chan<- sd.Event) {
c.mtx.Lock()
Expand Down
2 changes: 1 addition & 1 deletion sd/internal/instance/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = &Cache{} // API check
var _ sd.Instancer = (*Cache)(nil) // API check

// The test verifies the following:
// registering causes initial notification of the current state
Expand Down
2 changes: 1 addition & 1 deletion sd/zk/instancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/go-kit/kit/sd"
)

var _ sd.Instancer = &Instancer{}
var _ sd.Instancer = (*Instancer)(nil) // API check

func TestInstancer(t *testing.T) {
client := newFakeClient()
Expand Down