Add StateChanged(func(map[string]interface{}), more ...string) to client and server, to watch state updates with more customized detail, e.g. "completed:result" as default, e.g. pending:next\|task\|message\|result

This commit is contained in:
mindon
2022-10-19 11:11:05 +08:00
parent c08f142b56
commit dbe886c071
4 changed files with 138 additions and 8 deletions

View File

@@ -150,9 +150,9 @@ func (t deadlineOption) Value() interface{} { return time.Time(t) }
// TTL duration must be greater than or equal to 1 second.
//
// Uniqueness of a task is based on the following properties:
// - Task Type
// - Task Payload
// - Queue Name
// - Task Type
// - Task Payload
// - Queue Name
func Unique(ttl time.Duration) Option {
return uniqueOption(ttl)
}
@@ -426,3 +426,8 @@ func (c *Client) addToGroup(ctx context.Context, msg *base.TaskMessage, group st
}
return c.broker.AddToGroup(ctx, msg, group)
}
// StateChanged watchs state updates, with more customized detail
func (c *Client) StateChanged(handler func(map[string]interface{}), more ...string) error {
return c.broker.StateChanged(handler, more...)
}