api

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidData = errors.New("invalid data")

Functions

func GRPCKeyAuth

func GRPCKeyAuth(key string) grpc.ServerOption

GRPCKeyAuth allows to set simple authentication based on string key from configuration. Client should provide per RPC credentials: set authorization key to metadata with value `apikey <KEY>`.

func RegisterGRPCServerAPI

func RegisterGRPCServerAPI(n *centrifuge.Node, apiExecutor *Executor, server *grpc.Server, config GRPCAPIServiceConfig) error

RegisterGRPCServerAPI registers GRPC API service in provided GRPC server.

Types

type Config

type Config struct {
	UseOpenTelemetry      bool
	UseTransportErrorMode bool
}

Config configures Handler.

type ConsumingHandler added in v5.2.0

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

ConsumingHandler is responsible for processing API commands from asynchronous consumers.

func NewConsumingHandler added in v5.2.0

func NewConsumingHandler(n *centrifuge.Node, apiExecutor *Executor, c ConsumingHandlerConfig) *ConsumingHandler

NewConsumingHandler creates new ConsumingHandler.

func (*ConsumingHandler) Dispatch added in v5.2.0

func (h *ConsumingHandler) Dispatch(ctx context.Context, method string, payload []byte) error

Dispatch processes commands received from asynchronous consumers.

type ConsumingHandlerConfig added in v5.2.0

type ConsumingHandlerConfig struct {
	UseOpenTelemetry bool
}

ConsumingHandlerConfig configures ConsumingHandler.

type Executor

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

Executor can run API methods.

func NewExecutor

func NewExecutor(n *centrifuge.Node, ruleContainer *rule.Container, surveyCaller SurveyCaller, config ExecutorConfig) *Executor

NewExecutor ...

func (*Executor) Batch

func (h *Executor) Batch(ctx context.Context, req *BatchRequest) *BatchResponse

func (*Executor) Broadcast

func (h *Executor) Broadcast(ctx context.Context, cmd *BroadcastRequest) *BroadcastResponse

Broadcast publishes the same data into many channels.

func (*Executor) Channels

func (h *Executor) Channels(ctx context.Context, cmd *ChannelsRequest) *ChannelsResponse

Channels in the system.

func (*Executor) Disconnect

func (h *Executor) Disconnect(_ context.Context, cmd *DisconnectRequest) *DisconnectResponse

Disconnect disconnects user by its ID and sends disconnect control message to other nodes, so they could also disconnect user.

func (*Executor) History

func (h *Executor) History(_ context.Context, cmd *HistoryRequest) *HistoryResponse

History returns response with history information for channel.

func (*Executor) HistoryRemove

func (h *Executor) HistoryRemove(_ context.Context, cmd *HistoryRemoveRequest) *HistoryRemoveResponse

HistoryRemove removes all history information for channel.

func (*Executor) Info

func (h *Executor) Info(_ context.Context, _ *InfoRequest) *InfoResponse

Info returns information about running nodes.

func (*Executor) Presence

func (h *Executor) Presence(_ context.Context, cmd *PresenceRequest) *PresenceResponse

Presence returns response with presence information for channel.

func (*Executor) PresenceStats

func (h *Executor) PresenceStats(_ context.Context, cmd *PresenceStatsRequest) *PresenceStatsResponse

PresenceStats returns response with presence stats information for channel.

func (*Executor) Publish

func (h *Executor) Publish(ctx context.Context, cmd *PublishRequest) *PublishResponse

Publish publishes data into channel.

func (*Executor) RPC

func (h *Executor) RPC(ctx context.Context, cmd *RPCRequest) *RPCResponse

RPC can call arbitrary methods.

func (*Executor) Refresh

func (h *Executor) Refresh(_ context.Context, cmd *RefreshRequest) *RefreshResponse

Refresh user connection by its ID.

func (*Executor) SetRPCExtension

func (h *Executor) SetRPCExtension(method string, handler RPCHandler)

SetRPCExtension ...

func (*Executor) Subscribe

func (h *Executor) Subscribe(_ context.Context, cmd *SubscribeRequest) *SubscribeResponse

Subscribe subscribes user to a channel and sends subscribe control message to other nodes, so they could also subscribe user.

func (*Executor) Unsubscribe

func (h *Executor) Unsubscribe(_ context.Context, cmd *UnsubscribeRequest) *UnsubscribeResponse

Unsubscribe unsubscribes user from channel and sends unsubscribe control message to other nodes, so they could also unsubscribe user.

type ExecutorConfig added in v5.2.0

type ExecutorConfig struct {
	Protocol         string
	UseOpenTelemetry bool
}

type GRPCAPIServiceConfig

type GRPCAPIServiceConfig struct {
	UseOpenTelemetry      bool
	UseTransportErrorMode bool
}

GRPCAPIServiceConfig for GRPC API Service.

type Handler

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

Handler is responsible for processing API commands over HTTP.

func NewHandler

func NewHandler(n *centrifuge.Node, apiExecutor *Executor, c Config) *Handler

NewHandler creates new Handler.

func (*Handler) OldRoute

func (s *Handler) OldRoute() http.HandlerFunc

OldRoute handles all methods inside one /api handler. The plan is to remove it in Centrifugo v6.

func (*Handler) Routes

func (s *Handler) Routes() map[string]http.HandlerFunc

type RPCHandler

type RPCHandler func(ctx context.Context, params Raw) (Raw, error)

RPCHandler allows to handle custom RPC.

type SurveyCaller

type SurveyCaller interface {
	Channels(ctx context.Context, cmd *ChannelsRequest) (map[string]*ChannelInfo, error)
}

SurveyCaller can do surveys.

Jump to

Keyboard shortcuts

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