Skip to content

Commit

Permalink
disco: Add Name method to Service object (#233)
Browse files Browse the repository at this point in the history
This will help with logging in apps that use this module.
  • Loading branch information
benkeith-splunk authored Feb 1, 2022
1 parent ff8e29a commit 9a067f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions disco/disco.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ func (s *Service) ServiceInstances() (ret []ServiceInstance) {
return ret
}

// Name of the service
func (s *Service) Name() string {
return s.name
}

// ForceInstances overrides a disco service to have exactly the passed instances forever. Useful
// for debugging.
func (s *Service) ForceInstances(instances []ServiceInstance) {
Expand Down
1 change: 1 addition & 0 deletions disco/disco_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ func testServices(t *testing.T, z1 zktest.ZkConnSupported, ch <-chan zk.Event, z
require.NoError(t, err)
require.Equal(t, 0, len(s.ServiceInstances()))
require.NotNil(t, s.StateLog())
require.Equal(t, "not_here", s.Name())

onWatchChan := make(chan struct{})
s.Watch(func() {
Expand Down

0 comments on commit 9a067f2

Please sign in to comment.