Documentation ¶
Overview ¶
Package xwebhook provides an event webhook registry component for XMiDT services.
Deprecated: xwebhook has moved to https://github.com/xmidt-org/ancla.
This package is frozen and no new functionality will be added.
Index ¶
Constants ¶
const ( // ClientIDHeader provides a fallback method for fetching the client ID of users // registering their webhooks. The main method fetches this value from the claims of // the authentication JWT. ClientIDHeader = "X-Xmidt-Client-Id" )
const (
WebhookListSizeGauge = "webhook_list_size_value"
)
Names
Variables ¶
This section is empty.
Functions ¶
func NewAddWebhookHandler ¶
Types ¶
type Config ¶
type Config struct { // Argus contains all the argus specific configurations Argus chrysom.ClientConfig // WatchUpdateInterval is the duration between each update to all watchers. WatchUpdateInterval time.Duration }
Config provides the different options for the initializing the wehbook service.
type PushReader ¶
type Service ¶
type Service interface { // Add adds the given owned webhook to the current list of webhooks. If the operation // succeeds, a non-nil error is returned. Add(owner string, w *Webhook) error // AllWebhooks lists all the current webhooks for the given owner. // If an owner is not provided, all webhooks are returned. AllWebhooks(owner string) ([]Webhook, error) }
Service describes the core operations around webhook subscriptions. Initialize() provides a service ready to use and the controls around watching for updates.
func Initialize ¶
Initialize builds the webhook service from the given configuration. It allows adding watchers for the internal subscription state. Call the returned function when you are done watching for updates.
type Watch ¶
type Watch interface {
Update([]Webhook)
}
Watch is the interface for listening for webhook subcription updates. Updates represent the latest known list of subscriptions.
type Webhook ¶
type Webhook struct { // Address is the subscription request origin HTTP Address. Address string `json:"registered_from_address"` // Config contains data to inform how events are delivered. Config struct { // URL is the HTTP URL to deliver messages to. URL string `json:"url"` // ContentType is content type value to set WRP messages to (unless already specified in the WRP). ContentType string `json:"content_type"` // Secret is the string value for the SHA1 HMAC. // (Optional, set to "" to disable behavior). Secret string `json:"secret,omitempty"` // AlternativeURLs is a list of explicit URLs that should be round robin through on failure cases to the main URL. AlternativeURLs []string `json:"alt_urls,omitempty"` } `json:"config"` // FailureURL is the URL used to notify subscribers when they've been cut off due to event overflow. // Optional, set to "" to disable notifications. FailureURL string `json:"failure_url"` // Events is the list of regular expressions to match an event type against. Events []string `json:"events"` // Matcher type contains values to match against the metadata. Matcher struct { // DeviceID is the list of regular expressions to match device id type against. DeviceID []string `json:"device_id"` } `json:"matcher,omitempty"` // Duration describes how long the subscription lasts once added. // Deprecated. User input is ignored and value is always 5m. Duration time.Duration `json:"duration"` // Until describes the time this subscription expires. Until time.Time `json:"until"` }
Webhook contains all the information needed to serve events to webhook listeners.