Documentation
¶
Index ¶
- func CreateGripChannelHeader(channels []*Channel) string
- func CreateHold(mode string, channels []*Channel, response interface{}, timeout *int) (string, error)
- func CreateHoldResponse(channels []*Channel, response interface{}, timeout *int) (string, error)
- func CreateHoldStream(channels []*Channel, response interface{}) (string, error)
- func EncodeWebSocketEvents(events []*WebSocketEvent) string
- func ParseGripUri(rawUri string) (map[string]interface{}, error)
- func ValidateSig(token, key string) bool
- func WebSocketControlMessage(messageType string, args map[string]interface{}) (string, error)
- type Channel
- type GripFormatError
- type GripPubControl
- func (gpc *GripPubControl) ApplyGripConfig(config []map[string]interface{})
- func (gpc *GripPubControl) PublishHttpResponse(channel string, http_response interface{}, id, prevId string) error
- func (gpc *GripPubControl) PublishHttpStream(channel string, http_stream interface{}, id, prevId string) error
- type GripPublishError
- type HttpResponseFormat
- type HttpStreamFormat
- type Response
- type WebSocketEvent
- type WebSocketMessageFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGripChannelHeader ¶
Create a GRIP channel header for the specified channels. The channels parameter can be specified as a string representing the channel name, a Channel instance, or an array of Channel instances. The returned GRIP channel header is used when sending instructions to GRIP proxies via HTTP headers.
func CreateHold ¶
func CreateHold(mode string, channels []*Channel, response interface{}, timeout *int) (string, error)
Create GRIP hold instructions for the specified mode, channels, response and optional timeout value. The response parameter can be specified as either a string / byte array representing the response body or a Response instance.
func CreateHoldResponse ¶
A convenience method for creating GRIP hold response instructions for HTTP long-polling. This method simply passes the specified parameters to the create_hold method with 'response' as the hold mode.
func CreateHoldStream ¶
A convenience method for creating GRIP hold stream instructions for HTTP streaming. This method simply passes the specified parameters to the create_hold method with 'stream' as the hold mode.
func EncodeWebSocketEvents ¶
func EncodeWebSocketEvents(events []*WebSocketEvent) string
Encode the specified array of WebSocketEvent instances. The returned string value should then be passed to a GRIP proxy in the body of an HTTP response when using the WebSocket-over-HTTP protocol.
func ParseGripUri ¶
Parse the specified GRIP URI into a config object that can then be passed to the GripPubControl struct. The URI can include 'iss' and 'key' JWT authentication query parameters as well as any other required query string parameters. The JWT 'key' query parameter can be provided as-is or in base64 encoded format.
func ValidateSig ¶
Validate the specified JWT token and key. This method is used to validate the GRIP-SIG header coming from GRIP proxies such as Pushpin or Fanout.io. Note that the token expiration is also verified.
func WebSocketControlMessage ¶
Generate a WebSocket control message with the specified type and optional arguments. WebSocket control messages are passed to GRIP proxies and example usage includes subscribing/unsubscribing a WebSocket connection to/from a channel.
Types ¶
type Channel ¶
The Channel class is used to represent a channel in for a GRIP proxy and tracks the previous ID of the last message.
type GripFormatError ¶
type GripFormatError struct {
// contains filtered or unexported fields
}
An error object used to represent a GRIP formatting error.
func (GripFormatError) Error ¶
func (e GripFormatError) Error() string
The function used to retrieve the message associated with a GripFormatError.
type GripPubControl ¶
type GripPubControl struct {
*pubcontrol.PubControl
}
The GripPubControl struct allows consumers to easily publish HTTP response and HTTP stream format messages to GRIP proxies. Configuring GripPubControl is slightly different from configuring PubControl in that the 'uri' and 'iss' keys in each config entry should have a 'control_' prefix. GripPubControl inherits from PubControl and therefore also provides all of the same functionality.
func NewGripPubControl ¶
func NewGripPubControl(config []map[string]interface{}) *GripPubControl
Initialize with or without a configuration. A configuration can be applied after initialization via the apply_grip_config method.
func (*GripPubControl) ApplyGripConfig ¶
func (gpc *GripPubControl) ApplyGripConfig(config []map[string]interface{})
Apply the specified GRIP configuration to this GripPubControl instance. The configuration object can either be a hash or an array of hashes where each hash corresponds to a single PubControlClient instance. Each hash will be parsed and a PubControlClient will be created either using just a URI or a URI and JWT authentication information.
func (*GripPubControl) PublishHttpResponse ¶
func (gpc *GripPubControl) PublishHttpResponse(channel string, http_response interface{}, id, prevId string) error
Publish an HTTP response format message to all of the configured PubControlClients with a specified channel, message, and optional ID, previous ID, and callback. Note that the 'http_response' parameter can be provided as either an HttpResponseFormat instance or a string / byte array (in which case an HttpResponseFormat instance will automatically be created and have the 'body' field set to the specified value).
func (*GripPubControl) PublishHttpStream ¶
func (gpc *GripPubControl) PublishHttpStream(channel string, http_stream interface{}, id, prevId string) error
Publish an HTTP stream format message to all of the configured PubControlClients with a specified channel, message, and optional ID, previous ID, and callback. Note that the 'http_stream' parameter can be provided as either an HttpStreamFormat instance or a string / byte array (in which case an HttpStreamFormat instance will automatically be created and have the 'content' field set to the specified value).
type GripPublishError ¶
type GripPublishError struct {
// contains filtered or unexported fields
}
An error object representing an error encountered during publishing.
func (GripPublishError) Error ¶
func (e GripPublishError) Error() string
The function used to retrieve the message associated with a GripPublishError.
type HttpResponseFormat ¶
The HttpResponseFormat struct is the format used to publish messages to HTTP response clients connected to a GRIP proxy.
func (*HttpResponseFormat) Export ¶
func (format *HttpResponseFormat) Export() interface{}
Export the message into the required format and include only the fields that are set. The body is exported as base64 as 'body-bin' (as opposed to 'body') if the value is a buffer.
func (*HttpResponseFormat) Name ¶
func (format *HttpResponseFormat) Name() string
The name used when publishing this format.
type HttpStreamFormat ¶
The HttpStreamFormat struct is the format used to publish messages to HTTP stream clients connected to a GRIP proxy.
func (*HttpStreamFormat) Export ¶
func (format *HttpStreamFormat) Export() interface{}
Exports the message in the required format depending on whether the message content is binary or not, or whether the connection should be closed.
func (*HttpStreamFormat) Name ¶
func (format *HttpStreamFormat) Name() string
The name used when publishing this format.
type Response ¶
The Response struct is used to represent a set of HTTP response data. Populated instances of this struct are serialized to JSON and passed to the GRIP proxy in the body. The GRIP proxy then parses the message and deserialized the JSON into an HTTP response that is passed back to the client.
type WebSocketEvent ¶
The WebSocketEvent struct represents WebSocket event information that is used with the GRIP WebSocket-over-HTTP protocol. It includes information about the type of event as well as an optional content field.
func DecodeWebSocketEvents ¶
func DecodeWebSocketEvents(body string) ([]*WebSocketEvent, error)
Decode the specified HTTP request body into an array of WebSocketEvent instances when using the WebSocket-over-HTTP protocol. A RuntimeError is raised if the format is invalid.
type WebSocketMessageFormat ¶
The WebSocketMessageFormat struct is the format used to publish data to WebSocket clients connected to GRIP proxies.
func (*WebSocketMessageFormat) Export ¶
func (format *WebSocketMessageFormat) Export() interface{}
Exports the message in the required format depending on whether the binary field is set to true or false.
func (*WebSocketMessageFormat) Name ¶
func (format *WebSocketMessageFormat) Name() string
The name used when publishing this format.