client

package
v0.0.0-...-d9c1543 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0, MIT Imports: 11 Imported by: 6 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client[Req transport.Request, Res any] struct {
	Codec     transport.OutboundCodec[Req, Res]
	Transport transport.RoundTripper[Req, Res]
	Listeners []EventListener
}

func New

func New[Req transport.Request, Res any](transport transport.RoundTripper[Req, Res], codec transport.OutboundCodec[Req, Res]) *Client[Req, Res]

func (*Client[Req, Res]) Execute

func (c *Client[Req, Res]) Execute(execRequest execution.Request) (execution.Response, error)

Execute sends a single invocation and returns the receipt for its task. It is a batch of one; see Client.ExecuteBatch.

func (*Client[Req, Res]) ExecuteBatch

func (c *Client[Req, Res]) ExecuteBatch(req *batch.Request) (_ *batch.Response, err error)

ExecuteBatch sends every invocation in the request in one round trip and returns their receipts. The response is an error if the executor did not answer one of the invocations.

type EventListener

type EventListener interface {
	RequestEncodeListener
	ResponseDecodeListener
}

EventListener observes both halves of the request/response round trip a client performs: a request being encoded and a response being decoded. Register one with WithEventListener.

type HTTPClient

type HTTPClient struct {
	*Client[*http.Request, *http.Response]
}

func NewHTTP

func NewHTTP(serviceURL *url.URL, options ...HTTPOption) (*HTTPClient, error)

func (*HTTPClient) Execute

func (c *HTTPClient) Execute(execRequest execution.Request) (execution.Response, error)

func (*HTTPClient) ExecuteBatch

func (c *HTTPClient) ExecuteBatch(req *batch.Request) (*batch.Response, error)

type HTTPOption

type HTTPOption func(*httpClientConfig)

func WithEventListener

func WithEventListener(listener EventListener) HTTPOption

WithEventListener registers an EventListener to observe the client's requests and responses as they are encoded and decoded.

func WithHTTPClient

func WithHTTPClient(client *http.Client) HTTPOption

type RequestEncodeListener

type RequestEncodeListener interface {
	OnRequestEncode(ctx context.Context, container ucan.Container) error
}

RequestEncodeListener is an observer with a function that is called before an execution request is encoded by the codec.

type ResponseDecodeListener

type ResponseDecodeListener interface {
	OnResponseDecode(ctx context.Context, container ucan.Container) error
}

ResponseDecodeListener is an observer with a function that is called after an execution response is decoded by the codec.

Jump to

Keyboard shortcuts

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