bifrost_rpc

package
v0.40.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServiceClientUnavailable = errors.New("no client available for that service")

ErrServiceClientUnavailable is returned if no clients are available for a service.

Functions

func ExLookupRpcClientSet

func ExLookupRpcClientSet(
	ctx context.Context,
	b bus.Bus,
	serviceID, clientID string,
	waitOne bool,
	disposeCb func(),
) (*srpc.ClientSet, directive.Instance, directive.Reference, error)

ExLookupRpcClientSet executes the LookupRpcClient directive returning a ClientSet. Returns ErrServiceClientUnavailable if no clients are returned. If waitOne is set, waits for at least one value before returning. disposeCb is called if the directive or any of the clients is released. disposeCb is optional

Types

type BusClient added in v0.25.0

type BusClient struct {
	// contains filtered or unexported fields
}

BusClient implements srpc.Client looking up the RPC client on-demand when a RPC starts.

func NewBusClient added in v0.25.0

func NewBusClient(b bus.Bus) *BusClient

NewBusClient constructs a new rpc client.

func (*BusClient) ExecCall added in v0.25.0

func (c *BusClient) ExecCall(
	ctx context.Context,
	service,
	method string,
	in,
	out srpc.Message,
) error

ExecCall executes a request/reply RPC with the remote.

func (*BusClient) NewStream added in v0.25.0

func (c *BusClient) NewStream(
	ctx context.Context,
	service,
	method string,
	firstMsg srpc.Message,
) (srpc.Stream, error)

NewStream starts a streaming RPC with the remote & returns the stream. firstMsg is optional.

type ClientController

type ClientController struct {
	// contains filtered or unexported fields
}

ClientController wraps a srpc.Client and serves LookupRpcClient requests.

func NewClientController

func NewClientController(
	le *logrus.Entry,
	bus bus.Bus,
	info *controller.Info,
	client srpc.Client,
	matchServicePrefixes []string,
) *ClientController

NewClientController constructs a new controller.

func (*ClientController) Close

func (c *ClientController) Close() error

Close releases any resources used by the controller. Error indicates any issue encountered releasing.

func (*ClientController) Execute

func (c *ClientController) Execute(rctx context.Context) (rerr error)

Execute executes the controller. Returning nil ends execution.

func (*ClientController) GetBaseClient added in v0.25.1

func (c *ClientController) GetBaseClient() srpc.Client

GetBaseClient returns the client without the prefix stripping.

func (*ClientController) GetClient

func (c *ClientController) GetClient() *srpc.PrefixClient

GetClient returns the prefixed client.

func (*ClientController) GetControllerInfo

func (c *ClientController) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*ClientController) HandleDirective

func (c *ClientController) HandleDirective(
	ctx context.Context,
	inst directive.Instance,
) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive.

type Invoker

type Invoker struct {
	// contains filtered or unexported fields
}

Invoker implements the RPC invoker with a directive.

func NewInvoker

func NewInvoker(b bus.Bus, serverID string, wait bool) *Invoker

NewInvoker constructs a new rpc method invoker. serverID can be empty, will be used for directives. if wait is set, waits for the rpc service to become available. otherwise, returns "unimplemented" if the service is unavailable.

func (*Invoker) InvokeMethod

func (i *Invoker) InvokeMethod(serviceID, methodID string, strm srpc.Stream) (bool, error)

InvokeMethod invokes the method matching the service & method ID. Returns false, nil if not found. If service string is empty, ignore it.

type InvokerController

type InvokerController struct {
	// contains filtered or unexported fields
}

InvokerController wraps a srpc.Invoker and serves LookupRpcService requests.

func NewInvokerController

func NewInvokerController(
	le *logrus.Entry,
	bus bus.Bus,
	info *controller.Info,
	invoker srpc.Invoker,
	matchServicePrefixes []string,
) *InvokerController

NewInvokerController constructs a new controller.

func (*InvokerController) Close

func (c *InvokerController) Close() error

Close releases any resources used by the controller. Error indicates any issue encountered releasing.

func (*InvokerController) Execute

func (c *InvokerController) Execute(rctx context.Context) (rerr error)

Execute executes the controller. Returning nil ends execution.

func (*InvokerController) GetControllerInfo

func (c *InvokerController) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*InvokerController) HandleDirective

func (c *InvokerController) HandleDirective(
	ctx context.Context,
	inst directive.Instance,
) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive.

func (*InvokerController) InvokeMethod

func (c *InvokerController) InvokeMethod(serviceID, methodID string, strm srpc.Stream) (bool, error)

InvokeMethod invokes the method matching the service & method ID. Returns false, nil if not found. If service string is empty, ignore it.

type LookupRpcClient

type LookupRpcClient interface {
	// Directive indicates LookupRpcClient is a directive.
	directive.Directive

	// LookupRpcServiceID returns the ID of the service.
	// Cannot be empty.
	LookupRpcServiceID() string
	// LookupRpcClientID returns the identifier of the caller.
	// Use this for call routing only, not authentication.
	// Can be empty.
	LookupRpcClientID() string
}

