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 a socket.
The Agent requires a Handler object in order to fulfill requests.
func New ¶
func New(in io.ReadCloser, out io.WriteCloser) *Agent
Create a new Agent is the provided in/out objects. To create an Agent that reads from STDIN/STDOUT of the process use New(os.Stdin, os.Stdout)
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. Snapshot() (*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 a socket.
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.
type Server ¶ added in v0.13.0
type Server struct {
// contains filtered or unexported fields
}
A server accepts connections on a listener and spawns new Agents for each connection.
func (*Server) StopOnSignals ¶ added in v0.13.0
Register a signal handler to stop the Server for the given signals.