Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPEvents ¶
type HTTPEvents struct { Endpoint string // contains filtered or unexported fields }
func NewHTTPEvents ¶
func NewHTTPEvents(client *httpCore.Client, endpoint string, ctxProducer func() (ctx context.Context, canceller func()), refreshRate time.Duration) *HTTPEvents
NewHTTPEvents makes an EventProducer which creates events by pinging an external HTTP API for updates periodically. If refreshRate is negative, then the data will never be refreshed.
It expects the following endpoint to exist remotely:
GET {endpoint}
-- Returns all the known Stored Requests and Stored Imps.
GET {endpoint}?last-modified={timestamp}
-- Returns the Stored Requests and Stored Imps which have been updated since the last timestamp. This timestamp will be sent in the rfc3339 format, using UTC and no timezone shift. For more info, see: https://tools.ietf.org/html/rfc3339
The responses should be JSON like this:
{ "requests": { "request1": { ... stored request data ... }, "request2": { ... stored request data ... }, "request3": { ... stored request data ... }, }, "imps": { "imp1": { ... stored data for imp1 ... }, "imp2": { ... stored data for imp2 ... }, }, "responses": { "resp1": { ... stored data for resp1 ... }, "resp2": { ... stored data for resp2 ... }, } }
or
{ "accounts": { "acc1": { ... config data for acc1 ... }, "acc2": { ... config data for acc2 ... }, }, }
To signal deletions, the endpoint may return { "deleted": true } in place of the Stored Data if the "last-modified" param existed.
func (*HTTPEvents) Invalidations ¶
func (e *HTTPEvents) Invalidations() <-chan events.Invalidation
func (*HTTPEvents) Saves ¶
func (e *HTTPEvents) Saves() <-chan events.Save
Click to show internal directories.
Click to hide internal directories.