transports

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownMessageKind = fmt.Errorf("unknown message kind")

Functions

This section is empty.

Types

type Host

type Host interface {
	// Listen listens for incoming requests.
	// This function never returns unless an error occurs, or Close is called.
	Listen(ctx context.Context) error
	// Close closes the host.
	Close(ctx context.Context) error
}

Host is the interface implemented by types that can host a Bastion server.

func NewHost

func NewHost(address string, messageProcessor MessageProcessor) Host

NewHost creates a new Host listening on the given address.

type MessageHandler

type MessageHandler interface {
	// Register registers the given application.
	Register(ctx context.Context, message messages.RegistrationMessage) (*messages.RegistrationResponse, error)
	// Deregister removes the registration of the application with the given name.
	Deregister(ctx context.Context, message messages.DeregistrationMessage) (*messages.DeregistrationResponse, error)
	// ForwardRequest forwards the given request to the application specified in the request.
	ForwardRequest(ctx context.Context, message messages.ForwardRequestMessage) (*messages.ForwardRequestResponse, error)
}

MessageHandler allows the handling of incoming valid Bastion requests.

type MessageProcessor

type MessageProcessor interface {
	// ProcessMessage processes the given message and returns a response.
	ProcessMessage(ctx context.Context, message *funcie.Message) (*funcie.Response, error)
}

MessageProcessor dispatches messages to the appropriate handler.

func NewCachingMessageProcessor

func NewCachingMessageProcessor(underlyingProcessor MessageProcessor) MessageProcessor

NewCachingMessageProcessor creates a new caching MessageProcessor, forwarding requests to the underlying processor. If the underlying processor returns ErrNoConsumerFound, that result is cached for a minute or until registered.

func NewMessageProcessor

func NewMessageProcessor(handler MessageHandler) MessageProcessor

NewMessageProcessor creates a new MessageProcessor.

Directories

Path Synopsis
ws

Jump to

Keyboard shortcuts

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