Skip to content

Commit

Permalink
Add a method to eventd to get number of workers (sensu#4279)
Browse files Browse the repository at this point in the history
Needed for work in sensu-enterprise-go

Signed-off-by: Eric Chlebek <[email protected]>
  • Loading branch information
echlebek authored May 5, 2021
1 parent 0273cca commit b677006
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/eventd/eventd.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,8 @@ func (e *Eventd) Err() <-chan error {
func (e *Eventd) Name() string {
return "eventd"
}

// Workers returns the number of configured worker goroutines.
func (e *Eventd) Workers() int {
return e.workerCount
}
13 changes: 13 additions & 0 deletions backend/eventd/eventd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,16 @@ func entityNotFound(s *storetest.Store, namespace, name string) {
func entityLookupError(s *storetest.Store, namespace, name string) {
entityError(s, namespace, name, errors.New("some error"))
}

func TestWorkerCount(t *testing.T) {
// TODO(eric): this is tech debt, better to pass in a config with this
// property and test after New(). Unfortunately, New() requires a working
// etcd client and would be too heavy for this test.
const workers = 10
daemon := Eventd{
workerCount: workers,
}
if got, want := daemon.Workers(), workers; got != want {
t.Fatalf("bad workers: got %d, want %d", got, want)
}
}

0 comments on commit b677006

Please sign in to comment.