mux

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloserStream

type CloserStream interface {
	IncomingMessages() (<-chan rpc.IncomingMessage, error)
	WriteMessage(body []byte, bodyType transport.MessageBodyType) error
	CloseWithError(err error) error
}

type Handler

type Handler interface {
	// Procedure returns a specification of the procedure handled by this
	// handler. Mux routes requests bases on this value.
	Procedure() rpc.Procedure

	// Handle should perform actions requested by the provided request and
	// return responses using the provided response writer. The handler returns
	// errors to make the flow of control within the handler easier to follow.
	// If an error is returned it will be sent over the RPC connection,
	// otherwise the connection is terminated cleanly. Handle is executed in a
	// separate goroutine and can therefore block and process the request for as
	// long as it needs.
	Handle(ctx context.Context, s Stream, req *rpc.Request) error
}

type Mux

type Mux struct {
	// contains filtered or unexported fields
}

func NewMux

func NewMux(
	logger logging.Logger,
	handlers []Handler,
	synchronousHandlers []SynchronousHandler,
) (*Mux, error)

func (Mux) HandleRequest

func (m Mux) HandleRequest(ctx context.Context, s CloserStream, req *rpc.Request)

type Stream

type Stream interface {
	IncomingMessages() (<-chan rpc.IncomingMessage, error)
	WriteMessage(body []byte, bodyType transport.MessageBodyType) error
}

type SynchronousHandler

type SynchronousHandler interface {
	// Procedure returns a specification of the procedure handled by this
	// handler. Mux routes requests bases on this value.
	Procedure() rpc.Procedure

	// Handle should perform actions requested by the provided request and
	// return responses using the provided response writer. Handler must close
	// the response writer. Handle isn't processed in a separate goroutine and
	// should avoid blocking. This is useful when there is a need to offload the
	// work to a set of workers without spawning extra goroutines to limit
	// pressure on the scheduler and garbage collector. This is useful in the
	// case of create history stream requests which are performed in very large
	// amounts when connecting to large pubs.
	Handle(ctx context.Context, s CloserStream, req *rpc.Request)
}

Jump to

Keyboard shortcuts

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