Documentation ¶
Index ¶
- Constants
- func DefaultSubscribeOn[T any, P any](stream ServerStream[P], subscriptions *Subscriptions[T, P], ...) error
- func DefaultUnsubscribe[T any, P any](ctx context.Context, subscriptions *Subscriptions[T, P], subscriptionID uint64) (*pb.UnsubscribeResponse, error)
- type Client
- func (client *Client) Close() error
- func (client *Client) Connect(ctx context.Context, opts ...ConnectOption) error
- func (client *Client) Connection() *grpc.ClientConn
- func (client *Client) Name() string
- func (client *Client) Reconnect() <-chan struct{}
- func (client *Client) Start(ctx context.Context)
- type ConnectOption
- type ConnectOptions
- type Server
- type ServerConfig
- type ServerStream
- type Stream
- type Subscription
- type Subscriptions
- func (s *Subscriptions[T, P]) Add(id uint64, subscription Subscription[T, P])
- func (s *Subscriptions[T, P]) Close() error
- func (s *Subscriptions[T, P]) Get(id uint64) (Subscription[T, P], bool)
- func (s *Subscriptions[T, P]) NotifyAll(typ T, converter func(uint64, T) P)
- func (s *Subscriptions[T, P]) Remove(id uint64) error
Constants ¶
const (
SuccessMessage = "success"
)
Default messages
Variables ¶
This section is empty.
Functions ¶
func DefaultSubscribeOn ¶
func DefaultSubscribeOn[T any, P any](stream ServerStream[P], subscriptions *Subscriptions[T, P], subscription Subscription[T, P], handler func(id uint64) error, onEndOfSync func(id uint64) error) error
DefaultSubscribeOn - default subscribe server handler
func DefaultUnsubscribe ¶
func DefaultUnsubscribe[T any, P any](ctx context.Context, subscriptions *Subscriptions[T, P], subscriptionID uint64) (*pb.UnsubscribeResponse, error)
DefaultUnsubscribe - default unsubscribe server handler
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client - the structure which is responsible for connection to server
func (*Client) Connect ¶
func (client *Client) Connect(ctx context.Context, opts ...ConnectOption) error
Connect - connects to server
func (*Client) Connection ¶
func (client *Client) Connection() *grpc.ClientConn
Connection - receives connection entity
type ConnectOption ¶
type ConnectOption func(opts *ConnectOptions)
ConnectOption -
func WithReconnectTimeout ¶
func WithReconnectTimeout(duration time.Duration) ConnectOption
WithReconnectTimeout -
func WithReconnectionTime ¶
func WithReconnectionTime(duration time.Duration) ConnectOption
WithReconnectionTime -
type ConnectOptions ¶
type ConnectOptions struct {
// contains filtered or unexported fields
}
ConnectOptions -
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server - basic server structure which implemented module interface and handle stats endpoints.
func NewServer ¶
func NewServer(cfg *ServerConfig) (*Server, error)
NewServer - constructor of server struture
type ServerConfig ¶
type ServerConfig struct { Bind string `yaml:"bind" validate:"required,hostname_port"` Log bool `yaml:"log" validate:"omitempty"` Metrics bool `yaml:"metrics" validate:"omitempty"` RPS int `yaml:"rps" validate:"omitempty,min=1"` }
ServerConfig - config for server
type ServerStream ¶
type ServerStream[T any] interface { Send(T) error grpc.ServerStream }
ServerStream -
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
Stream -
func NewStream ¶
func NewStream[T any](stream grpc.ClientStream) *Stream[T]
NewStream - creates new stream
func (*Stream[T]) Listen ¶
func (s *Stream[T]) Listen() <-chan *T
Listen - channel with received messages
type Subscription ¶
type Subscription[T any, P any] interface { Filter(typ T) bool Send(msg P) Listen() <-chan P io.Closer }
Subscription - general interface for subscription
type Subscriptions ¶
Subscriptions -
func NewSubscriptions ¶
func NewSubscriptions[T any, P any]() *Subscriptions[T, P]
NewSubscriptions -
func (*Subscriptions[T, P]) Add ¶
func (s *Subscriptions[T, P]) Add(id uint64, subscription Subscription[T, P])
Add -
func (*Subscriptions[T, P]) Get ¶
func (s *Subscriptions[T, P]) Get(id uint64) (Subscription[T, P], bool)
Get -
func (*Subscriptions[T, P]) NotifyAll ¶
func (s *Subscriptions[T, P]) NotifyAll(typ T, converter func(uint64, T) P)
NotifyAll -