subscription

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SubscriptionBufferSize = 8

SubscriptionBufferSize is the buffer size of the subscription channel. It is used to prevent blocking the client dispatcher when the client is slow to consume values.

Functions

This section is empty.

Types

type ClientSubscription

type ClientSubscription[T any] struct {
	// contains filtered or unexported fields
}

ClientSubscription is a subscription that can be used by the client to unsubscribe from the subscription.

func (*ClientSubscription[T]) Done

func (c *ClientSubscription[T]) Done() <-chan struct{}

Done returns the done channel of the subscription

func (*ClientSubscription[T]) Err

func (c *ClientSubscription[T]) Err() <-chan error

Err returns the error channel of the subscription.

func (*ClientSubscription[T]) IsClosed

func (c *ClientSubscription[T]) IsClosed() bool

IsClosed returns status of the subscription

func (*ClientSubscription[T]) Unsubscribe

func (c *ClientSubscription[T]) Unsubscribe()

func (*ClientSubscription[T]) UnsubscribeWithContext

func (c *ClientSubscription[T]) UnsubscribeWithContext(ctx context.Context) (err error)

type Subscription

type Subscription[T any] struct {
	// contains filtered or unexported fields
}

Subscription is a subscription to a stream of values from the client dispatcher. It has two channels: one for values, and one for errors.

func NewSubscription

func NewSubscription[T any](channel chan<- T) *Subscription[T]

func (*Subscription[T]) Client

func (s *Subscription[T]) Client() *ClientSubscription[T]

Client returns a client subscription for this subscription.

func (*Subscription[T]) Done

func (s *Subscription[T]) Done() <-chan struct{}

Done returns the done channel of the subscription

func (*Subscription[T]) Err

func (s *Subscription[T]) Err() <-chan error

Err returns the error channel of the subscription.

func (*Subscription[T]) IsClosed

func (s *Subscription[T]) IsClosed() bool

IsClosed returns status of the subscription

func (*Subscription[T]) Send

func (s *Subscription[T]) Send(ctx context.Context, value T) error

Send sends a value to the subscription channel. If the subscription is closed, it returns an error.

func (*Subscription[T]) SendError

func (s *Subscription[T]) SendError(ctx context.Context, err error) error

SendError sends an error to the subscription error channel. If the subscription is closed, it returns an error.

func (*Subscription[T]) Unsubscribe

func (s *Subscription[T]) Unsubscribe()

func (*Subscription[T]) UnsubscribeWithContext

func (s *Subscription[T]) UnsubscribeWithContext(ctx context.Context) (err error)

Jump to

Keyboard shortcuts

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