Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct { // A channel for writing Responses, specifically Batch and Point responses. Responses chan<- *udf.Response // The handler for requests. Handler Handler // contains filtered or unexported fields }
Go implementation of a Kapacitor UDF agent. This agent is responsible for reading and writing messages over STDIN and STDOUT.
The Agent requires a Handler object in order to fulfill requests.
type Handler ¶
type Handler interface { // Return the InfoResponse. Describing the properties of this Handler Info() (*udf.InfoResponse, error) // Initialize the Handler with the provided options. Init(*udf.InitRequest) (*udf.InitResponse, error) // Create a snapshot of the running state of the handler. Snaphost() (*udf.SnapshotResponse, error) // Restore a previous snapshot. Restore(*udf.RestoreRequest) (*udf.RestoreResponse, error) // A batch has begun. BeginBatch(*udf.BeginBatch) error // A point has arrived. Point(*udf.Point) error // The batch is complete. EndBatch(*udf.EndBatch) error // Gracefully stop the Handler. // No other methods will be called. Stop() }
The Agent calls the appropriate methods on the Handler as it receives requests over STDIN.
Returning an error from any method will cause the Agent to stop and an ErrorResponse to be sent. Some *Response objects (like SnapshotResponse) allow for returning their own error within the object itself. These types of errors will not stop the Agent and Kapacitor will deal with them appropriately.
The Handler is called from a single goroutine, meaning methods will not be called concurrently.
To write Points/Batches back to the Agent/Kapacitor use the Agent.Responses channel.