2016-12-01 11:40:58 -02:00
|
|
|
package messaging
|
2016-11-25 18:51:34 -02:00
|
|
|
|
2017-05-24 18:23:07 -03:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type EventHandler func(body []byte) error
|
2016-11-25 18:51:34 -02:00
|
|
|
|
2017-10-05 14:11:11 -03:00
|
|
|
type SubscribeOptions struct {
|
|
|
|
// The action name.
|
|
|
|
Action string
|
|
|
|
// The function that will be called.
|
|
|
|
Handler EventHandler
|
|
|
|
// The time to retry after it fails.
|
|
|
|
RetryDelay time.Duration
|
|
|
|
// If enable the retry time it will be incresed in power of two.
|
|
|
|
// This means if your retry delay is 1s, the first retry will be after 1s,
|
|
|
|
// the sencond 2s, the third 4s and so on.
|
|
|
|
DelayedRetry bool
|
|
|
|
// Max attempts to retry.
|
|
|
|
MaxRetries int32
|
|
|
|
}
|
|
|
|
|
2016-12-01 10:52:22 -02:00
|
|
|
type Consumer interface {
|
|
|
|
Subscribe(action string, handler EventHandler) error
|
2017-10-05 14:11:11 -03:00
|
|
|
SubscribeWithOptions(options SubscribeOptions) error
|
2016-12-01 10:52:22 -02:00
|
|
|
Unsubscribe(action string) error
|
2017-03-09 17:32:05 -03:00
|
|
|
Consume()
|
2016-12-28 09:20:29 -02:00
|
|
|
Close()
|
2016-11-25 18:51:34 -02:00
|
|
|
}
|