Skip to content

Commit 86b92ba

Browse files
committed
refactor: refactor queue handling to use core TaskMessage interface
- Add import for `github.com/golang-queue/queue/core` - Change function parameter type from `queue.QueuedMessage` to `core.TaskMessage` - Replace `m.Bytes()` with `m.Payload()` in JSON unmarshal function Signed-off-by: appleboy <[email protected]>
1 parent f1214fa commit 86b92ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636

3737
"github.com/golang-queue/nats"
3838
"github.com/golang-queue/queue"
39+
"github.com/golang-queue/queue/core"
3940
)
4041

4142
type job struct {
@@ -59,9 +60,9 @@ func main() {
5960
nats.WithAddr("127.0.0.1:4222"),
6061
nats.WithSubj("example"),
6162
nats.WithQueue("foobar"),
62-
nats.WithRunFunc(func(ctx context.Context, m queue.QueuedMessage) error {
63+
nats.WithRunFunc(func(ctx context.Context, m core.TaskMessage) error {
6364
var v *job
64-
if err := json.Unmarshal(m.Bytes(), &v); err != nil {
65+
if err := json.Unmarshal(m.Payload(), &v); err != nil {
6566
return err
6667
}
6768
rets <- v.Message

0 commit comments

Comments
 (0)