Skip to content

Commit

Permalink
improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Mar 18, 2024
1 parent c18f9e6 commit 1ab91ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ go get github.com/stanipetrosyan/go-eventbus
And import
``` go
import (
goeventbus "github.com/StaniPetrosyan/go-eventbus"
goeventbus "github.com/stanipetrosyan/go-eventbus"
)

```

## Publish/Subscribe

Simple example of publish/subscribe pattern.

```go

var eventbus = goeventbus.NewEventBus()
Expand All @@ -40,10 +42,7 @@ eventbus.Channel(address).Subscriber().Listen(func(dc goeventbus.Context) {
fmt.Printf("Message %s\n", dc.Result().Data)
})

for {
eventbus.Channel(address).Publisher().Publish(message)
time.Sleep(time.Second)
}
eventbus.Channel(address).Publisher().Publish(message)
```

## Message
Expand All @@ -67,6 +66,8 @@ eventBus.Channel("address").Publisher().Publish(message)

## Processor

A processor works like a middleware, in fact forwards messages only if the predicate is satisfied. The method accepts a function with message and return must return a boolean.

```go

eventbus.Channel("topic1").Processor(func(message goeventbus.Message) bool {
Expand Down

0 comments on commit 1ab91ed

Please sign in to comment.