eventchannel

package
v0.0.0-...-4bf4b70 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Overview

Package eventchannel contains functionality for sending any protobuf message on a socketpair.

The wire format is a uvarint length followed by a binary protobuf.Any message.

Index

Constants

This section is empty.

Variables

View Source
var DefaultEmitter = &multiEmitter{}

DefaultEmitter is the default emitter. Calls to Emit and AddEmitter are sent to this Emitter.

Functions

func AddEmitter

func AddEmitter(e Emitter)

AddEmitter is a helper method that calls DefaultEmitter.AddEmitter.

func Emit

func Emit(msg proto.Message) error

Emit is a helper method that calls DefaultEmitter.Emit.

Types

type Emitter

type Emitter interface {
	// Emit writes a single eventchannel message to an emitter. Emit should
	// return hangup = true to indicate an emitter has "hung up" and no further
	// messages should be directed to it.
	Emit(msg proto.Message) (hangup bool, err error)

	// Close closes this emitter. Emit cannot be used after Close is called.
	Close() error
}

Emitter emits a proto message.

func DebugEmitterFrom

func DebugEmitterFrom(inner Emitter) Emitter

DebugEmitterFrom creates a new event channel emitter by wrapping an existing raw emitter.

func RateLimitedEmitterFrom

func RateLimitedEmitterFrom(inner Emitter, maxRate float64, burst int) Emitter

RateLimitedEmitterFrom creates a new event channel emitter that wraps the existing emitter and enforces rate limits. The limits are imposed via a token bucket, with `maxRate` events per second, with burst size of `burst` events. See the golang.org/x/time/rate package and https://en.wikipedia.org/wiki/Token_bucket for more information about token buckets generally.

func SocketEmitter

func SocketEmitter(fd int) (Emitter, error)

SocketEmitter creates a new event channel based on the given fd.

SocketEmitter takes ownership of fd.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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