stream

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CName = "consensus.stream"

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	// NewStream creates new stream with able to watch and unwatch log ids
	NewStream() *Stream
	app.ComponentRunnable
}

Service maintains a cache for logs (receive updates from db) and creates new stream objects with able to subscribe/unsubscribe to log ids

func New

func New() Service

type Stream

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

Stream is a buffer that receives updates from object and gives back to a client

func (*Stream) AddRecords

func (s *Stream) AddRecords(logId string, records []consensus.Record) (err error)

AddRecords adds new records to stream, called by objects

func (*Stream) Close

func (s *Stream) Close()

Close closes stream and unsubscribes all ids

func (*Stream) LogIds

func (s *Stream) LogIds() []string

LogIds returns watched log ids

func (*Stream) UnwatchIds

func (s *Stream) UnwatchIds(ctx context.Context, logIds []string)

UnwatchIds removes given ids from subscription

func (*Stream) WaitLogs

func (s *Stream) WaitLogs() []consensus.Log

WaitLogs wait for new log records empty returned slice means that stream is closed

func (*Stream) WatchIds

func (s *Stream) WatchIds(ctx context.Context, logIds []string)

WatchIds adds given ids to subscription

Jump to

Keyboard shortcuts

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