Documentation
¶
Overview ¶
Package orb provides the default client for go-orb.
Index ¶
- Constants
- Variables
- func Provide(configData map[string]any, components *types.Components, logger log.Logger, ...) (client.Type, error)
- func RegisterTransport(name string, transport TransportFactory)
- type Client
- func (c *Client) Config() client.Config
- func (c *Client) Logger() log.Logger
- func (c *Client) Request(ctx context.Context, service string, endpoint string, req any, result any, ...) error
- func (c *Client) SelectService(ctx context.Context, service string, opts ...client.CallOption) (string, string, error)
- func (c *Client) Start(_ context.Context) error
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) Stream(ctx context.Context, service string, endpoint string, ...) (client.StreamIface[any, any], 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 ¶
View Source
const Name = "orb"
Name contains the plugins name.
Variables ¶
View Source
var ( // Transports is a map of registered transports. Transports = container.NewMap[string, TransportFactory]() )
Functions ¶
func Provide ¶
func Provide( configData map[string]any, components *types.Components, 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) Request ¶ added in v0.2.0
func (c *Client) Request( ctx context.Context, service string, endpoint string, req any, result any, opts ...client.CallOption, ) error
Request does the actual call.
func (*Client) SelectService ¶ added in v0.2.0
func (c *Client) SelectService(ctx context.Context, service string, opts ...client.CallOption) (string, string, error)
SelectService selects a service node.
func (*Client) Stream ¶ added in v0.2.0
func (c *Client) Stream( ctx context.Context, service string, endpoint string, opts ...client.CallOption, ) (client.StreamIface[any, any], error)
Stream opens a bidirectional stream to the service endpoint.
type Transport ¶
type Transport interface {
Start() error
Stop(ctx context.Context) error
Name() string
// Request does the actual call to the service, it's important that any errors returned by Request are orberrors.
Request(ctx context.Context, infos client.RequestInfos, req any, result any, opts *client.CallOptions) error
// Stream opens a bidirectional stream to the service endpoint.
// It handles streaming communication with the service.
Stream(ctx context.Context, infos client.RequestInfos, opts *client.CallOptions) (client.StreamIface[any, any], 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.
Click to show internal directories.
Click to hide internal directories.