Documentation ¶
Index ¶
- Variables
- type AnyFunction
- type Dispatch
- func (d *Dispatch) Client() (*dispatchclient.Client, error)
- func (d *Dispatch) Handler() (string, http.Handler)
- func (d *Dispatch) ListenAndServe() error
- func (d *Dispatch) Register(fn AnyFunction)
- func (d *Dispatch) RegisterPrimitive(name string, fn dispatchproto.Function)
- func (d *Dispatch) URL() string
- type Function
- func (f *Function[I, O]) Await(input I, opts ...dispatchproto.CallOption) (O, error)
- func (f *Function[I, O]) BuildCall(input I, opts ...dispatchproto.CallOption) (dispatchproto.Call, error)
- func (f *Function[I, O]) Dispatch(ctx context.Context, input I, opts ...dispatchproto.CallOption) (dispatchproto.ID, error)
- func (f *Function[I, O]) Gather(inputs []I, opts ...dispatchproto.CallOption) ([]O, error)
- func (f *Function[I, O]) Name() string
- func (f *Function[I, O]) Register(endpoint *Dispatch) (string, dispatchproto.Function)
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTimeout indicates an operation failed due to a timeout. ErrTimeout error = dispatchproto.StatusError(dispatchproto.TimeoutStatus) // ErrTimeout indicates an operation failed due to throttling. ErrThrottled error = dispatchproto.StatusError(dispatchproto.ThrottledStatus) // ErrInvalidArgument indicates an operation failed due to an invalid argument. ErrInvalidArgument error = dispatchproto.StatusError(dispatchproto.InvalidArgumentStatus) // ErrInvalidResponse indicates an operation failed due to an invalid response. ErrInvalidResponse error = dispatchproto.StatusError(dispatchproto.InvalidResponseStatus) // ErrTemporary indicates an operation failed with a temporary error. ErrTemporary error = dispatchproto.StatusError(dispatchproto.TemporaryErrorStatus) // ErrPermanent indicates an operation failed with a permanent error. ErrPermanent error = dispatchproto.StatusError(dispatchproto.PermanentErrorStatus) // ErrIncompatibleStatus indicates that a function's serialized state is incompatible. ErrIncompatibleState error = dispatchproto.StatusError(dispatchproto.IncompatibleStateStatus) // ErrDNS indicates an operation failed with a DNS error. ErrDNS error = dispatchproto.StatusError(dispatchproto.DNSErrorStatus) // ErrTCP indicates an operation failed with a TCP error. ErrTCP error = dispatchproto.StatusError(dispatchproto.TCPErrorStatus) // ErrTLS indicates an operation failed with a TLS error. ErrTLS error = dispatchproto.StatusError(dispatchproto.TLSErrorStatus) // ErrHTTP indicates an operation failed with a HTTP error. ErrHTTP error = dispatchproto.StatusError(dispatchproto.HTTPErrorStatus) // ErrUnauthenticated indicates an operation failed or was not attempted // because the caller did not authenticate correctly. ErrUnauthenticated error = dispatchproto.StatusError(dispatchproto.UnauthenticatedStatus) // ErrPermissionDenied indicates an operation failed or was not attempted // because the caller did not have permission. ErrPermissionDenied error = dispatchproto.StatusError(dispatchproto.PermissionDeniedStatus) // ErrNotFound indicates an operation failed because a resource could not be found. ErrNotFound error = dispatchproto.StatusError(dispatchproto.NotFoundStatus) )
Functions ¶
This section is empty.
Types ¶
type AnyFunction ¶
type AnyFunction interface { Option Register(*Dispatch) (string, dispatchproto.Function) }
AnyFunction is a Function[I, O] instance.
type Dispatch ¶
type Dispatch struct {
// contains filtered or unexported fields
}
Dispatch is a Dispatch endpoint.
func (*Dispatch) Client ¶
func (d *Dispatch) Client() (*dispatchclient.Client, error)
Client returns the Client attached to this endpoint.
func (*Dispatch) Handler ¶
Handler returns an HTTP handler for Dispatch, along with the path that the handler should be registered at.
func (*Dispatch) ListenAndServe ¶
ListenAndServe serves the Dispatch endpoint.
func (*Dispatch) Register ¶
func (d *Dispatch) Register(fn AnyFunction)
Register registers a function.
func (*Dispatch) RegisterPrimitive ¶
func (d *Dispatch) RegisterPrimitive(name string, fn dispatchproto.Function)
RegisterPrimitive registers a primitive function.
type Function ¶
type Function[I, O any] struct { // contains filtered or unexported fields }
Function is a Dispatch Function.
func (*Function[I, O]) Await ¶
func (f *Function[I, O]) Await(input I, opts ...dispatchproto.CallOption) (O, error)
Await calls the function and awaits a result.
Await should only be called within a Dispatch Function (created via Func).
func (*Function[I, O]) BuildCall ¶
func (f *Function[I, O]) BuildCall(input I, opts ...dispatchproto.CallOption) (dispatchproto.Call, error)
BuildCall creates (but does not dispatch) a Call for the function.
func (*Function[I, O]) Dispatch ¶
func (f *Function[I, O]) Dispatch(ctx context.Context, input I, opts ...dispatchproto.CallOption) (dispatchproto.ID, error)
Dispatch dispatches a Call to the function.
func (*Function[I, O]) Gather ¶
func (f *Function[I, O]) Gather(inputs []I, opts ...dispatchproto.CallOption) ([]O, error)
Gather makes many concurrent calls to the function and awaits the results.
Gather should only be called within a Dispatch Function (created via Func).
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Dispatch endpoint.
func Client ¶
func Client(client *dispatchclient.Client) Option
Client sets the client to use when dispatching calls from functions registered on the endpoint.
By default the Dispatch endpoint will attempt to construct a dispatchclient.Client instance using the DISPATCH_API_KEY and optional DISPATCH_API_URL environment variables. If more control is required over client configuration, the custom client instance can be registered here and used instead.
func EndpointUrl ¶
EndpointUrl sets the URL of the Dispatch endpoint.
It defaults to the value of the DISPATCH_ENDPOINT_URL environment variable.
func Env ¶
Env sets the environment variables that a Dispatch endpoint parses its default configuration from.
It defaults to os.Environ().
func ServeAddress ¶
ServeAddress sets the address that the Dispatch endpoint is served on (see Dispatch.Serve).
Note that this is not the same as the endpoint URL, which is the URL that this Dispatch endpoint is publicly accessible from.
It defaults to the value of the DISPATCH_ENDPOINT_ADDR environment variable, which is automatically set by the Dispatch CLI. If this is unset, it defaults to 127.0.0.1:8000.
func VerificationKey ¶
VerificationKey sets the verification key to use when verifying Dispatch request signatures.
The key should be a PEM or base64-encoded ed25519 public key.
It defaults to the value of the DISPATCH_VERIFICATION_KEY environment variable value.
If a verification key is not provided, request signatures will not be validated.