notification

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coalescer

type Coalescer interface {
	io.WriterTo

	// Coalescer must return itself on error (not nil!)
	Coalesce(io.WriterTo) (Coalescer, error)
}

Coalescer allows event to be merged together to prevent sending too many events in a short time.

type Manager

type Manager[Key comparable] struct {
	// If a connection is active, events will not be sent (to prevent corruption).
	// EventBuffer indicates the number of events to buffer (per connection),
	// which will be delivered when the connection is back to idle.
	EventBuffer int

	// CoalesceDuration will prevent too many events from being delivered after another.
	// Standard recommands 1s
	CoalesceDuration time.Duration
	Logger           log.Logger
	// contains filtered or unexported fields
}

Manager manages notifications. m.ConnContext & m.ConnState must be registered on the http.Server respective fields.

func (*Manager[Key]) ConnContext

func (m *Manager[Key]) ConnContext(ctx context.Context, c net.Conn) context.Context

func (*Manager[Key]) ConnState

func (m *Manager[Key]) ConnState(c net.Conn, s http.ConnState)

func (*Manager[Key]) HookConnEvents

func (m *Manager[Key]) HookConnEvents(server *http.Server)

func (*Manager[Key]) IsSubscribed

func (m *Manager[Key]) IsSubscribed(ctx context.Context, id Key) (bool, error)

func (*Manager[Key]) Publish

func (m *Manager[Key]) Publish(ctx context.Context, id Key, event io.WriterTo)

Publish an event. If the event is a Coalescer it might be throtteled.

func (*Manager[Key]) Subscribe

func (m *Manager[Key]) Subscribe(ctx context.Context, id Key, v bool) error

Jump to

Keyboard shortcuts

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