adminport

package
v0.0.0-...-b800c40 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package adminport provides admin-port client/server library that can be used by system components to talk with each other. It is based on request/response protocol, by default used http for transport and protobuf, JSON for payload. Admin port can typically be used for collecting statistics, administering and managing cluster.

Index

Constants

This section is empty.

Variables

View Source
var ErrorDecodeRequest = errors.New("adminport.decodeRequest")

ErrorDecodeRequest

View Source
var ErrorDecodeResponse = errors.New("adminport.decodeResponse")

ErrorDecodeResponse

View Source
var ErrorEncodeResponse = errors.New("adminport.encodeResponse")

ErrorEncodeResponse

View Source
var ErrorInternal = errors.New("adminport.internal")

ErrorInternal

View Source
var ErrorMessageUnknown = errors.New("adminport.unknownMessage")

ErrorMessageUnknown

View Source
var ErrorPathNotFound = errors.New("adminport.pathNotFound")

ErrorPathNotFound

View Source
var ErrorRegisteringRequest = errors.New("adminport.registeringRequest")

ErrorRegisteringRequest

View Source
var ErrorRequest = errors.New("adminport.request")

ErrorRequest

View Source
var ErrorServerStarted = errors.New("adminport.serverStarted")

ErrorServerStarted

Functions

This section is empty.

Types

type Client

type Client interface {
	// Request shall post a `request` message to server, wait for response and
	// decode response into `response` argument. `response` argument must be a
	// pointer to an object implementing `MessageMarshaller` interface.
	Request(request, response MessageMarshaller) (err error)
}

Client API for a remote adminport

func NewHTTPClient

func NewHTTPClient(listenAddr, urlPrefix string) Client

NewHTTPClient returns a new instance of Client over HTTP.

type MessageMarshaller

type MessageMarshaller interface {
	// Name of the message
	Name() string

	// Content type to be used by the transport layer.
	ContentType() string

	// Encode function shall marshal message to byte array.
	Encode() (data []byte, err error)

	// Decode function shall unmarshal byte array back to message.
	Decode(data []byte) (err error)
}

MessageMarshaller APIs message format.

type Request

type Request interface {
	// Get message from request packet.
	GetMessage() MessageMarshaller

	// Send a response message back to the client.
	Send(MessageMarshaller) error

	// Send error back to the client.
	SendError(error) error
}

Request API for server application to handle incoming request.

type Server

type Server interface {
	// Register a request message that shall be supported by adminport-server
	Register(msg MessageMarshaller) error

	// RegisterHandler a request message that shall be supported by
	// adminport-server
	RegisterHTTPHandler(pattern string, handler interface{}) error

	// Unregister a previously registered request message
	Unregister(msg MessageMarshaller) error

	// Start server routine and wait for incoming request, Register() and
	// Unregister() APIs cannot be called after starting the server.
	Start() error

	// GetStatistics returns server statistics.
	GetStatistics() c.Statistics

	// Stop server routine.
	Stop()
}

Server API for adminport

func NewHTTPServer

func NewHTTPServer(config c.Config, reqch chan<- Request) Server

NewHTTPServer creates an instance of admin-server. Start() will actually start the server.

Jump to

Keyboard shortcuts

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