1
0
mirror of https://github.com/eventials/goevents.git synced 2025-04-26 13:48:59 +08:00

33 lines
723 B
Go
Raw Normal View History

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"
)
2017-10-05 15:19:54 -03:00
const (
MaxInt32 = 1<<31 - 1
MaxRetries = MaxInt32
)
2016-11-25 18:51:34 -02:00
2017-10-05 14:11:11 -03:00
type SubscribeOptions struct {
// 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
}
2017-10-05 15:19:54 -03:00
type EventHandler func(Event) error
2016-12-01 10:52:22 -02:00
type Consumer interface {
2017-10-05 16:22:28 -03:00
Subscribe(action string, handler EventHandler, options *SubscribeOptions) error
2016-12-01 10:52:22 -02:00
Unsubscribe(action string) error
BindActions(actions ...string) error
UnbindActions(actions ...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
}