diff --git a/config.go b/config.go index 15b3e5b..e7a7da2 100644 --- a/config.go +++ b/config.go @@ -8,7 +8,7 @@ import ( ) type config struct { - processId string + ProcessId string Namespace string PollInterval int Pool *redis.Pool @@ -73,8 +73,10 @@ func Configure(options map[string]string) { return err }, }, - func(queue string) Fetcher { - return NewFetch(queue, make(chan *Msg), make(chan bool)) - }, + DefaultFetch, } } + +func DefaultFetch(queue string) Fetcher { + return NewFetch(queue, make(chan *Msg), make(chan bool)) +} diff --git a/config_test.go b/config_test.go index afde76d..d429c7a 100644 --- a/config_test.go +++ b/config_test.go @@ -31,14 +31,14 @@ func ConfigSpec(c gospec.Context) { }) c.Specify("can specify custom process", func() { - c.Expect(Config.processId, Equals, "1") + c.Expect(Config.ProcessId, Equals, "1") Configure(map[string]string{ "server": "localhost:6379", "process": "2", }) - c.Expect(Config.processId, Equals, "2") + c.Expect(Config.ProcessId, Equals, "2") }) c.Specify("requires a server parameter", func() { diff --git a/fetcher.go b/fetcher.go index 04ff0a4..18f4c6d 100644 --- a/fetcher.go +++ b/fetcher.go @@ -152,5 +152,5 @@ func (f *fetch) inprogressMessages() []string { } func (f *fetch) inprogressQueue() string { - return fmt.Sprint(f.queue, ":", Config.processId, ":inprogress") + return fmt.Sprint(f.queue, ":", Config.ProcessId, ":inprogress") } diff --git a/manager_test.go b/manager_test.go index cf7adb6..d7981b0 100644 --- a/manager_test.go +++ b/manager_test.go @@ -1,7 +1,8 @@ package workers import ( - "fmt" + "reflect" + "runtime" "sync" "time" @@ -54,7 +55,9 @@ func ManagerSpec(c gospec.Context) { c.Specify("sets job function", func() { manager := newManager("myqueue", testJob, 10) - c.Expect(fmt.Sprint(manager.job), Equals, fmt.Sprint(testJob)) + expected := runtime.FuncForPC(reflect.ValueOf(manager.job).Pointer()).Name() + actual := runtime.FuncForPC(reflect.ValueOf(testJob).Pointer()).Name() + c.Expect(expected, Equals, actual) }) c.Specify("sets worker concurrency", func() {