bifrost_rpc

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 8 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) (*srpc.ClientSet, directive.Reference, error)

ExLookupRpcClientSet executes the LookupRpcClient directive returning a ClientSet. Returns ErrServiceClientUnavailable if no clients are returned.

Types

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) 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) *Invoker

NewInvoker constructs a new rpc method invoker. serverID can be empty, will be used for directives.

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,
) ([]LookupRpcClientValue, 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

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,
) ([]LookupRpcServiceValue, 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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