Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the workers list #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ func init() {
func Register(class string, worker workerFunc) {
workers[class] = worker
}

func Workers() []string {
mk := make([]string, len(workers))
for k, _ := range workers {
mk = append(mk, k)
}
return mk
}
18 changes: 18 additions & 0 deletions workers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package goworker

import (
"reflect"
"testing"
)

func TestWorkers(t *testing.T) {
Register("SomeJob", fakePerformer)
workers := Workers()
if reflect.DeepEqual(workers, []string{"SomeJob"}) {
t.Error("Excepted worker \"SomeJob\" to be registered")
}
}

func fakePerformer(queue string, args ...interface{}) error {
return nil
}