Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterFunction[Req, Resp proto.Message](t *EtcdTransportClient, handler func(context.Context, Req) (Resp, error)) error
- func RegisterWatcher(lc fx.Lifecycle, t *EtcdTransportClient, agentName string)
- func SendRequest[RespValue any, Resp ExactMessage[RespValue]](t *EtcdTransportServer, client string, msg proto.Message) (*RespValue, error)
- type EtcdTransportClient
- type EtcdTransportServer
- type ExactMessage
- type HandlerRegistry
- type Request
- type Response
- type Result
Constants ¶
const ( // RPCBasePath is the base path for all etc based RPCs. RPCBasePath = "/rpc" // RPCRequestPath is the path for RPC requests. RPCRequestPath = "/request" // RPCResponsePath is the path for RPC responses. RPCResponsePath = "/response" )
Variables ¶
var TransportClientModule = fx.Options( fx.Provide(NewEtcdTransportClient), )
TransportClientModule is the client fx provider for etcd transport.
var TransportServerModule = fx.Options( fx.Provide(NewEtcdTransportServer), )
TransportServerModule is the server fx provider for etcd transport.
Functions ¶
func RegisterFunction ¶
func RegisterFunction[Req, Resp proto.Message]( t *EtcdTransportClient, handler func(context.Context, Req) (Resp, error), ) error
RegisterFunction register a function as a handler in the registry Only one function for a given Req type can be registered.
func RegisterWatcher ¶
func RegisterWatcher(lc fx.Lifecycle, t *EtcdTransportClient, agentName string)
RegisterWatcher allows to register a client on the etcd transport.
func SendRequest ¶
func SendRequest[RespValue any, Resp ExactMessage[RespValue]](t *EtcdTransportServer, client string, msg proto.Message) (*RespValue, error)
SendRequest allows consumers of the etcd transport to send single request to agents.
Types ¶
type EtcdTransportClient ¶
type EtcdTransportClient struct { Registry *HandlerRegistry // contains filtered or unexported fields }
EtcdTransportClient is the client side for the etcd transport.
func NewEtcdTransportClient ¶
func NewEtcdTransportClient(client *etcdclient.Client) (*EtcdTransportClient, error)
NewEtcdTransportClient creates and returns a new etcd transport client module.
func (*EtcdTransportClient) RegisterWatcher ¶
func (c *EtcdTransportClient) RegisterWatcher(agentName string) error
RegisterWatcher register an agent on the etcd transport client.
func (*EtcdTransportClient) Stop ¶
func (c *EtcdTransportClient) Stop()
Stop stops the etcd transport client.
type EtcdTransportServer ¶
type EtcdTransportServer struct {
// contains filtered or unexported fields
}
EtcdTransportServer is the server side of the etcd transport.
func NewEtcdTransportServer ¶
func NewEtcdTransportServer(client *etcdclient.Client) (*EtcdTransportServer, error)
NewEtcdTransportServer creates a new server on the etcd transport.
func (*EtcdTransportServer) SendRequest ¶
SendRequest sends a request to etcd, supposed to be consumed by an agent.
type ExactMessage ¶
ExactMessage is like proto.Message, but known to point to T.
type HandlerRegistry ¶
type HandlerRegistry struct {
// contains filtered or unexported fields
}
HandlerRegistry allow registering handlers and can start a dispatcher.
This is intended to be used at at fx provide/invoke stage.
func NewHandlerRegistry ¶
func NewHandlerRegistry() *HandlerRegistry
NewHandlerRegistry creates a new HandlerRegistry.
type Result ¶
Result is a result from one agent.
func SendRequests ¶
func SendRequests[RespValue any, Resp ExactMessage[RespValue]](t *EtcdTransportServer, agents []string, msg proto.Message) ([]Result[*RespValue], error)
SendRequests allows consumers of the etcd transport to send requests to agents.