execution

package
v0.0.0-...-2076d20 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const HandlerExecutionErrorName = "HandlerExecutionError"
View Source
const InvalidAudienceErrorName = "InvalidAudience"

Variables

This section is empty.

Functions

func NewHandlerExecutionError

func NewHandlerExecutionError(cmd ucan.Command, cause error) error

func NewInvalidAudienceError

func NewInvalidAudienceError(expected did.DID, actual did.DID) error

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) SetSigner

func (r *ExecResponse) SetSigner(signer ucan.Signer) error

func (*ExecResponse) SetSuccess

func (r *ExecResponse) SetSuccess(ok cbg.CBORMarshaler) error

type Executor

type Executor interface {
	Execute(Request) (Response, error)
}

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

type HandlerFunc = func(Request, Response) error

HandlerFunc is a function that can handle a specific UCAN invocation.

type Request

type Request interface {
	Context() context.Context
	// Invocation that should be executed.
	Invocation() ucan.Invocation
	// Metadata provides additional information about the invocation.
	Metadata() ucan.Container
}

type RequestOption

type RequestOption = func(cfg *requestConfig)

func WithDelegations

func WithDelegations(delegations ...ucan.Delegation) RequestOption

WithDelegations adds delegations to the execution request.

func WithInvocations

func WithInvocations(invocations ...ucan.Invocation) RequestOption

WithInvocations adds additional invocations to the execution request.

func WithProofs

func WithProofs(delegations ...ucan.Delegation) RequestOption

WithProofs adds delegations to the execution request. They should be linked from the invocation to be executed.

func WithReceipts

func WithReceipts(receipts ...ucan.Receipt) RequestOption

WithReceipts adds receipts to the execution request.

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 WithMetadata

func WithMetadata(m ucan.Container) ResponseOption

func WithReceipt

func WithReceipt(receipt ucan.Receipt) ResponseOption

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 WithSigner

func WithSigner(signer ucan.Signer) ResponseOption

func WithSuccess

func WithSuccess(o cbg.CBORMarshaler) ResponseOption

WithSuccess issues and sets a receipt for a successful execution of a task.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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