server

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(logger types.Logger) *server

Types

type CallbacksStruct

type CallbacksStruct struct {
	OnConnectingFunc      func(request *http.Request) types.ConnectionResponse
	OnConnectedFunc       func(conn types.Connection)
	OnMessageFunc         func(conn types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent
	OnConnectionCloseFunc func(conn types.Connection)
}

func (CallbacksStruct) OnConnected

func (c CallbacksStruct) OnConnected(conn types.Connection)

func (CallbacksStruct) OnConnecting

func (c CallbacksStruct) OnConnecting(request *http.Request) types.ConnectionResponse

func (CallbacksStruct) OnConnectionClose

func (c CallbacksStruct) OnConnectionClose(conn types.Connection)

func (CallbacksStruct) OnMessage

type HTTPHandlerFunc

type HTTPHandlerFunc func(http.ResponseWriter, *http.Request)

type OpAMPServer

type OpAMPServer interface {
	// Attach prepares the OpAMP Server to begin handling requests from an existing
	// http.Server. The returned HTTPHandlerFunc should be added as a handler to the
	// desired http.Server by the caller and the http.Server should be started by
	// the caller after that.
	// For example:
	//   handler, _ := Server.Attach()
	//   mux := http.NewServeMux()
	//   mux.HandleFunc("/opamp", handler)
	//   httpSrv := &http.Server{Handler:mux,Addr:"127.0.0.1:4320"}
	//   httpSrv.ListenAndServe()
	Attach(settings Settings) (HTTPHandlerFunc, error)

	// Start an OpAMP Server and begin accepting connections. Starts its own http.Server
	// using provided settings. This should block until the http.Server is ready to
	// accept connections.
	Start(settings StartSettings) error

	// Stop accepting new connections and close all current connections. This should
	// block until all connections are closed.
	Stop(ctx context.Context) error
}

type Settings

type Settings struct {
	// Callbacks that the Server will call after successful Attach/Start.
	Callbacks types.Callbacks
}

type StartSettings

type StartSettings struct {
	Settings

	// ListenEndpoint specifies the endpoint to listen on, e.g. "127.0.0.1:4320"
	ListenEndpoint string

	// ListenPath specifies the URL path on which to accept the OpAMP connections
	// If this is empty string then Start() will use the default "/v1/opamp" path.
	ListenPath string

	// Server's TLS configuration.
	TLSConfig *tls.Config
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL