Documentation ¶
Index ¶
- Constants
- Variables
- func Factories() []string
- func NopExecutionHandler(e *Execution)
- func NopIDGenerator() (string, error)
- func NopNotificationHandler(n *notification.Notification)
- func NopReceiptHanlder(*Receipt)
- func NopRecover()
- func Register(name string, f Factory)
- func UnregisterAll()
- type CommonConfig
- type Config
- type Directive
- type DirectiveConfig
- type DirectiveFunc
- type Execution
- type Factory
- type NopQueue
- type Notifier
- func (notifier *Notifier) HandleDeliverTimeout(e *Execution)
- func (notifier *Notifier) HandleRetryTooMany(e *Execution)
- func (notifier *Notifier) InitNotification(n *notification.Notification) error
- func (notifier *Notifier) Notify(n *notification.Notification) error
- func (notifier *Notifier) Queue() Queue
- func (notifier *Notifier) Reset()
- func (notifier *Notifier) SetQueue(q Queue)
- func (notifier *Notifier) Start() error
- func (notifier *Notifier) Stop() error
- type Publisher
- func (publisher *Publisher) DraftboxLoader() notification.Store
- func (publisher *Publisher) PublishDraft(nid string) (*notification.Notification, error)
- func (publisher *Publisher) PublishNotification(n *notification.Notification) (string, bool, error)
- func (publisher *Publisher) Start() error
- func (publisher *Publisher) Stop() error
- type Queue
- type Receipt
Constants ¶
const DirectiveNameCommon = "common"
Variables ¶
var CheckerDraftModeHeader = notification.HasHeaderChecker(notification.HeaderNameDraftMode)
var ErrIDGeneratorRequired = errors.New("id generator required")
ErrIDGeneratorRequired id generator required
var ErrQueueDriverRequired = errors.New("queue driver required")
ErrQueueDriverRequired queue driver required error.
var FactoryCommon = func(loader func(v interface{}) error) (Directive, error) { c := &CommonConfig{} err := loader(c) if err != nil { return nil, err } return c, nil }
Functions ¶
func Factories ¶
func Factories() []string
Factories returns a sorted list of the names of the registered factories.
func NopExecutionHandler ¶
func NopExecutionHandler(e *Execution)
NopExecutionHandler nop execution handelr
func NopNotificationHandler ¶
func NopNotificationHandler(n *notification.Notification)
NopNotificationHandler nop notification heandler
Types ¶
type CommonConfig ¶
type CommonConfig struct {
Workers int
}
func (*CommonConfig) AppylToPublisher ¶
func (c *CommonConfig) AppylToPublisher(p *Publisher) error
type Directive ¶
type Directive interface { //AppylToPublisher applu directive to publisher AppylToPublisher(*Publisher) error }
Directive publisher directive
type DirectiveConfig ¶
type DirectiveConfig struct { //Directive directive keyword Directive string //DirectiveConfig directive config DirectiveConfig func(v interface{}) error `config:", lazyload"` }
DirectiveConfig Directive config
type DirectiveFunc ¶
DirectiveFunc directive func
func (DirectiveFunc) AppylToPublisher ¶
func (f DirectiveFunc) AppylToPublisher(p *Publisher) error
AppylToPublisher applu directive to publisher
type Execution ¶
type Execution struct { //ExecutionID execition id ExecutionID string //Notification notification to execute Notification *notification.Notification //RetryCount retry count RetryCount int32 //StartTime execution start time StartTime int64 //RetryAfterTime execution retry after time RetryAfterTime int64 }
Execution notification Execution
type NopQueue ¶
type NopQueue struct { }
NopQueue struct
func (*NopQueue) Push ¶
func (*NopQueue) Push(*notification.Notification) error
Push push notification to queue
type Notifier ¶
type Notifier struct { //DeliveryCenter notificationdelivery.DeliveryCenter //Workers push workers num Workers int //IDGenerator id generator IDGenerator func() (string, error) //OnNotification notification handler OnNotification func(*notification.Notification) //OnReceipt receipt handler OnReceipt func(*Receipt) //OnExecution execution handler OnExecution func(*Execution) //Recover recover handler Recover func() // contains filtered or unexported fields }
Notifier notifier struct
func (*Notifier) HandleDeliverTimeout ¶
HandleDeliverTimeout deliver timeout handler
func (*Notifier) HandleRetryTooMany ¶
HandleRetryTooMany retry toomany handler
func (*Notifier) InitNotification ¶
func (notifier *Notifier) InitNotification(n *notification.Notification) error
func (*Notifier) Notify ¶
func (notifier *Notifier) Notify(n *notification.Notification) error
Notify delivery notification Notification id will be returned
type Publisher ¶
type Publisher struct { //DraftReviewer checker that check if given notification should be published or put in draft box. //Return true if notification should sendt to draftbox //Default value is CheckerDraftModeHeader DraftReviewer notification.Checker Draftbox notification.Store *Notifier }
Publisher publisher struct
func (*Publisher) DraftboxLoader ¶
func (publisher *Publisher) DraftboxLoader() notification.Store
DraftboxLoader draftbox loader
func (*Publisher) PublishDraft ¶
func (publisher *Publisher) PublishDraft(nid string) (*notification.Notification, error)
PublishDraft publish notificaiton by given id. Notification.ErrNotificationIDNotFound will be returned if nid not found.
func (*Publisher) PublishNotification ¶
func (publisher *Publisher) PublishNotification(n *notification.Notification) (string, bool, error)
PublishNotification generate notification id and publish given notification Return notification id and if notification is published.
type Queue ¶
type Queue interface { //PopChan return execution chan PopChan() (<-chan *Execution, error) //Push push notification to queue Push(*notification.Notification) error //Remove remove notification by given id Remove(nid string) error //Start start queue Start() error //Stop stop queue Stop() error //AttachTo attach queue to notifier AttachTo(*Notifier) error //Detach detach queue. Detach() error }
Queue notification deliver queue
type Receipt ¶
type Receipt struct { //NotificationID notification id Notification *notification.Notification //ExecutionID notification execution id ExecutionID string //Status delivery status Status notificationdelivery.DeliveryStatus //Message. receipt for successfully delivery or resofn fail fail delivery Message string }
Receipt notification receipt struct