Documentation
¶
Overview ¶
Package orb provides the default client for go-orb.
Index ¶
- Constants
- Variables
- func Provide(name types.ServiceName, data types.ConfigData, logger log.Logger, ...) (client.Type, error)
- func RegisterTransport(name string, transport TransportFactory)
- type Client
- func (c *Client) Call(ctx context.Context, req *client.Request[any, any], _ any, ...) (resp *client.RawResponse, err error)
- func (c *Client) CallNoCodec(ctx context.Context, req *client.Request[any, any], result any, ...) error
- func (c *Client) Config() client.Config
- func (c *Client) NeedsCodec(ctx context.Context, req *client.Request[any, any], opts ...client.CallOption) bool
- func (c *Client) ResolveService(_ context.Context, service string, preferredTransports ...string) (client.NodeMap, error)
- func (c *Client) Start() error
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) String() string
- func (c *Client) Type() string
- func (c *Client) With(opts ...client.Option) error
- type Config
- type Transport
- type TransportFactory
- type TransportType
Constants ¶
const Name = "orb"
Name contains the plugins name.
Variables ¶
var ( // Transports is a map of registered transports. Transports = container.NewMap[string, TransportFactory]() )
Functions ¶
func Provide ¶
func Provide( name types.ServiceName, data types.ConfigData, logger log.Logger, registry registry.Type, opts ...client.Option, ) (client.Type, error)
Provide is the wire provider for client.
func RegisterTransport ¶
func RegisterTransport(name string, transport TransportFactory)
RegisterTransport registers a transport with the orb client.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the microservices client for go-orb.
func New ¶
New creates a new orb client. This functions should rarely be called manually. To create a new client use ProvideClientOrb.
func (*Client) Call ¶
func (c *Client) Call( ctx context.Context, req *client.Request[any, any], _ any, opts ...client.CallOption, ) (resp *client.RawResponse, err error)
Call does the actual call.
func (*Client) CallNoCodec ¶
func (c *Client) CallNoCodec( ctx context.Context, req *client.Request[any, any], result any, opts ...client.CallOption, ) error
CallNoCodec does the actual call without codecs.
func (*Client) NeedsCodec ¶
func (c *Client) NeedsCodec(ctx context.Context, req *client.Request[any, any], opts ...client.CallOption) bool
NeedsCodec returns whetever the underlying transport requires a codec to translate the communication with the server.
func (*Client) ResolveService ¶
func (c *Client) ResolveService( _ context.Context, service string, preferredTransports ...string, ) (client.NodeMap, error)
ResolveService resolves a servicename to a Node with the help of the registry.
type Config ¶
Config is the config for the orb client.
func NewConfig ¶
func NewConfig( serviceName types.ServiceName, datas types.ConfigData, opts ...client.Option, ) (Config, error)
NewConfig creates a new config object.
type Transport ¶
type Transport interface {
Start() error
Stop(ctx context.Context) error
String() string
// NoCodec indicates whatever the transport does the encoding on its own.
NeedsCodec() bool
// Call does the actual call to the service, it's important that any errors returned by Call are orberrors.
Call(ctx context.Context, req *client.Request[any, any], opts *client.CallOptions) (*client.RawResponse, error)
// CallNoCodec is the same as call but it's using the codec from the transport.
CallNoCodec(ctx context.Context, req *client.Request[any, any], result any, opts *client.CallOptions) error
}
Transport is the interface for each transport.
type TransportFactory ¶
type TransportFactory = func(log.Logger, *Config) (TransportType, error)
TransportFactory is used by a transports to register itself with the global "Transports" below.
type TransportType ¶
type TransportType struct {
Transport
}
TransportType is the type returned by NewTransportFunc.