[PR #561] [CLOSED] Add StateChanged(func(map[string]interface{}), more ...string) #2799

Closed
opened 2026-03-15 21:03:56 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/561
Author: @mindon
Created: 10/19/2022
Status: Closed

Base: masterHead: master


📝 Commits (4)

  • dbe886c 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
  • 8f9b0c0 remove message and add TaskDetail to transform base.TaskInfo to TaskInfo
  • f9f966d update status value and fix active state bug
  • c02e721 reverse active state pub

📊 Changes

5 files changed (+146 additions, -12 deletions)

View changed files

📝 asynq.go (+11 -4)
📝 client.go (+8 -3)
📝 internal/base/base.go (+3 -0)
📝 internal/rdb/rdb.go (+119 -5)
📝 server.go (+5 -0)

📄 Description

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 part of completed output.

The format of more string is "state:next | task | message | result", e.g. pending:message

here a example for workers

go srv.StateChanged(func(out map[string]interface{}) {
	fmt.Println(out)
	if result, ok := out["result"]; ok {
		fmt.Println(string(result.([]byte)))
	}
})```

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/hibiken/asynq/pull/561 **Author:** [@mindon](https://github.com/mindon) **Created:** 10/19/2022 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (4) - [`dbe886c`](https://github.com/hibiken/asynq/commit/dbe886c071a70b0e7f3867a5e2e81dbdbdba8c5c) 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 - [`8f9b0c0`](https://github.com/hibiken/asynq/commit/8f9b0c00874381e284249feb967db12b921e1561) remove message and add TaskDetail to transform base.TaskInfo to TaskInfo - [`f9f966d`](https://github.com/hibiken/asynq/commit/f9f966dfb3333667c1f5c3be34fb0cfc3ce7257f) update status value and fix active state bug - [`c02e721`](https://github.com/hibiken/asynq/commit/c02e721a136fb8ba91b5deb4ed2e7ce122a15348) reverse active state pub ### 📊 Changes **5 files changed** (+146 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `asynq.go` (+11 -4) 📝 `client.go` (+8 -3) 📝 `internal/base/base.go` (+3 -0) 📝 `internal/rdb/rdb.go` (+119 -5) 📝 `server.go` (+5 -0) </details> ### 📄 Description 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 part of completed output. The format of more string is "state:next | task | message | result", e.g. pending:message here a example for workers ``` go srv.StateChanged(func(out map[string]interface{}) { fmt.Println(out) if result, ok := out["result"]; ok { fmt.Println(string(result.([]byte))) } })``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 21:03:56 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2799
No description provided.