stream

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletionHook

type CompletionHook func(summary SessionSummary, events []*Event)

type Config

type Config struct {
	BufferSize     int
	ListenerBuffer int
	DropPolicy     DropPolicy
}

type Direction

type Direction int
const (
	DirNA Direction = iota
	DirSend
	DirReceive
)

type DropPolicy

type DropPolicy int
const (
	DropNewest DropPolicy = iota
	DropOldest
	DropListener
)

type Event

type Event struct {
	Kind      Kind
	Direction Direction
	Timestamp time.Time
	Sequence  uint64

	Metadata map[string]string
	Payload  []byte

	SSE SSEMetadata
	WS  WSMetadata
}

type Kind

type Kind int
const (
	KindSSE Kind = iota
	KindWebSocket
)

type Listener

type Listener struct {
	C        <-chan *Event
	Cancel   func()
	Snapshot Snapshot
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) AddCompletionHook

func (m *Manager) AddCompletionHook(id string, hook CompletionHook) bool

func (*Manager) Cancel

func (m *Manager) Cancel(id string) bool

func (*Manager) Get

func (m *Manager) Get(id string) (SessionSummary, bool)

func (*Manager) List

func (m *Manager) List() []SessionSummary

func (*Manager) Register

func (m *Manager) Register(session *Session) SessionSummary

func (*Manager) Snapshot

func (m *Manager) Snapshot(id string) ([]*Event, bool)

type SSEMetadata

type SSEMetadata struct {
	Name    string
	ID      string
	Comment string
	Retry   int
}

type Session

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

func NewSession

func NewSession(parent context.Context, kind Kind, cfg Config) *Session

func (*Session) Cancel

func (s *Session) Cancel()

func (*Session) Close

func (s *Session) Close(err error)

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) Done

func (s *Session) Done() <-chan struct{}

func (*Session) Err

func (s *Session) Err() error

func (*Session) EventsSnapshot

func (s *Session) EventsSnapshot() []*Event

func (*Session) ID

func (s *Session) ID() string

func (*Session) Kind

func (s *Session) Kind() Kind

func (*Session) MarkClosing

func (s *Session) MarkClosing()

func (*Session) MarkOpen

func (s *Session) MarkOpen()

func (*Session) Publish

func (s *Session) Publish(evt *Event)

func (*Session) State

func (s *Session) State() (State, error)

func (*Session) StatsSnapshot

func (s *Session) StatsSnapshot() Stats

func (*Session) Subscribe

func (s *Session) Subscribe() Listener

type SessionSummary

type SessionSummary struct {
	ID        string
	Kind      Kind
	State     State
	Err       error
	StartedAt time.Time
	EndedAt   time.Time
}

type Snapshot

type Snapshot struct {
	Events []*Event
	State  State
	Err    error
}

type State

type State int
const (
	StateConnecting State = iota
	StateOpen
	StateClosing
	StateClosed
	StateFailed
)

type Stats

type Stats struct {
	StartedAt   time.Time
	EndedAt     time.Time
	EventsTotal uint64
	BytesTotal  uint64
	Dropped     uint64
}

type WSMetadata

type WSMetadata struct {
	Opcode int
	Code   websocket.StatusCode
	Reason string
}

Jump to

Keyboard shortcuts

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