Documentation ¶
Overview ¶
Package types defines common types used in package notify, model and drivers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Creates a new Client using current settings and different context. The // context is used with http.NewRequestWithContext to create *http.Request. With(ctx context.Context) (ret Client) // maps api endpoints to function Send(id string, driver string, ep string, payload interface{}) (err error) SendOnce(id string, driver string, ep string, payload interface{}) (err error) Resend(id string) (err error) Result(id string) (ret []byte, err error) Status(id string) (ret Status, err error) Detail(id string) (ret Detail, err error) Delete(id string) (err error) Clear(before time.Time) (err error) ForceClear(before time.Time) (err error) }
Client defines golang client to call notify.APIServer
type Detail ¶
type Detail struct { Driver string `json:"type"` Endpoint string `json:"endpoint"` Content []byte `json:"content"` Response []byte `json:"response"` Status }
Detail defines response type of /detail
type Driver ¶
type Driver interface { // driver type, 3rd party drivers *SHOULD* use go import path format like // github.com/some_org/some_proj/DRIVER_NAME Type() string // send the notification Send(ep string, content []byte) (resp []byte, err error) // check the payload format. content is in json format Verify(content []byte) (err error) // check endpoint format. CheckEP(ep string) (err error) }
Driver defines the interface a driver must implement
type Params ¶
type Params struct { // notification ID. It has to be unique as used as primary key in DB. ID string `json:"id"` // driver type Driver string `json:"type"` // endpoint to recieve notification. see docs of the driver for detail Endpoint string `json:"endpoint"` // driver specific parameters. see docs of the driver for detail Payload json.RawMessage `json:"payload"` }
Params defines required parameters of API endpoint /send and /sendOnce
type Scheduler ¶
type Scheduler func(driver, notifyID string, lastExec time.Time, tried uint32) (next time.Time, stop bool)
Scheduler is an user-defined function to determine when to resend notification
Click to show internal directories.
Click to hide internal directories.