Help us shape the future of Go! Take the 2026 Go Developer Survey

resource_client

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client manages one immutable remote ResourceClient generation. It serializes lifecycle controls and reference-counts each remote resource.

func NewClient

func NewClient(ctx context.Context, service resource.SRPCResourceServiceClient) (*Client, error)

NewClient constructs a ResourceClient generation and waits for its init.

func (*Client) AccessRootResource

func (c *Client) AccessRootResource() ResourceRef

AccessRootResource returns a reference to this generation's root resource.

func (*Client) AttachRawInvoker added in v0.51.2

func (c *Client) AttachRawInvoker(
	ctx context.Context,
	label string,
	mux srpc.Invoker,
) (uint32, error)

AttachRawInvoker provides a leaf callback mux that server-side handlers can invoke. Raw invokers are not resource trees; handlers should use GetAttachedResource for this shape.

func (*Client) AttachResource

func (c *Client) AttachResource(
	ctx context.Context,
	label string,
	mux srpc.Invoker,
) (uint32, error)

AttachResource provides a mux that server-side handlers can invoke. The mux is served over a yamux session inside the ResourceAttach bidi stream. Returns the server-assigned resource ID. Multiple resources share one yamux session. The caller's mux serves RPCs coming from the server side, routed by rpcstream component_id = resourceID.

func (*Client) AttachResourceTree added in v0.51.2

func (c *Client) AttachResourceTree(
	ctx context.Context,
	label string,
	mux srpc.Invoker,
) (uint32, error)

AttachResourceTree provides a Resource SDK tree root that server-side handlers can wrap as a resource reference and use to call child resources.

func (*Client) CreateResourceReference

func (c *Client) CreateResourceReference(resourceID uint32) ResourceRef

CreateResourceReference acquires a local reference to resourceID.

func (*Client) DetachResource

func (c *Client) DetachResource(ctx context.Context, resourceID uint32) error

DetachResource withdraws a previously attached resource.

func (*Client) Done added in v0.54.0

func (c *Client) Done() <-chan struct{}

Done closes after this ResourceClient generation has drained and retired.

func (*Client) Release

func (c *Client) Release()

Release queues final releases and closes this ResourceClient generation.

type ResourceRef

type ResourceRef interface {
	// GetResourceID returns the resource ID.
	GetResourceID() uint32
	// GetClient returns the SRPC client for this resource.
	// The client is created lazily on first access.
	GetClient() (srpc.Client, error)
	// Release releases this reference.
	// When the last reference to a resource is released, the server is notified.
	Release()
}

ResourceRef is a reference to a remote resource. Each reference must be explicitly released when no longer needed.

Jump to

Keyboard shortcuts

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