Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterHandler[RequestType proto.Message, ResponseType proto.Message](s *RPCServer, rpc string, topic string, ...) error
- func RequestMulti[ResponseType proto.Message](ctx context.Context, c *RPCClient, rpc string, topic string, ...) (<-chan *Response[ResponseType], error)
- func RequestSingle[ResponseType proto.Message](ctx context.Context, c *RPCClient, rpc string, topic string, ...) (ResponseType, error)
- func SetLogger(l logr.Logger)
- type AffinityFunc
- type ClientOption
- type Handler
- type MessageBus
- type RPCClient
- type RPCServer
- type RequestOption
- type Response
- type SelectionOpts
- type ServerOption
- type Subscription
- func Join[ResponseType proto.Message](ctx context.Context, c *RPCClient, rpc string, topic string) (Subscription[ResponseType], error)
- func JoinQueue[ResponseType proto.Message](ctx context.Context, c *RPCClient, rpc string, topic string) (Subscription[ResponseType], error)
- func Subscribe[MessageType proto.Message](ctx context.Context, bus MessageBus, channel string, channelSize int) (Subscription[MessageType], error)
- func SubscribeQueue[MessageType proto.Message](ctx context.Context, bus MessageBus, channel string, channelSize int) (Subscription[MessageType], error)
- type UnaryServerInterceptor
Constants ¶
View Source
const (
DefaultChannelSize = 100
)
View Source
const (
DefaultClientTimeout = time.Second * 3
)
View Source
const (
DefaultServerTimeout = time.Second * 3
)
Variables ¶
View Source
var ( ErrRequestTimedOut = errors.New("request timed out") ErrNoResponse = errors.New("no response from servers") )
Functions ¶
func RegisterHandler ¶ added in v0.2.0
func RequestMulti ¶ added in v0.2.0
func RequestSingle ¶
Types ¶
type AffinityFunc ¶
type ClientOption ¶ added in v0.2.0
type ClientOption func(*clientOpts)
func WithClientChannelSize ¶ added in v0.2.0
func WithClientChannelSize(size int) ClientOption
func WithClientTimeout ¶
func WithClientTimeout(timeout time.Duration) ClientOption
type MessageBus ¶
type MessageBus interface {
Publish(ctx context.Context, channel string, msg proto.Message) error
Subscribe(ctx context.Context, channel string, channelSize int) (subInternal, error)
SubscribeQueue(ctx context.Context, channel string, channelSize int) (subInternal, error)
}
func NewNatsMessageBus ¶
func NewNatsMessageBus(nc *nats.Conn) MessageBus
func NewRedisMessageBus ¶
func NewRedisMessageBus(rc redis.UniversalClient) MessageBus
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func NewRPCClient ¶
func NewRPCClient(serviceName, clientID string, bus MessageBus, opts ...ClientOption) (*RPCClient, error)
type RPCServer ¶
type RPCServer struct {
// contains filtered or unexported fields
}
func NewRPCServer ¶
func NewRPCServer(serviceName, serverID string, bus MessageBus, opts ...ServerOption) *RPCServer
func (*RPCServer) DeregisterHandler ¶
type RequestOption ¶ added in v0.2.0
type RequestOption func(*reqOpts)
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) RequestOption
func WithSelectionOpts ¶
func WithSelectionOpts(opts SelectionOpts) RequestOption
type SelectionOpts ¶
type SelectionOpts struct {
MinimumAffinity float32 // minimum affinity for a server to be considered a valid handler
AcceptFirstAvailable bool // go fast
AffinityTimeout time.Duration // server selection deadline
ShortCircuitTimeout time.Duration // deadline imposed after receiving first response
}
type ServerOption ¶ added in v0.2.0
type ServerOption func(*serverOpts)
func WithServerChannelSize ¶ added in v0.2.0
func WithServerChannelSize(size int) ServerOption
func WithServerTimeout ¶
func WithServerTimeout(timeout time.Duration) ServerOption
func WithUnaryServerInterceptors ¶ added in v0.2.0
func WithUnaryServerInterceptors(interceptors ...UnaryServerInterceptor) ServerOption
type Subscription ¶
type Subscription[MessageType proto.Message] interface { Channel() <-chan MessageType Close() error }
func Subscribe ¶
func Subscribe[MessageType proto.Message]( ctx context.Context, bus MessageBus, channel string, channelSize int, ) (Subscription[MessageType], error)
func SubscribeQueue ¶
func SubscribeQueue[MessageType proto.Message]( ctx context.Context, bus MessageBus, channel string, channelSize int, ) (Subscription[MessageType], error)
type UnaryServerInterceptor ¶ added in v0.2.0
type UnaryServerInterceptor func(ctx context.Context, req proto.Message, handler Handler) (proto.Message, error)
func WithServerRecovery ¶ added in v0.2.0
func WithServerRecovery() UnaryServerInterceptor
Source Files
¶
Click to show internal directories.
Click to hide internal directories.