Add test for jobs (#34)

This commit is contained in:
Jonas Plum
2022-02-27 18:33:50 +01:00
committed by GitHub
parent fd18458f3d
commit ffba7b4f5f
18 changed files with 181 additions and 80 deletions

View File

@@ -26,11 +26,11 @@ func (b *Bus) PublishRequest(user, f string, ids []driver.DocumentID) error {
func (b *Bus) SubscribeRequest(f func(msg *RequestMsg)) error {
return b.safeSubscribe(b.config.requestKey, ChannelRequest, func(c *emitter.Client, m emitter.Message) {
var msg RequestMsg
if err := json.Unmarshal(m.Payload(), &msg); err != nil {
msg := &RequestMsg{}
if err := json.Unmarshal(m.Payload(), msg); err != nil {
log.Println(err)
return
}
go f(&msg)
go f(msg)
})
}

View File

@@ -23,11 +23,11 @@ func (b *Bus) PublishResult(automation string, data map[string]interface{}, targ
func (b *Bus) SubscribeResult(f func(msg *ResultMsg)) error {
return b.safeSubscribe(b.config.resultBusKey, channelResult, func(c *emitter.Client, m emitter.Message) {
var msg ResultMsg
if err := json.Unmarshal(m.Payload(), &msg); err != nil {
msg := &ResultMsg{}
if err := json.Unmarshal(m.Payload(), msg); err != nil {
log.Println(err)
return
}
go f(&msg)
go f(msg)
})
}