events

package
v1.18.4-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MPL-2.0 Imports: 9 Imported by: 22

Documentation

Overview

Package events provides event subscription and polling functionality.

Index

Constants

View Source
const BufferSize = 64

Variables

View Source
var (
	ErrTimeout = errors.New("timeout")
	ErrClosed  = errors.New("closed")
)

Functions

func Error

func Error(err error) *string

Error returns a string pointer suitable for JSON marshalling errors. It retains the "null on success" semantics, but ensures the error result is a string regardless of the underlying concrete error type.

Types

type BufferedSubscription

type BufferedSubscription interface {
	Since(id int, into []Event, timeout time.Duration) []Event
	Mask() EventType
}

func NewBufferedSubscription

func NewBufferedSubscription(s Subscription, size int) BufferedSubscription

type Event

type Event struct {
	// Per-subscription sequential event ID. Named "id" for backwards compatibility with the REST API
	SubscriptionID int `json:"id"`
	// Global ID of the event across all subscriptions
	GlobalID int         `json:"globalID"`
	Time     time.Time   `json:"time"`
	Type     EventType   `json:"type"`
	Data     interface{} `json:"data"`
}

type EventType

type EventType int64
const (
	Starting EventType = 1 << iota
	StartupComplete
	DeviceDiscovered
	DeviceConnected
	DeviceDisconnected
	DeviceRejected // DEPRECATED, superseded by PendingDevicesChanged
	PendingDevicesChanged
	DevicePaused
	DeviceResumed
	LocalChangeDetected
	RemoteChangeDetected
	LocalIndexUpdated
	RemoteIndexUpdated
	ItemStarted
	ItemFinished
	StateChanged
	FolderRejected // DEPRECATED, superseded by PendingFoldersChanged
	PendingFoldersChanged
	ConfigSaved
	DownloadProgress
	RemoteDownloadProgress
	FolderSummary
	FolderCompletion
	FolderErrors
	FolderScanProgress
	FolderPaused
	FolderResumed
	FolderWatchStateChanged
	ListenAddressesChanged
	LoginAttempt
	Failure

	AllEvents = (1 << iota) - 1
)

func UnmarshalEventType added in v0.14.28

func UnmarshalEventType(s string) EventType

func (EventType) MarshalText

func (t EventType) MarshalText() ([]byte, error)

func (EventType) String

func (t EventType) String() string

func (*EventType) UnmarshalJSON added in v0.14.42

func (t *EventType) UnmarshalJSON(b []byte) error

type Logger

type Logger interface {
	suture.Service
	Log(t EventType, data interface{})
	Subscribe(mask EventType) Subscription
}
var NoopLogger Logger = &noopLogger{}

func NewLogger

func NewLogger() Logger

type Subscription

type Subscription interface {
	C() <-chan Event
	Poll(timeout time.Duration) (Event, error)
	Mask() EventType
	Unsubscribe()
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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