orb

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 16 Imported by: 31

Documentation

Overview

Package orb provides the default client for go-orb.

Index

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

func New(cfg Config, log log.Logger, registry registry.Type) *Client

New creates a new orb client. This functions should rarely be called manually. To create a new client use ProvideClientOrb.

func (*Client) Config

func (c *Client) Config() client.Config

Config returns the internal config, this is for tests.

func (*Client) Logger added in v0.2.0

func (c *Client) Logger() log.Logger

Logger returns the logger.

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) Start

func (c *Client) Start(_ context.Context) error

Start starts the client.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context) error

Stop stops the client.

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.

func (*Client) String

func (c *Client) String() string

func (*Client) Type

func (c *Client) Type() string

Type returns the clients componenttype "client".

func (*Client) With

func (c *Client) With(opts ...client.Option) error

With closes all transports and configures the client with the given options.

type Config

type Config struct {
	client.Config `yaml:",inline"`
}

Config is the config for the orb client.

func NewConfig

func NewConfig(
	opts ...client.Option,
) Config

NewConfig creates a new config object.

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.

Directories

Path Synopsis
transport
basehertz module
basehttp module
drpc module
grpc module
h2c module
hertzh2c module
hertzhttp module
http module
http3 module
https module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL