Documentation ¶
Overview ¶
Package websox provides a wrapper for a client to initiate and handle data push requests from a server
Package websox provides a wrapper for a client to initiate and handle data push requests from a server
Package websox provides a wrapper for a client to initiate and handle data push requests from a server
Package websox provides a wrapper for a client to initiate and handle data push requests from a server
Index ¶
- Constants
- func Client(url string, fn Actionable, pings bool, headers http.Header, logger *log.Logger) error
- func MakeClientCredentialsTokenSource(ctx context.Context, url, cid, secret string) oauth2.TokenSource
- func Oauth2Header(ctx context.Context, url, cid, secret string) (http.Header, error)
- func Pusher(setup Setup, expires, pingFreq time.Duration, contacted func(), ...) http.HandlerFunc
- type Actionable
- type Results
- type Setup
- type Stuff
Constants ¶
const ( // LogFlags are the default log flags LogFlags = log.Ldate | log.Lmicroseconds | log.Lshortfile )
Variables ¶
This section is empty.
Functions ¶
func Client ¶
Client connects to url and applies the Actionable function to each message received url specifices the websocket endpoint to connect to pings will log websocket pings if set true headers supplies optional http headers for authentication logger logs actions
func MakeClientCredentialsTokenSource ¶
func MakeClientCredentialsTokenSource(ctx context.Context, url, cid, secret string) oauth2.TokenSource
MakeClientCredentialsTokenSource returns an oauth2 token source for validation
func Oauth2Header ¶
Oauth2Header returns headers to access protected http endpoints
Types ¶
type Actionable ¶
Actionable functions process an io.Reader and returns any relevant results a bool set false if to close the client, and an error if such is encountered
type Results ¶
type Results struct { ErrMsg string `json:"error"` Payload *json.RawMessage `json:"payload"` }
Results is used to return client results / errors on websocket pushes
type Setup ¶
Setup returns a channel to get data and one that return an error value and optional artifacts from the results of that action
If the setup function cannot do the required processing, it should return a nil interface channel and send an error message in the error channel
The Results channel is closed by Pusher() when it is done processing (due to session timeout or error)