Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackAttempt ¶
type CallbackAttempt struct { // 0 if the endpoint was unavailable or did not provide a response within // the server timeout. StatusCode int `json:"statuscode"` // The data received in the HTTP reponse. Response CallbackData `json:"response"` // The time that the callback was made. Time time.Time `json:"time"` // The duration that the server took to respond to the callback request. Duration time.Duration `json:"duration"` }
CallbackAttempt provides the result of a Callback.
type CallbackData ¶
type CallbackData struct { // HTTP headers to apply to the callback Headers map[string]string `json:"headers"` // Form post data (used when the Method is POST or PUT) Data []byte `json:"data"` }
CallbackData stores the larger data used in HTTP request / reponses.
type CallbackLock ¶
type CallbackLock struct { // The time that the lock was acquired. Acquired time.Time `json:"acquired"` // The time that the lock expires. Timeout time.Time `json:"timeout"` // Set to true when the lock is no longer required. Completed bool `json:"completed"` // The name of the machine which has acquired the lock. MachineName string `json:"machinename"` }
CallbackLock allows the background services running on multiple servers to acquire a temporary lock against the callback request. The lock is held for a timeout period which allows the background service to attempt to complete the callback. If the callback server does not respond within the lock timeout, the attempt is logged as a failure, the lock cancelled, and a retry may occur.
If the attempt is not completed and the lock cancelled within the lock timeout period, (for example, if the background service is terminated unexpectedly), another background service instance can attempt to execute the callback.
type CallbackRequest ¶
type CallbackRequest struct { // Specifies the location the callback should be sent to URL string `json:"url"` // One of GET, POST, PUT Method string `json:"method"` // Data to send via HTTP headers or form post. PostData CallbackData `json:"postdata"` // The number of times to rety sending the callback, divided up into phases // which have their own delay. This allows the construction of policy which // attempts rapid retries in the first minute, followed by retrying every 5 // minutes for an hour before failing. RetryPhases []RetryPhase `json:"retryphases"` // The name of the Application which is requesting that callbacks are made. ApplicationID string `json:"applicationid"` // Defines the queue that the message belongs to, for example, // a unique queue might be created per customer or order. // Example queue names: // HONDA - Ensures ordered messaging for all HONDA vehicles. // HONDA_CIVIC - Ensures ordered messaging for HONDA CIVIC vehicles. // If not set, then a random queue is created for the Callback. QueueID string `json:"queueid"` // The email address to notify if the callback fails. NotificationEmailAddress string `json:"notificationemailaddress"` }
CallbackRequest defines the message which will be sent to the remote location.
func NewCallbackRequest ¶
func NewCallbackRequest() *CallbackRequest
NewCallbackRequest creates an empty CallbackRequest struct.
type CallbackStatus ¶
type CallbackStatus struct { ID string `bson:"_id" json:"id"` // Information about the initial request. Request CallbackRequest `json:"request"` // A list of all attempts which have been made. Attempts []CallbackAttempt `json:"attempts"` // All of the locks associated with the callback. Locks []CallbackLock `json:"locks"` // Whether any of the attempts are classified as successful. Succcess bool `json:"success"` }
CallbackStatus provides the status of a callback, including all attempts.
func NewCallbackStatus ¶
func NewCallbackStatus() *CallbackStatus
NewCallbackStatus creates a CallbackStatus with Attempts and Locks initialised to empty slices.
type DataAccess ¶
type DataAccess interface { StoreCallbackRequest(request *CallbackRequest) (*CallbackStatus, error) GetCallbackStatus(id string) (*CallbackStatus, error) }
The DataAccess interface defines how data is written to the data store.
type RetryPhase ¶
A RetryPhase defines how the CallbackRequest will handle failure. For example, if the