Documentation
¶
Index ¶
- type Client
- func (c *Client) AccessRootResource() ResourceRef
- func (c *Client) AttachRawInvoker(ctx context.Context, label string, mux srpc.Invoker) (uint32, error)
- func (c *Client) AttachResource(ctx context.Context, label string, mux srpc.Invoker) (uint32, error)
- func (c *Client) AttachResourceTree(ctx context.Context, label string, mux srpc.Invoker) (uint32, error)
- func (c *Client) CreateResourceReference(resourceID uint32) ResourceRef
- func (c *Client) DetachResource(ctx context.Context, resourceID uint32) error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Release()
- type ResourceRef
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 (*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 ¶
DetachResource withdraws a previously attached resource.
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.