Documentation
¶
Index ¶
- Constants
- func NewExecutionFailureError(cmd ucan.Command) error
- func NewHandlerExecutionError(cmd ucan.Command, cause error) error
- func NewInvalidAudienceError(expected did.DID, actual did.DID) error
- type ExecRequest
- type ExecResponse
- func (r *ExecResponse) Metadata() ucan.Container
- func (r *ExecResponse) Receipt() ucan.Receipt
- func (r *ExecResponse) SetFailure(x error) error
- func (r *ExecResponse) SetIssuer(issuer ucan.Issuer) error
- func (r *ExecResponse) SetMetadata(meta ucan.Container) error
- func (r *ExecResponse) SetReceipt(receipt ucan.Receipt) error
- func (r *ExecResponse) SetSuccess(ok cbg.CBORMarshaler) error
- type Executor
- type HandlerFunc
- type Request
- type RequestOption
- type Response
- type ResponseOption
- func WithFailure(x error) ResponseOption
- func WithIssuer(issuer ucan.Issuer) ResponseOption
- func WithMetadata(m ucan.Container) ResponseOption
- func WithReceipt(receipt ucan.Receipt) ResponseOption
- func WithReceiptExpiration(exp ucan.UnixTimestamp) ResponseOption
- func WithReceiptTimestamp(enabled bool) ResponseOption
- func WithSuccess(o cbg.CBORMarshaler) ResponseOption
Constants ¶
const ExecutionFailureErrorName = "ExecutionFailure"
const HandlerExecutionErrorName = "HandlerExecutionError"
const InvalidAudienceErrorName = "InvalidAudience"
Variables ¶
This section is empty.
Functions ¶
func NewExecutionFailureError ¶
NewExecutionFailureError is the failure a receipt carries when executing the invocation panicked, in the handler or in validation code such as a DID resolver or verifier factory. The receipt says only that execution failed; the panic value and the fact that it was a panic stay on the server.
Types ¶
type ExecRequest ¶
type ExecRequest struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest(ctx context.Context, inv ucan.Invocation, options ...RequestOption) *ExecRequest
func (*ExecRequest) Context ¶
func (r *ExecRequest) Context() context.Context
func (*ExecRequest) Invocation ¶
func (r *ExecRequest) Invocation() ucan.Invocation
func (*ExecRequest) Metadata ¶
func (r *ExecRequest) Metadata() ucan.Container
type ExecResponse ¶
type ExecResponse struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(task cid.Cid, options ...ResponseOption) (*ExecResponse, error)
NewResponse creates a new response object, representing the result of executing a task.
func (*ExecResponse) Metadata ¶
func (r *ExecResponse) Metadata() ucan.Container
func (*ExecResponse) Receipt ¶
func (r *ExecResponse) Receipt() ucan.Receipt
func (*ExecResponse) SetFailure ¶
func (r *ExecResponse) SetFailure(x error) error
func (*ExecResponse) SetMetadata ¶
func (r *ExecResponse) SetMetadata(meta ucan.Container) error
func (*ExecResponse) SetReceipt ¶
func (r *ExecResponse) SetReceipt(receipt ucan.Receipt) error
func (*ExecResponse) SetSuccess ¶
func (r *ExecResponse) SetSuccess(ok cbg.CBORMarshaler) error
type Executor ¶
Executor executes UCAN invocations. In order to execute an invocation, proof chains must be validated and delegation policies matched. Hence a UCAN executor is responsible for both validation and execution of invocations.
type HandlerFunc ¶
HandlerFunc is a function that can handle a specific UCAN invocation.
A server calls handlers concurrently: across requests, as any HTTP handler, and within one request, since the invocations of a batch execute at the same time. A handler must not rely on another invocation of the same request having run before it, and any state it shares needs its own locking.
type RequestOption ¶
type RequestOption = func(cfg *requestConfig)
func WithDelegations ¶
func WithDelegations(delegations ...ucan.Delegation) RequestOption
WithDelegations adds delegations to the execution request. They should be linked from the invocation to be executed.
func WithInvocations ¶
func WithInvocations(invocations ...ucan.Invocation) RequestOption
WithInvocations adds additional invocations to the execution request.
func WithReceipts ¶
func WithReceipts(receipts ...ucan.Receipt) RequestOption
WithReceipts adds receipts to the execution request.
func WithRequestMetadata ¶
func WithRequestMetadata(metadata ucan.Container) RequestOption
WithRequestMetadata sets a ready-made container as the request metadata, so an executor running many invocations against the same tokens builds the container once and shares it.
The container is shared by every request it is passed to, and container.Container returns its internal slices. Handlers must treat the metadata as read-only and clone a slice before modifying it.
Tokens given through WithInvocations, WithDelegations and WithReceipts are merged into a new container after the tokens of this one, de-duplicated by CID. The given container is used as is only when no token option is passed.
type Response ¶
type Response interface {
// Receipt for the executed task.
Receipt() ucan.Receipt
// SetReceipt sets the receipt for the executed task.
SetReceipt(ucan.Receipt) error
// SetSuccess issues a receipt with a successful result for the executed
// task and sets it on the response. The ok value is any
// cborgen-marshalable type whose schema matches what the task expects to
// produce.
SetSuccess(ok cbg.CBORMarshaler) error
// SetFailure issues a receipt with a failure result for the executed task
// and sets it on the response.
SetFailure(error) error
// Metadata provides additional information about the response.
Metadata() ucan.Container
// SetMetadata sets additional information about the response.
SetMetadata(ucan.Container) error
}
type ResponseOption ¶
type ResponseOption func(r *ExecResponse) error
func WithFailure ¶
func WithFailure(x error) ResponseOption
WithFailure issues and sets a receipt for a failed execution of a task.
func WithIssuer ¶
func WithIssuer(issuer ucan.Issuer) ResponseOption
func WithMetadata ¶
func WithMetadata(m ucan.Container) ResponseOption
func WithReceipt ¶
func WithReceipt(receipt ucan.Receipt) ResponseOption
func WithReceiptExpiration ¶
func WithReceiptExpiration(exp ucan.UnixTimestamp) ResponseOption
WithReceiptExpiration configures the response to issue receipts with the given expiration. Note: this option should be ordered before WithSuccess or WithFailure, since these options issue a receipt.
func WithReceiptTimestamp ¶
func WithReceiptTimestamp(enabled bool) ResponseOption
WithReceiptTimestamp configures the response to issue receipts with issuance timestamps. Note: this option should be ordered before WithSuccess or WithFailure, since these options issue a receipt.
func WithSuccess ¶
func WithSuccess(o cbg.CBORMarshaler) ResponseOption
WithSuccess issues and sets a receipt for a successful execution of a task.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package batch executes many UCAN invocations in one round trip.
|
Package batch executes many UCAN invocations in one round trip. |