river

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package river provides a streaming version of the Go standard library expvar. This allows monitors to be updated to only variables they are interested in and only when the variable has actually changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVars

func GetVars() []string

GetVars returns all the registered variable names.

func IDString

func IDString(id ID) (string, error)

func Publish

func Publish(name string, v expvar.Var)

Publish declares a named exported variable. This should be called from a package's init function when it creates its Vars. If the name is already registered then this will log.Panic. Publishing a Func will call the Func() once to verify its output.

func RegisterMonitor

func RegisterMonitor(ctx context.Context, dest string, t transport.RiverTransport) error

RegisterMonitor connects to a river monitor. This will return an error if we cannot connect. Connecting will only be attempted for the lifetime of ctx (by default this is infinity).

func RemoveMonitor

func RemoveMonitor(dest string)

RemoveMonitor removes all monitors

func SetID

func SetID(id ID)

SetID sets the service's identifier to the monitors. This must be unique to your monitors or they will reject the conneciton attempts. Must be set before calling Publish() or RegisterMonitor(). Calling this twice will panic.

Types

type Float

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

Float is a 64-bit float variable that satisfies the Var interface.

func MakeFloat

func MakeFloat(f float64) Float

MakeFloat creates a new Float, but does not call Publish() like NewFloat().

func NewFloat

func NewFloat(name string) Float

NewFloat makes a new Float and calls Publish(name, Float) with it.

func (Float) Add

func (v Float) Add(delta float64)

Add adds delta to v.

func (Float) Set

func (v Float) Set(value float64)

Set sets v to value.

func (Float) String

func (v Float) String() string

func (Float) Value

func (v Float) Value() float64

type ID

type ID interface {
	// Attributes returns a list of field/value pairs that are used to make up
	// an ID.  A string version of this IDAttr will be output using this order
	// with just the values separated by ":".  ":"'s a'
	Attributes() []IDAttr
}

ID provides an ID for the application instance, which must be unique between apps talking to a monitor.

type IDAttr

type IDAttr struct {
	// Field is the name of the field.
	Field string
	// Value is the string value of the field.
	Value string
}

IDAttr is an attribute used to make up an ID.

type Int

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

Int is a 64-bit integer variable that satisfies the Var interface.

func MakeInt

func MakeInt(i int64) Int

MakeInt is creates a new Int, but does not call Publish() like NewInt().

func NewInt

func NewInt(name string) Int

NewInt creates a new Int and calls Publish(name, Int).

func (Int) Add

func (v Int) Add(delta int64)

func (Int) Set

func (v Int) Set(value int64)

func (Int) String

func (v Int) String() string

func (Int) Value

func (v Int) Value() int64

type Map

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

Map is a string-to-Var map variable that satisfies the Var interface.

func MakeMap

func MakeMap() *Map

MakeMap creates a new *Map, but does not call Publish() like NewMap().

func NewMap

func NewMap(name string) *Map

NewMap is the constructor for Map.

func (*Map) Add

func (v *Map) Add(key string, delta int64)

func (*Map) AddFloat

func (v *Map) AddFloat(key string, delta float64)

AddFloat adds delta to the *Float value stored under the given map key.

func (*Map) Do

func (v *Map) Do(f func(expvar.KeyValue))

Do calls f for each entry in the map. The map is locked during the iteration, but existing entries may be concurrently updated.

func (*Map) Get

func (v *Map) Get(key string) expvar.Var

func (*Map) Init

func (v *Map) Init() *Map

Init is a no-op and is included here only for compatibility.

func (*Map) Set

func (v *Map) Set(key string, av Var)

func (*Map) String

func (v *Map) String() string

type String

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

String is a string variable, and satisfies the Var interface.

func MakeString

func MakeString(s string) String

func NewString

func NewString(name string) String

NewString is the constructor for String.

func (String) Set

func (v String) Set(value string)

func (String) String

func (v String) String() string

String implements the Val interface. To get the unquoted string use Value.

func (String) Value

func (v String) Value() string

type Var

type Var interface {
	// String returns a valid JSON value for the variable.
	// Types with String methods that do not return valid JSON
	// (such as time.Time) must not be used as a Var.
	String() string
	// contains filtered or unexported methods
}

Var is an abstract type for all exported variables.

Directories

Path Synopsis
actions
Package actions provides boutique.Actions to signal modifications to the store.
Package actions provides boutique.Actions to signal modifications to the store.
data
Package data provides state data for boutique stores.
Package data provides state data for boutique stores.
modifiers
Package modifiers provides modifiers for all boutique.Store changes.
Package modifiers provides modifiers for all boutique.Store changes.

Jump to

Keyboard shortcuts

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