LookupRpcClient is a directive to lookup a RPC client for a service.

func NewLookupRpcClient

func NewLookupRpcClient(serviceID, clientID string) LookupRpcClient

NewLookupRpcClient constructs a new LookupRpcClient directive.

type LookupRpcClientResolver

type LookupRpcClientResolver = *directive.ValueResolver[LookupRpcClientValue]

LookupRpcClientResolver resolves LookupRpcClient with an Invoker.

func NewLookupRpcClientResolver

func NewLookupRpcClientResolver(client srpc.Client) LookupRpcClientResolver

NewLookupRpcClientResolver constructs a new LookupRpcClientResolver directive.

type LookupRpcClientValue

type LookupRpcClientValue = srpc.Client

LookupRpcClientValue is the result type for LookupRpcClient. Multiple results may be pushed to the directive.

func ExLookupRpcClient

func ExLookupRpcClient(
	ctx context.Context,
	b bus.Bus,
	serviceID, clientID string,
	waitOne bool,
	disposeCb func(),
) ([]LookupRpcClientValue, directive.Instance, directive.Reference, error)

ExLookupRpcClient executes the LookupRpcClient directive. Returns if the directive becomes idle (most likely: service not found). If no values are returned, returns nil, nil, nil If values are returned, returns vals, valsRef, nil Otherwise returns nil, nil, err If waitOne is set, waits for at least one value before returning. disposeCb is called if the directive or any of the clients is released. disposeCb is optional

type LookupRpcService

type LookupRpcService interface {
	// Directive indicates LookupRpcService is a directive.
	directive.Directive

	// LookupRpcServiceID returns the service ID to load.
	// Cannot be empty.
	LookupRpcServiceID() string
	// LookupRpcServerID returns the ID of the server requesting the service.
	// Use this for call routing only, not authentication.
	// Can be empty.
	LookupRpcServerID() string
}

LookupRpcService is a directive to lookup a RPC service for a server.

func NewLookupRpcService

func NewLookupRpcService(serviceID, serverID string) LookupRpcService

NewLookupRpcService constructs a new LookupRpcService directive.

type LookupRpcServiceResolver

type LookupRpcServiceResolver = *directive.ValueResolver[LookupRpcServiceValue]

LookupRpcServiceResolver resolves LookupRpcService with an Invoker.

func NewLookupRpcServiceResolver

func NewLookupRpcServiceResolver(invoker srpc.Invoker) LookupRpcServiceResolver

NewLookupRpcServiceResolver constructs a new LookupRpcServiceResolver directive.

type LookupRpcServiceValue

type LookupRpcServiceValue = srpc.Invoker

LookupRpcServiceValue is the result type for LookupRpcService. Multiple results may be pushed to the directive.

func ExLookupRpcService

func ExLookupRpcService(
	ctx context.Context,
	b bus.Bus,
	serviceID, serverID string,
	waitOne bool,
) ([]LookupRpcServiceValue, directive.Instance, directive.Reference, error)

ExLookupRpcService executes the LookupRpcService directive. Returns if the directive becomes idle (most likely: service not found). If no values are returned, returns nil, nil, nil If values are returned, returns vals, valsRef, nil Otherwise returns nil, nil, err If waitOne is set, waits for at least one value before returning.

type RpcServiceBuilder added in v0.15.2

type RpcServiceBuilder = refcount.RefCountResolver[srpc.Invoker]

RpcServiceBuilder builds a rpc service invoker.

returns the srpc invoker and an optional release function can return nil to indicate not found.

func NewRpcServiceBuilder added in v0.15.2

func NewRpcServiceBuilder(handler srpc.Invoker) RpcServiceBuilder

NewRpcServiceBuilder creates a new RpcServiceBuilder with a static invoker.

type RpcServiceController added in v0.15.2

type RpcServiceController struct {
	// contains filtered or unexported fields
}

RpcServiceController resolves LookupRpcService with a srpc.Invoker.

func NewRpcServiceController added in v0.15.2

func NewRpcServiceController(
	info *controller.Info,
	resolver RpcServiceBuilder,
	serviceIdPrefixes []string,
	stripServiceIdPrefix bool,
	serviceIdRe *regexp.Regexp,
	serviceIdList []string,
	serverIdRe *regexp.Regexp,
) *RpcServiceController

NewRpcServiceController constructs a new LookupRpcService resolver controller.

Responds if a URL matches either serviceIdPrefixes OR serviceIdRe OR serviceIdList. all filters can be empty if no filters are set, resolves for any LookupRpcService directive. serverIdRe MUST match if set, regardless of the other filters.

func (*RpcServiceController) Close added in v0.15.2

func (c *RpcServiceController) Close() error

Close releases any resources used by the controller.

func (*RpcServiceController) Execute added in v0.15.2

func (c *RpcServiceController) Execute(ctx context.Context) error

Execute executes the controller.

func (*RpcServiceController) GetControllerInfo added in v0.15.2

func (c *RpcServiceController) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*RpcServiceController) HandleDirective added in v0.15.2

func (c *RpcServiceController) HandleDirective(
	ctx context.Context,
	inst directive.Instance,
) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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