Skip to content

Commit

Permalink
refactor: refactor job type handling and improve test reliability
Browse files Browse the repository at this point in the history
- Refactor job type assertion and JSON unmarshalling logic in the main function

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jan 20, 2025
1 parent b64c331 commit 5461ddb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ func main() {
redisdb.WithAddr("127.0.0.1:6379"),
redisdb.WithChannel("foobar"),
redisdb.WithRunFunc(func(ctx context.Context, m queue.TaskMessage) error {
v, ok := m.(*job)
if !ok {
if err := json.Unmarshal(m.Bytes(), &v); err != nil {
return err
}
var v job
if err := json.Unmarshal(m.Payload(), &v); err != nil {
return err
}

rets <- v.Message
Expand Down

0 comments on commit 5461ddb

Please sign in to comment.