Documentation ¶
Index ¶
- Constants
- Variables
- func Factories() []string
- func IsErrDeliveryNotFound(err error) bool
- func IsStatusRetryable(s DeliveryStatus) bool
- func Register(name string, f Factory)
- func RegisterNullFactory()
- func UnregisterAll()
- type AtomicDeliveryCenter
- type Config
- type DeliveryCenter
- type DeliveryCenterConfig
- type DeliveryDriver
- type DeliveryServer
- type DeliveryServerConfig
- type DeliveryStatus
- type ErrDeliveryNotFound
- type Factory
- type Field
- type NullDelivery
- type PlainDeliveryCenter
Constants ¶
const ( //DeliveryStatusFail status for delivery fail DeliveryStatusFail = DeliveryStatus(0) //DeliveryStatusSuccess status for delivery success DeliveryStatusSuccess = DeliveryStatus(1) //DeliveryStatusAbort status for delivery abort DeliveryStatusAbort = DeliveryStatus(2) //DeliveryStatusExpired status for delivery expired DeliveryStatusExpired = DeliveryStatus(3) //DeliveryStatusDisabled status for delivery disabled DeliveryStatusDisabled = DeliveryStatus(4) //DeliveryStatusTimeout status for delivery timeout DeliveryStatusTimeout = DeliveryStatus(5) //DeliveryStatusRetryTooMany status for delivery too many DeliveryStatusRetryTooMany = DeliveryStatus(6) )
const DeliveryNull = "null"
DeliveryNull delivery null keyword
Variables ¶
var NullFactory = func(loader func(v interface{}) error) (DeliveryDriver, error) { return NullDelivery{}, nil }
NullFactory null factory
Functions ¶
func Factories ¶
func Factories() []string
Factories returns a sorted list of the names of the registered factories.
func IsErrDeliveryNotFound ¶
IsErrDeliveryNotFound check if given error is ErrDeliveryNotFound.
func IsStatusRetryable ¶
func IsStatusRetryable(s DeliveryStatus) bool
IsStatusRetryable chech if status retryable
Types ¶
type AtomicDeliveryCenter ¶
type AtomicDeliveryCenter struct {
// contains filtered or unexported fields
}
AtomicDeliveryCenter delivery center which use atomic.Value to implement concurrently update.
func NewAtomicDeliveryCenter ¶
func NewAtomicDeliveryCenter() *AtomicDeliveryCenter
NewAtomicDeliveryCenter create new atomic delivery cemter.
func (*AtomicDeliveryCenter) DeliveryCenter ¶
func (c *AtomicDeliveryCenter) DeliveryCenter() DeliveryCenter
DeliveryCenter return delivery center actually used.
func (*AtomicDeliveryCenter) Get ¶
func (c *AtomicDeliveryCenter) Get(id string) (*DeliveryServer, error)
Get get delivery server by keyword and return any error if rasied. Notification.ErrDeliveryNotFound should be returned if give keyword not found.
func (*AtomicDeliveryCenter) List ¶
func (c *AtomicDeliveryCenter) List() ([]*DeliveryServer, error)
List all delivery servers in delivery center and any error if raised.
func (*AtomicDeliveryCenter) SetDeliveryCenter ¶
func (c *AtomicDeliveryCenter) SetDeliveryCenter(pc DeliveryCenter)
SetDeliveryCenter atomicly update delivery center.
type Config ¶
type Config struct { //DeliveryType delivery driver type DeliveryType string //DeliveryConfig delivery dirver config DeliveryConfig func(v interface{}) error `config:", lazyload"` }
Config delivery driver config
func (*Config) CreateDriver ¶
func (c *Config) CreateDriver() (DeliveryDriver, error)
CreateDriver create delivery driver.
type DeliveryCenter ¶
type DeliveryCenter interface { //List all delivery servers in delivery center and any error if raised. List() ([]*DeliveryServer, error) //Get get delivery server by keyword and return any error if rasied. //Notification.ErrDeliveryNotFound should be returned if give keyword not found. Get(keyword string) (*DeliveryServer, error) }
DeliveryCenter delivery center interface. Delivery center manages delivery servers by delivery keyword.
type DeliveryCenterConfig ¶
type DeliveryCenterConfig struct {
Server []*DeliveryServerConfig
}
DeliveryCenterConfig plain delivery center config
func (*DeliveryCenterConfig) CreateDeliveryCenter ¶
func (c *DeliveryCenterConfig) CreateDeliveryCenter() (DeliveryCenter, error)
CreateDeliveryCenter create delivery center
type DeliveryDriver ¶
type DeliveryDriver interface { //DeliveryType Delivery type DeliveryType() string //CheckInvalidContent check if given content invalid //Return invalid fields and any error raised CheckInvalidContent(notification.Content) ([]string, error) //Deliver send give content. //Return delivery status and any receipt if returned,and any error if raised. Deliver(notification.Content) (status DeliveryStatus, receipt string, err error) //ContentFields return content fields ContentFields() []*Field }
DeliveryDriver Delivery driver
type DeliveryServer ¶
type DeliveryServer struct { //Delivery delivery id Delivery string //Disabled is delivery disabled Disabled bool //Description delivery server description Description string //Driver delivery driver DeliveryDriver }
DeliveryServer delivery server struct
func NewDeliveryServer ¶
func NewDeliveryServer() *DeliveryServer
NewDeliveryServer create new delivery server
func (*DeliveryServer) Deliver ¶
func (s *DeliveryServer) Deliver(c notification.Content) (status DeliveryStatus, receipt string, err error)
Deliver send give content. Return delivery status and any receipt if returned,and any error if raised. DeliveryStatusDisabled will be returned if DeliveryServer is disabled.
type DeliveryServerConfig ¶
type DeliveryServerConfig struct { //Delivery delivery keyword Delivery string //Disabled if delivery disabled Disabled bool //Description delivery description Description string Config }
DeliveryServerConfig delivery config struct
func (*DeliveryServerConfig) CreateDeliverServer ¶
func (c *DeliveryServerConfig) CreateDeliverServer() (*DeliveryServer, error)
CreateDeliverServer create delivery server.
type DeliveryStatus ¶
type DeliveryStatus int64
DeliveryStatus delivery status type
func Deliver ¶
func Deliver(c DeliveryCenter, delivery string, content notification.Content) (status DeliveryStatus, receipt string, err error)
Deliver delivery content to delivery center with given keyword Return delivery status,receipt and any error if raised.
func DeliverNotification ¶
func DeliverNotification(c DeliveryCenter, n *notification.Notification) (status DeliveryStatus, receipt string, err error)
DeliverNotification notification to delivery center with given keyword Return delivery status,receipt and any error if raised.
type ErrDeliveryNotFound ¶
type ErrDeliveryNotFound struct {
Delivery string
}
ErrDeliveryNotFound error raised if given delivery not found
func NewErrDeliveryNotFound ¶
func NewErrDeliveryNotFound(delivery string) *ErrDeliveryNotFound
NewErrDeliveryNotFound create new ErrDeliveryNotFound
func (*ErrDeliveryNotFound) Error ¶
func (e *ErrDeliveryNotFound) Error() string
Error return error message
type Factory ¶
type Factory func(loader func(v interface{}) error) (DeliveryDriver, error)
Factory delivery driver factory
type Field ¶
type Field struct { //Name field name Name string //Escape escape method Escape string //Example example data Example string }
Field content field struct
type NullDelivery ¶
type NullDelivery struct { }
NullDelivery delivery do nothing
func (NullDelivery) CheckInvalidContent ¶
func (d NullDelivery) CheckInvalidContent(notification.Content) ([]string, error)
CheckInvalidContent check if content invalid Return invalid fields and any error raised
func (NullDelivery) ContentFields ¶
func (d NullDelivery) ContentFields() []*Field
ContentFields return content fields Return invalid fields and any error raised
func (NullDelivery) Deliver ¶
func (d NullDelivery) Deliver(notification.Content) (status DeliveryStatus, receipt string, err error)
Deliver send give content. Return delivery status and any receipt if returned,and any error if raised.
func (NullDelivery) DeliveryType ¶
func (d NullDelivery) DeliveryType() string
DeliveryType Delivery type
type PlainDeliveryCenter ¶
type PlainDeliveryCenter map[string]*DeliveryServer
PlainDeliveryCenter plain delivery center type
func NewPlainDeliveryCenter ¶
func NewPlainDeliveryCenter() PlainDeliveryCenter
NewPlainDeliveryCenter create new plain delivery center
func (PlainDeliveryCenter) Get ¶
func (c PlainDeliveryCenter) Get(id string) (*DeliveryServer, error)
Get get delivery server by keyword and return any error if rasied. Notification.ErrDeliveryNotFound should be returned if give keyword not found.
func (PlainDeliveryCenter) Insert ¶
func (c PlainDeliveryCenter) Insert(d *DeliveryServer)
Insert insert delivery server to c
func (PlainDeliveryCenter) List ¶
func (c PlainDeliveryCenter) List() ([]*DeliveryServer, error)
List all delivery servers in delivery center and any error if raised. Result will be sorted by delivery.