Documentation
¶
Overview ¶
Package client implements the experimental Pi client over ordered byte transports.
Index ¶
- func CreateClientServiceTransport(client ServiceTransportClient, getTarget func() protocol.RpcTarget) chord.RemoteServiceTransport
- type AttachmentChangeListener
- type ByteTransport
- type ByteTransportFactory
- type ByteTransportHandlers
- type Client
- func (client *Client) Attachment() *protocol.SessionTarget
- func (client *Client) BeginInvoke(ctx context.Context, target protocol.RpcTarget, call chord.ServiceCall) (*chord.ServiceInvocation, error)
- func (client *Client) Connect(ctx context.Context) (protocol.ServerHello, error)
- func (client *Client) Connected() bool
- func (client *Client) ConnectionState() ConnectionState
- func (client *Client) Disconnect(reason error)
- func (client *Client) Dispose() error
- func (client *Client) Disposed() bool
- func (client *Client) Hello() *protocol.ServerHello
- func (client *Client) OnAttachmentChange(identity *AttachmentChangeListener) (func(), error)
- func (client *Client) OnConnectionStateChange(identity *ConnectionStateChangeListener) (func(), error)
- func (client *Client) Reconnect(ctx context.Context) (protocol.ServerHello, error)
- func (client *Client) Request(ctx context.Context, target protocol.RpcTarget, call chord.ServiceCall) (json.RawMessage, error)
- func (client *Client) ServerId() string
- func (client *Client) ServiceCatalogue(ctx context.Context, target protocol.RpcTarget) ([]chord.ServiceCatalogueEntry, error)
- func (client *Client) ServiceCatalogueCallback(ctx context.Context, target protocol.RpcTarget, ...)
- func (client *Client) SubscribeService(ctx context.Context, target protocol.RpcTarget, serviceId string, ...) (*ServiceSubscription, error)
- func (client *Client) WaitClosed(ctx context.Context) error
- type ClientDisposedError
- type ClientOptions
- type Connection
- func (connection *Connection) Connect(ctx context.Context) (protocol.ServerHello, error)
- func (connection *Connection) Disconnect(reason error)
- func (connection *Connection) Fail(err error)
- func (connection *Connection) MaxFrameLength() float64
- func (connection *Connection) Send(frame []byte) error
- func (connection *Connection) State() ConnectionState
- type ConnectionOptions
- type ConnectionState
- type ConnectionStateChange
- type ConnectionStateChangeListener
- type DisconnectedError
- type DiscoverUnixServersOptions
- type InitiatingServiceTransportClient
- type ServerError
- type ServiceSubscription
- type ServiceTransportClient
- type UnixServerRoute
- type UnixTransportOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateClientServiceTransport ¶
func CreateClientServiceTransport(client ServiceTransportClient, getTarget func() protocol.RpcTarget) chord.RemoteServiceTransport
CreateClientServiceTransport resolves the current target for each operation. Update listeners receive the background context, matching upstream's transport adapter.
Types ¶
type AttachmentChangeListener ¶
type AttachmentChangeListener struct {
// contains filtered or unexported fields
}
AttachmentChangeListener retains callback identity across removal and re-registration.
func NewAttachmentChangeListener ¶
func NewAttachmentChangeListener(call func(*protocol.SessionTarget)) *AttachmentChangeListener
type ByteTransport ¶
ByteTransport admits sends synchronously, in invocation order, and completes each send exactly once. Send returns promptly; its completion callback represents the upstream Promise settlement. Close is idempotent and does not report a local close as a remote callback.
type ByteTransportFactory ¶
type ByteTransportFactory func(context.Context, ByteTransportHandlers, func(ByteTransport, error))
ByteTransportFactory starts one connection attempt and returns promptly. Completion supplies one fresh connected transport or an error. The context owns the attempt, not the established transport. This callback boundary preserves the synchronous prefix of upstream's possibly Promise-returning factory.
func CreateUnixTransportFactory ¶
func CreateUnixTransportFactory(options UnixTransportOptions) (ByteTransportFactory, error)
CreateUnixTransportFactory validates options without connecting. Every invocation owns one cancellable dial and returns a fresh transport.
type ByteTransportHandlers ¶
ByteTransportHandlers receive ordered data and exactly one remote terminal notification.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client correlates framed requests, maintains attachment state, and hydrates ordered Chord subscriptions. It does not interpret application service methods.
func Connect ¶
func Connect(ctx context.Context, options ClientOptions) (*Client, error)
Connect constructs a client and waits for its handshake. Failed startup disposes the client and joins Go-owned attempts and transport I/O before returning the original error.
func NewClient ¶
func NewClient(options ClientOptions) (*Client, error)
NewClient validates identity and creates a disconnected client without opening a transport.
func (*Client) Attachment ¶
func (client *Client) Attachment() *protocol.SessionTarget
func (*Client) BeginInvoke ¶
func (client *Client) BeginInvoke(ctx context.Context, target protocol.RpcTarget, call chord.ServiceCall) (*chord.ServiceInvocation, error)
BeginInvoke performs request validation, correlation registration and ordered send admission before returning. The operation keeps ctx unchanged. Cancelling its Wait only abandons that observer; ctx still controls the actual request.
func (*Client) ConnectionState ¶
func (client *Client) ConnectionState() ConnectionState
func (*Client) Disconnect ¶
func (*Client) Dispose ¶
Dispose rejects pending requests, disconnects, and removes listeners. Repeated calls are harmless. Subscription owners dispose their subscriptions to join pending listener deliveries.
func (*Client) Hello ¶
func (client *Client) Hello() *protocol.ServerHello
func (*Client) OnAttachmentChange ¶
func (client *Client) OnAttachmentChange(identity *AttachmentChangeListener) (func(), error)
func (*Client) OnConnectionStateChange ¶
func (client *Client) OnConnectionStateChange(identity *ConnectionStateChangeListener) (func(), error)
func (*Client) Request ¶
func (client *Client) Request(ctx context.Context, target protocol.RpcTarget, call chord.ServiceCall) (json.RawMessage, error)
Request waits for one service result. Cancellation rejects this caller and sends a fenced cancel envelope without dropping the response correlation.
func (*Client) ServiceCatalogue ¶
func (client *Client) ServiceCatalogue(ctx context.Context, target protocol.RpcTarget) ([]chord.ServiceCatalogueEntry, error)
ServiceCatalogue validates the returned catalogue; malformed server data terminates the connection.
func (*Client) ServiceCatalogueCallback ¶
func (client *Client) ServiceCatalogueCallback(ctx context.Context, target protocol.RpcTarget, complete func([]chord.ServiceCatalogueEntry, error))
ServiceCatalogueCallback preserves the synchronous request-admission prefix needed by the connection service source. Its completion remains client-owned and WaitClosed drains it even if the source is disposed first.
func (*Client) SubscribeService ¶
func (client *Client) SubscribeService(ctx context.Context, target protocol.RpcTarget, serviceId string, mode chord.ServiceMode, listener func(chord.ServiceProviderUpdate) error) (*ServiceSubscription, error)
type ClientDisposedError ¶
type ClientDisposedError struct{}
ClientDisposedError rejects operations after client disposal.
func (*ClientDisposedError) Error ¶
func (*ClientDisposedError) Error() string
type ClientOptions ¶
type ClientOptions struct {
TransportFactory ByteTransportFactory
ServerId string
MaxFrameLength *float64
OnListenerError func(error)
}
ClientOptions selects one logical server and a fresh transport factory.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection validates handshakes and routes all subsequent messages. Each attempt has its own decoder and identity; stale transport callbacks cannot replace a newer connection.
func NewConnection ¶
func NewConnection(options ConnectionOptions) (*Connection, error)
NewConnection validates the frame limit without opening a transport.
func (*Connection) Connect ¶
func (connection *Connection) Connect(ctx context.Context) (protocol.ServerHello, error)
Connect starts the transport factory's synchronous prefix before waiting for a validated hello. Cancelling ctx cancels only this attempt; a completed connection stays live until Disconnect or a terminal transport event.
func (*Connection) Disconnect ¶
func (connection *Connection) Disconnect(reason error)
Disconnect ends the current attempt or connection. A nil reason selects the upstream default diagnostic.
func (*Connection) Fail ¶
func (connection *Connection) Fail(err error)
func (*Connection) MaxFrameLength ¶
func (connection *Connection) MaxFrameLength() float64
func (*Connection) Send ¶
func (connection *Connection) Send(frame []byte) error
Send admits an ordered write without awaiting it. A later transport rejection fails the connection that owns that write, not a replacement connection.
func (*Connection) State ¶
func (connection *Connection) State() ConnectionState
type ConnectionOptions ¶
type ConnectionOptions struct {
TransportFactory ByteTransportFactory
ServerId string
MaxFrameLength *float64
OnHandshake func(protocol.ServerHello) error
OnMessage func(protocol.ServerMessage)
OnStateChange func(ConnectionStateChange)
}
ConnectionOptions supplies the transport and client-owned callbacks. Callbacks run on the transport's ordered dispatcher and may synchronously disconnect or start a new connection.
type ConnectionState ¶
type ConnectionState string
ConnectionState is the transport/handshake lifecycle state.
const ( Disconnected ConnectionState = "disconnected" Connecting ConnectionState = "connecting" Connected ConnectionState = "connected" )
type ConnectionStateChange ¶
type ConnectionStateChange struct {
State ConnectionState
Error error
}
ConnectionStateChange is delivered after committing the connection's state.
type ConnectionStateChangeListener ¶
type ConnectionStateChangeListener struct {
// contains filtered or unexported fields
}
ConnectionStateChangeListener gives Go callbacks the stable identity that JavaScript functions have in a Set.
func NewConnectionStateChangeListener ¶
func NewConnectionStateChangeListener(call func(ConnectionStateChange)) *ConnectionStateChangeListener
type DisconnectedError ¶
DisconnectedError retains an underlying transport failure when there is one.
func (*DisconnectedError) Error ¶
func (err *DisconnectedError) Error() string
func (*DisconnectedError) Unwrap ¶
func (err *DisconnectedError) Unwrap() error
type DiscoverUnixServersOptions ¶
DiscoverUnixServersOptions bounds each connection and handshake attempt.
type InitiatingServiceTransportClient ¶
type InitiatingServiceTransportClient interface {
ServiceTransportClient
BeginInvoke(context.Context, protocol.RpcTarget, chord.ServiceCall) (*chord.ServiceInvocation, error)
}
InitiatingServiceTransportClient explicitly supplies a true request-admission boundary. A decorator forwards this capability only when it preserves that boundary.
type ServerError ¶
type ServerError struct{ Code, Message string }
ServerError retains the server's opaque error code and message.
func NewServerError ¶
func NewServerError(failure protocol.ProtocolError) *ServerError
func (*ServerError) Error ¶
func (err *ServerError) Error() string
type ServiceSubscription ¶
type ServiceSubscription struct {
Id string
Target protocol.RpcTarget
Snapshot chord.ServiceSubscriptionSnapshot
// contains filtered or unexported fields
}
ServiceSubscription holds the initial snapshot and buffers subsequent updates until Start. Dispose removes its listener before unsubscribing and drains admitted delivery after a successful unsubscribe.
func (*ServiceSubscription) Dispose ¶
func (subscription *ServiceSubscription) Dispose() error
func (*ServiceSubscription) Start ¶
func (subscription *ServiceSubscription) Start()
type ServiceTransportClient ¶
type ServiceTransportClient interface {
Request(context.Context, protocol.RpcTarget, chord.ServiceCall) (json.RawMessage, error)
SubscribeService(context.Context, protocol.RpcTarget, string, chord.ServiceMode, func(chord.ServiceProviderUpdate) error) (*ServiceSubscription, error)
}
ServiceTransportClient is the request/subscription capability consumed by a routed Chord transport. Decorators retain the production Client's lifecycle while interposing one service operation.
type UnixServerRoute ¶
UnixServerRoute identifies a canonical server-addressed local socket.
func DiscoverUnixServers ¶
func DiscoverUnixServers(ctx context.Context, options DiscoverUnixServersOptions) ([]UnixServerRoute, error)
DiscoverUnixServers probes only canonical server-addressed sockets, with at most sixteen joined workers. Stale/unresponsive endpoints remain on disk and are omitted; unexpected filesystem/transport errors propagate.
type UnixTransportOptions ¶
UnixTransportOptions selects a socket and the maximum admitted, not-yet-completed send bytes.