{"modulePath":"github.com/dispatchrun/dispatch-go","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dispatch\n\n## Variables\n\n```go\nvar (\n\t// ErrTimeout indicates an operation failed due to a timeout.\n\tErrTimeout error = dispatchproto.StatusError(dispatchproto.TimeoutStatus)\n\n\t// ErrTimeout indicates an operation failed due to throttling.\n\tErrThrottled error = dispatchproto.StatusError(dispatchproto.ThrottledStatus)\n\n\t// ErrInvalidArgument indicates an operation failed due to an invalid argument.\n\tErrInvalidArgument error = dispatchproto.StatusError(dispatchproto.InvalidArgumentStatus)\n\n\t// ErrInvalidResponse indicates an operation failed due to an invalid response.\n\tErrInvalidResponse error = dispatchproto.StatusError(dispatchproto.InvalidResponseStatus)\n\n\t// ErrTemporary indicates an operation failed with a temporary error.\n\tErrTemporary error = dispatchproto.StatusError(dispatchproto.TemporaryErrorStatus)\n\n\t// ErrPermanent indicates an operation failed with a permanent error.\n\tErrPermanent error = dispatchproto.StatusError(dispatchproto.PermanentErrorStatus)\n\n\t// ErrIncompatibleStatus indicates that a function's serialized state is incompatible.\n\tErrIncompatibleState error = dispatchproto.StatusError(dispatchproto.IncompatibleStateStatus)\n\n\t// ErrDNS indicates an operation failed with a DNS error.\n\tErrDNS error = dispatchproto.StatusError(dispatchproto.DNSErrorStatus)\n\n\t// ErrTCP indicates an operation failed with a TCP error.\n\tErrTCP error = dispatchproto.StatusError(dispatchproto.TCPErrorStatus)\n\n\t// ErrTLS indicates an operation failed with a TLS error.\n\tErrTLS error = dispatchproto.StatusError(dispatchproto.TLSErrorStatus)\n\n\t// ErrHTTP indicates an operation failed with a HTTP error.\n\tErrHTTP error = dispatchproto.StatusError(dispatchproto.HTTPErrorStatus)\n\n\t// ErrUnauthenticated indicates an operation failed or was not attempted\n\t// because the caller did not authenticate correctly.\n\tErrUnauthenticated error = dispatchproto.StatusError(dispatchproto.UnauthenticatedStatus)\n\n\t// ErrPermissionDenied indicates an operation failed or was not attempted\n\t// because the caller did not have permission.\n\tErrPermissionDenied error = dispatchproto.StatusError(dispatchproto.PermissionDeniedStatus)\n\n\t// ErrNotFound indicates an operation failed because a resource could not be found.\n\tErrNotFound error = dispatchproto.StatusError(dispatchproto.NotFoundStatus)\n)\n```\n\n## Types\n\n```go\ntype AnyFunction interface {\n\tOption\n\n\tRegister(*Dispatch) (string, dispatchproto.Function)\n}\n```\nAnyFunction is a Function\\[I, O] instance.\n\n```go\ntype Dispatch struct {\n\t// contains filtered or unexported fields\n}\n```\nDispatch is a Dispatch endpoint.\n\n```go\nfunc New(opts ...Option) (*Dispatch, error)\n```\nNew creates a Dispatch endpoint.\n\n```go\nfunc (d *Dispatch) Client() (*dispatchclient.Client, error)\n```\nClient returns the Client attached to this endpoint.\n\n```go\nfunc (d *Dispatch) Handler() (string, http.Handler)\n```\nHandler returns an HTTP handler for Dispatch, along with the path that the handler should be registered at.\n\n```go\nfunc (d *Dispatch) ListenAndServe() error\n```\nListenAndServe serves the Dispatch endpoint.\n\n```go\nfunc (d *Dispatch) Register(fn AnyFunction)\n```\nRegister registers a function.\n\n```go\nfunc (d *Dispatch) RegisterPrimitive(name string, fn dispatchproto.Function)\n```\nRegisterPrimitive registers a primitive function.\n\n```go\nfunc (d *Dispatch) URL() string\n```\nURL is the URL of the Dispatch endpoint.\n\n```go\ntype Function[I, O any] struct {\n\t// contains filtered or unexported fields\n}\n```\nFunction is a Dispatch Function.\n\n```go\nfunc Func[I, O any](name string, fn func(context.Context, I) (O, error)) *Function[I, O]\n```\nFunc creates a Function.\n\n```go\nfunc (f *Function[I, O]) Await(input I, opts ...dispatchproto.CallOption) (O, error)\n```\nAwait calls the function and awaits a result.\n\nAwait should only be called within a Dispatch Function (created via Func).\n\n```go\nfunc (f *Function[I, O]) BuildCall(input I, opts ...dispatchproto.CallOption) (dispatchproto.Call, error)\n```\nBuildCall creates (but does not dispatch) a Call for the function.\n\n```go\nfunc (f *Function[I, O]) Dispatch(ctx context.Context, input I, opts ...dispatchproto.CallOption) (dispatchproto.ID, error)\n```\nDispatch dispatches a Call to the function.\n\n```go\nfunc (f *Function[I, O]) Gather(inputs []I, opts ...dispatchproto.CallOption) ([]O, error)\n```\nGather makes many concurrent calls to the function and awaits the results.\n\nGather should only be called within a Dispatch Function (created via Func).\n\n```go\nfunc (f *Function[I, O]) Name() string\n```\nName is the name of the function.\n\n```go\nfunc (f *Function[I, O]) Register(endpoint *Dispatch) (string, dispatchproto.Function)\n```\nRegister is called when the function is registered on a Dispatch endpoint.\n\n```go\ntype Option interface {\n\t// contains filtered or unexported methods\n}\n```\nOption configures a Dispatch endpoint.\n\n```go\nfunc Client(client *dispatchclient.Client) Option\n```\nClient sets the client to use when dispatching calls from functions registered on the endpoint.\n\nBy 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.\n\n```go\nfunc EndpointUrl(endpointUrl string) Option\n```\nEndpointUrl sets the URL of the Dispatch endpoint.\n\nIt defaults to the value of the DISPATCH\\_ENDPOINT\\_URL environment variable.\n\n```go\nfunc Env(env ...string) Option\n```\nEnv sets the environment variables that a Dispatch endpoint parses its default configuration from.\n\nIt defaults to os.Environ().\n\n```go\nfunc ServeAddress(addr string) Option\n```\nServeAddress sets the address that the Dispatch endpoint is served on (see Dispatch.Serve).\n\nNote that this is not the same as the endpoint URL, which is the URL that this Dispatch endpoint is publicly accessible from.\n\nIt 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.\n\n```go\nfunc VerificationKey(verificationKey string) Option\n```\nVerificationKey sets the verification key to use when verifying Dispatch request signatures.\n\nThe key should be a PEM or base64-encoded ed25519 public key.\n\nIt defaults to the value of the DISPATCH\\_VERIFICATION\\_KEY environment variable value.\n\nIf a verification key is not provided, request signatures will not be validated.\n\n","path":"github.com/dispatchrun/dispatch-go","name":"dispatch","synopsis":"","isRedistributable":true}
