Documentation ¶
Overview ¶
Package client is a low level client to the Choria network
It is capable of publishing any raw data contained in a choria Message to the network and supports federations, SRV records and everything else
This client has no awareness of the RPC system or anything like that, it's the lowest level raw access to the network from which higher order abstractions can be made like those that the RPC libraries require or discovery systems
Index ¶
- func AgentFilter(f ...string) filter.Filter
- func ClassFilter(f ...string) filter.Filter
- func CombinedFilter(f ...string) filter.Filter
- func CompoundFilter(f ...string) filter.Filter
- func FactFilter(f ...string) filter.Filter
- func IdentityFilter(f ...string) filter.Filter
- func NewFilter(fs ...filter.Filter) (f *protocol.Filter, err error)
- func ParseFactFilterString(f string) (pf *protocol.FactFilter, err error)
- type ChoriaFramework
- type Client
- type Connector
- type Handler
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentFilter ¶
AgentFilter processes a series of strings as agent filters
func ClassFilter ¶
ClassFilter processes a series of strings as agent filters
func CombinedFilter ¶
CombinedFilter processes a series of strings as combined fact and class filters
func CompoundFilter ¶
CompoundFilter processes a series of strings as compound filters
func FactFilter ¶
FactFilter processes a series of strings as fact filters
func IdentityFilter ¶
IdentityFilter processes a series of strings as identity filters
func ParseFactFilterString ¶
func ParseFactFilterString(f string) (pf *protocol.FactFilter, err error)
ParseFactFilterString parses a fact filter string as typically typed on the CLI
Types ¶
type ChoriaFramework ¶
type ChoriaFramework interface { Configuration() *config.Config Logger(string) *logrus.Entry NewRequestID() (string, error) Certname() string MiddlewareServers() (srvcache.Servers, error) NewConnector(ctx context.Context, servers func() (srvcache.Servers, error), name string, logger *logrus.Entry) (conn choria.Connector, err error) NewMessage(payload string, agent string, collective string, msgType string, request *choria.Message) (msg *choria.Message, err error) NewTransportFromJSON(data string) (message protocol.TransportMessage, err error) }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a basic low level high performance Choria client
func New ¶
func New(fw ChoriaFramework, opts ...Option) (*Client, error)
New creates a Choria client
func (*Client) Request ¶
Request performs a request
handler will be called for every reply that gets received, when handler is nil this means no receiving listeners, workers or subscriptions are setup effectively the message is published and forgotten
This fire and forget approach is useful when one do not care for the replies or when the reply to target in the message is set to a custom reply target meaning the client will anyway never receive the replies
type Connector ¶
type Connector interface { QueueSubscribe(ctx context.Context, name string, subject string, group string, output chan *choria.ConnectorMessage) error Publish(msg *choria.Message) error }
Connector is a connection to the choria network
type Handler ¶
type Handler func(ctx context.Context, m *choria.ConnectorMessage)
Handler handles individual messages
type Option ¶
type Option func(c *Client)
Option configures the broadcast discovery method
func Connection ¶
Connection Supplies a custom connection, when this is supplied this is the only connection that will be used for the duration of this client for all publishes and replies
This might have severe performance impact and might even cause message loss, my suggestion would be to use this only when doing batch style messages where you expect small amounts of replies
func Name ¶
Name sets a NATS connection name to use, without this random names will be made.
This setting is important if you make a daemon that makes many long client connections as each client connection makes Prometheus stats based on the name and you'll be leaking many stats over time
func OnPublishFinish ¶
func OnPublishFinish(f func()) Option
OnPublishFinish function to call synchronously when publishing ends
func OnPublishStart ¶
func OnPublishStart(f func()) Option
OnPublishStart function to call synchronously when publishing starts