Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter interface { // The name of the format which should return a string. Examples // include 'json-object' and 'http-response' Name() string // The export method which should return a format-specific hash // containing the required format-specific data. Export() interface{} }
The Format interface is used for all publishing formats that are wrapped in the Item struct. Examples of format implementations include JsonObjectFormat and HttpStreamFormat.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
The Item struct is a container used to contain one or more format implementation instances where each implementation instance is of a different type of format. An Item instance may not contain multiple implementations of the same type of format. An Item instance is then serialized into a hash that is used for publishing to clients.
func NewItem ¶
Initialize this struct with either a single Format implementation instance or an array of Format implementation instances. Optionally specify an ID and/or previous ID to be sent as part of the message published to the client.
type ItemFormatError ¶
type ItemFormatError struct {
// contains filtered or unexported fields
}
An error struct used to represent an error related to item formats.
func (ItemFormatError) Error ¶
func (e ItemFormatError) Error() string
This function returns the message associated with the ItemFormatError error struct.
type PubControl ¶
type PubControl struct {
// contains filtered or unexported fields
}
The PubControl struct allows a consumer to manage a set of publishing endpoints and to publish to all of those endpoints via a single publish method call. A PubControl instance can be configured either using a hash or array of hashes containing configuration information or by manually adding PubControlClient instances.
func NewPubControl ¶
func NewPubControl(config []map[string]interface{}) *PubControl
Initialize with or without a configuration. A configuration can be applied after initialization via the apply_config method.
func (*PubControl) AddClient ¶
func (pc *PubControl) AddClient(pcc *PubControlClient)
Add the specified PubControlClient instance.
func (*PubControl) ApplyConfig ¶
func (pc *PubControl) ApplyConfig(config []map[string]interface{})
Apply the specified configuration to this PubControl 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 (*PubControl) Publish ¶
func (pc *PubControl) Publish(channel string, item *Item) error
The publish method for publishing the specified item to the specified channel on the configured endpoints. Different endpoints are published to in parallel, with this function waiting for them to finish. Any errors (including panics) are aggregated into one error.
func (*PubControl) RemoveAllClients ¶
func (pc *PubControl) RemoveAllClients()
Remove all of the configured PubControlClient instances.
type PubControlClient ¶
type PubControlClient struct {
// contains filtered or unexported fields
}
The PubControlClient struct allows consumers to publish to an endpoint of their choice. The consumer wraps a Format struct instance in an Item struct instance and passes that to the publish method. The publish method has an optional callback parameter that is called after the publishing is complete to notify the consumer of the result.
func NewPubControlClient ¶
func NewPubControlClient(uri string) *PubControlClient
Initialize this struct with a URL representing the publishing endpoint.
func (*PubControlClient) Publish ¶
func (pcc *PubControlClient) Publish(channel string, item *Item) error
The publish method for publishing the specified item to the specified channel on the configured endpoint.
func (*PubControlClient) SetAuthBasic ¶
func (pcc *PubControlClient) SetAuthBasic(username, password string)
Call this method and pass a username and password to use basic authentication with the configured endpoint.
func (*PubControlClient) SetAuthBearer ¶
func (pcc *PubControlClient) SetAuthBearer(key string)
func (*PubControlClient) SetAuthJwt ¶
func (pcc *PubControlClient) SetAuthJwt(claim map[string]interface{}, key []byte)
Call this method and pass a claim and key to use JWT authentication with the configured endpoint.
type PublishError ¶
type PublishError struct {
// contains filtered or unexported fields
}
An error struct used to represent an error encountered during publishing.
func (PublishError) Error ¶
func (e PublishError) Error() string
This function returns the message associated with the Publish error struct.