dispatchserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointClient

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

EndpointClient is a client for a Dispatch endpoint.

Note that this is not the same as dispatch.Client, which is a client for the Dispatch API. The client here is used by a Dispatch server to interact with the functions provided by a Dispatch endpoint.

func NewEndpointClient

func NewEndpointClient(endpointUrl string, opts ...EndpointClientOption) (*EndpointClient, error)

NewEndpointClient creates an EndpointClient.

func (*EndpointClient) Run

Run sends a RunRequest and returns a RunResponse.

type EndpointClientOption

type EndpointClientOption func(*EndpointClient)

EndpointClientOption configures an EndpointClient.

func ClientOptions

func ClientOptions(opts ...connect.ClientOption) EndpointClientOption

ClientOptions adds options for the underlying connect (gRPC) client.

func HTTPClient

func HTTPClient(client connect.HTTPClient) EndpointClientOption

HTTPClient sets the HTTP client to use when making requests to the endpoint.

By default http.DefaultClient is used.

func RequestHeaders

func RequestHeaders(header http.Header) EndpointClientOption

RequestHeaders sets headers on the request to the endpoint.

func SigningKey

func SigningKey(signingKey ed25519.PrivateKey) EndpointClientOption

SigningKey sets the signing key to use when signing requests bound for the endpoint.

By default the EndpointClient does not sign requests to the endpoint.

type Handler

type Handler interface {
	Handle(ctx context.Context, header http.Header, calls []dispatchproto.Call) ([]dispatchproto.ID, error)
}

Handler handles requests to a Dispatch API server.

func HandlerFunc

func HandlerFunc(fn func(context.Context, http.Header, []dispatchproto.Call) ([]dispatchproto.ID, error)) Handler

HandlerFunc creates a Handler from a function.

type Server

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

Server is a Dispatch API server.

func New

func New(handler Handler, opts ...connect.HandlerOption) (*Server, error)

New creates a Server.

func (*Server) Handler

func (s *Server) Handler() (string, http.Handler)

Handler returns an HTTP handler for the Dispatch API server, along with the path that the handler should be registered at.

func (*Server) Serve

func (s *Server) Serve(addr string) error

Serve serves the Server on the specified address.

Jump to

Keyboard shortcuts

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