Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callbacks ¶
type Callbacks interface { // OnConnecting is called when there is a new incoming connection. // The handler can examine the request and either accept or reject the connection. // To accept: // Return ConnectionResponse with Accept=true. ConnectionCallbacks MUST be set to an // implementation of the ConnectionCallbacks interface to handle the connection. // HTTPStatusCode and HTTPResponseHeader are ignored. // // To reject: // Return ConnectionResponse with Accept=false. HTTPStatusCode MUST be set to // non-zero value to indicate the rejection reason (typically 401, 429 or 503). // HTTPResponseHeader may be optionally set (e.g. "Retry-After: 30"). // ConnectionCallbacks is ignored. OnConnecting(request *http.Request) ConnectionResponse }
type Connection ¶
type Connection interface { // Connection returns the underlying net.Conn Connection() net.Conn // Send a message. Should not be called concurrently for the same Connection instance. // Can be called only for WebSocket connections. Will return an error for plain HTTP // connections. // Blocks until the message is sent. // Should return as soon as possible if the ctx is cancelled. Send(ctx context.Context, message *protobufs.ServerToAgent) error // Disconnect closes the network connection. // Any blocked Read or Write operations will be unblocked and return errors. Disconnect() error }
Connection represents one OpAMP connection. The implementation MUST be a comparable type so that it can be used as a map key.
type ConnectionCallbacks ¶ added in v0.7.0
type ConnectionCallbacks interface { // OnConnected is called when an incoming OpAMP connection is successfully // established after OnConnecting() returns. OnConnected(ctx context.Context, conn Connection) // OnMessage is called when a message is received from the connection. Can happen // only after OnConnected(). Must return a ServerToAgent message that will be sent // as a response to the Agent. // For plain HTTP requests once OnMessage returns and the response is sent // to the Agent the OnConnectionClose message will be called immediately. OnMessage(ctx context.Context, conn Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent // OnConnectionClose is called when the OpAMP connection is closed. OnConnectionClose(conn Connection) }
ConnectionCallbacks receives callbacks for a specific connection. An implementation of this interface MUST be set on the ConnectionResponse returned by the OnConnecting callback if Accept=true. The implementation can be shared by all connections or can be unique for each connection.
type ConnectionResponse ¶
type ConnectionResponse struct { Accept bool HTTPStatusCode int HTTPResponseHeader map[string]string ConnectionCallbacks ConnectionCallbacks }
ConnectionResponse is the return type of the OnConnecting callback.
Click to show internal directories.
Click to hide internal directories.