polling

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp int64
	Data      interface{}
	Id        uuid.UUID
}

Event implements a single event inserted into queue

type PollingConfig

type PollingConfig struct {
	// MaxBufferSize defines the maximum number of events
	// per subscription before the oldest events are expired.
	MaxBufferSize int
	// DeleteEventAfterRetrieval defines if the event should be
	// deleted after it is retreived.
	DeleteAfter bool
}

PollingConfig is used to configure the polling manager

type PollingServer

type PollingServer struct {
	Config *PollingConfig
	// contains filtered or unexported fields
}

PollingServer contains the eventHandler and polling manager that should be passed around to each package. Once the polling server is started via Start(), a package can begin publishing messages via Publish(), or fetch all messages in the queue via GetAll()

func New

func New(cfg *PollingConfig) *PollingServer

New returns a PollingServer struct used to managed the polling server

func (*PollingServer) GetAll

func (p *PollingServer) GetAll() []*Event

GetAll returns and purges all events in the queue

func (*PollingServer) Publish

func (p *PollingServer) Publish(event interface{}) error

Publish will publish an event to the polling queue

func (*PollingServer) ReadAll

func (p *PollingServer) ReadAll() []*Event

ReadAll returns all events in the queue without purging

func (*PollingServer) Start

func (s *PollingServer) Start() *PollingServer

Start will create a new polling server and queue

func (*PollingServer) Stop

func (s *PollingServer) Stop()

Stop shuts down the polling server gracefully

Jump to

Keyboard shortcuts

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