agent

package
v0.0.0-...-af321b4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadHijacked  = errors.New("read hijacked, structured access not available")
	ErrWriteHijacked = errors.New("write hijacked, structured access not available")
)
View Source
var ErrProtocolError = errors.New("protocol error detected")

Functions

This section is empty.

Types

type Agent

type Agent struct {
	L hclog.Logger

	LocalAddr string
	Token     string
	Labels    []string

	// RootCAs are the RootCAs to trust for connections to the hubs. If this
	// is not set, the defaults are used.
	RootCAs *x509.CertPool
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(L hclog.Logger) (*Agent, error)

func (*Agent) AddService

func (a *Agent) AddService(serv *Service) (*pb.ULID, error)

func (*Agent) Connect

func (a *Agent) Connect(labels *pb.LabelSet) (net.Conn, error)

func (*Agent) Nego

func (a *Agent) Nego(ctx context.Context, L hclog.Logger, conn net.Conn, hubCfg discovery.HubConfig, status chan hubStatus) error

func (*Agent) RPCClient

func (a *Agent) RPCClient() (*wire.RPCClient, error)

func (*Agent) Run

func (*Agent) Start

func (*Agent) Wait

func (a *Agent) Wait(ctx context.Context) error

type Conn

type Conn struct {
	io.Reader
	io.WriteCloser

	Stream *yamux.Stream
	Labels *pb.LabelSet
	// contains filtered or unexported fields
}

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

type Label

type Label struct {
	Name, Value string
}

func ParseLabel

func ParseLabel(s string) Label

func (*Label) String

func (l *Label) String() string

type Service

type Service struct {
	// The identifier for the service, populated when the service is added.
	Id *pb.ULID

	// The type identifer for the service. These identifiers are used by other
	// agents and hubs to find services of a particular type.
	Type string

	// The unique identifiers for the service. The labels can be anything and are
	// used by agents and hubs to locate services.
	Labels *pb.LabelSet

	// An additional metadata to attach to the service. Peer agents will be able to
	// see this metadata.
	Metadata map[string]string

	// The handler to invoke when the service is called.
	Handler ServiceHandler
}

Describes a service that an agent is advertising. When a client connects to the service, the Handler will be invoked.

type ServiceContext

type ServiceContext interface {
	wire.Context

	ProtocolId() string

	// Returns a reader that reads data on the connection
	BodyReader() io.Reader

	// Returns a writer than writes data on the connection
	BodyWriter() io.Writer
}

type ServiceHandler

type ServiceHandler interface {
	HandleRequest(ctx context.Context, L hclog.Logger, sctx ServiceContext) error
}

The implementation of a service. req is the request sent initially. fr and fw are used to read and write data from the client.

func EchoHandler

func EchoHandler() ServiceHandler

func HTTPHandler

func HTTPHandler(url string) ServiceHandler

func TCPHandler

func TCPHandler(addr string) ServiceHandler

Jump to

Keyboard shortcuts

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