Skip to content

Commit

Permalink
updated readme and example
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Mar 30, 2024
1 parent aa5b05d commit 122fb7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ A processor works like a middleware, in fact forwards messages only if the predi
```go

eventbus.Channel("topic1").Processor(func(message goeventbus.Message) bool {
return message.
return message.Options.Headers().Contains("header")
})
```

Expand Down
6 changes: 3 additions & 3 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
})

eventbus.Channel("topic1").Processor(func(message goeventbus.Message) bool {
return message.Data == "Hi topic 1"
return message.Options.Headers().Contains("header")
})

eventbus.Channel("topic2").Subscriber().Listen(func(dc goeventbus.Context) {
Expand Down Expand Up @@ -49,10 +49,10 @@ func publishTo(address string, data string) {
message := goeventbus.CreateMessage().SetBody(data).SetOptions(options)
for {
eventbus.Channel(address).Publisher().Publish(message)
time.Sleep(time.Second * 2)
time.Sleep(time.Second)
}
}

func printMessage(data goeventbus.Message) {
fmt.Printf("Message %s, Headers %s\n", data.Data, data.Options)
fmt.Printf("Message %s, Headers %s\n", data.Data, data.Options.Headers())
}

0 comments on commit 122fb7c

Please sign in to comment.