diff --git a/workers.go b/workers.go index e33035f..45a0ce8 100644 --- a/workers.go +++ b/workers.go @@ -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 +} diff --git a/workers_test.go b/workers_test.go new file mode 100644 index 0000000..5860a0c --- /dev/null +++ b/workers_test.go @@ -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 +}