subscription

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotificationsUnsupported is returned when the connection doesn't support notifications
	ErrNotificationsUnsupported = errors.New("notifications not supported")
	// ErrNotificationNotFound is returned when the notification for the given id is not found
	ErrSubscriptionNotFound = errors.New("subscription not found")
	// ErrNotificationNotFound is returned when the notification for the given id is not found
	ErrSubscriptionClosed = errors.New("subscription not found")
)

Functions

func SetServiceMethodSeparator added in v0.2.17

func SetServiceMethodSeparator(val string)

Types

type ClientSubscription

type ClientSubscription interface {
	Err() <-chan error
	Unsubscribe() error
	String() string
}

type Conn

type Conn interface {
	Subscribe(ctx context.Context, namespace string, channel any, args any) (ClientSubscription, error)

	jsonrpc.Conn
}

func UpgradeConn

func UpgradeConn(c jsonrpc.Conn, err error) (Conn, error)

type Engine

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

func NewEngine

func NewEngine() *Engine

func (*Engine) Middleware

func (e *Engine) Middleware() func(jsonrpc.Handler) jsonrpc.Handler

type Notifier

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

Notifier is tied to a RPC connection that supports subscriptions. Server callbacks use the notifier to send notifications.

func NotifierFromContext

func NotifierFromContext(ctx context.Context) (*Notifier, bool)

NotifierFromContext returns the Notifier value stored in ctx, if any.

func (*Notifier) Err

func (n *Notifier) Err() <-chan error

func (*Notifier) Notify

func (n *Notifier) Notify(data any) error

Notify sends a notification to the client with the given data as payload. If an error occurs the RPC connection is closed and the error is returned.

type SubID

type SubID string

func NewID

func NewID() SubID

NewID returns a new, random ID.

type WrapClient

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

func NewWrapClient

func NewWrapClient(conn jsonrpc.Conn) *WrapClient

func (*WrapClient) Close

func (c *WrapClient) Close() error

func (*WrapClient) Closed

func (w *WrapClient) Closed() <-chan struct{}

func (*WrapClient) Do

func (c *WrapClient) Do(ctx context.Context, result any, method string, params any) error

func (*WrapClient) Middleware

func (c *WrapClient) Middleware(h jsonrpc.Handler) jsonrpc.Handler

func (*WrapClient) Mount

func (c *WrapClient) Mount(m jsonrpc.Middleware)

func (*WrapClient) Notify

func (c *WrapClient) Notify(ctx context.Context, method string, params any) error

func (*WrapClient) Subscribe

func (c *WrapClient) Subscribe(ctx context.Context, namespace string, channel any, args any) (ClientSubscription, error)

Jump to

Keyboard shortcuts

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