transport

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: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Drop

type Drop struct {
	// Name is the name of the variable to drop.
	Name string
}

Drop describes a moniors attempt to drop a variable.

func (Drop) Validate

func (d Drop) Validate() error

Validate validates that the Drop contains data within constraints.

type IdentityVar

type IdentityVar struct {
	// ID is an identity for an application instance talking to a monitor.
	ID string
	// Var is the variable sent to the monitor from the Identity.
	Var Var
}

IdentityVar is a variable sent from an Identity.

type MonitorTransport

type MonitorTransport interface {
	// Listen allows for the transport to start listening for connections.
	Listen(hostPort string) error
	// Subscribe subscribes the monitor to start receiving a variable.
	Subscribe(id string, v string) error
	// Drop drops s variable from being monitored.
	Drop(id string, vars string) error
	// Receive a variable that has changed from a river instance.
	Receive() <-chan IdentityVar
	// Close closes the Transport's connection.
	Close()
}

MonitorTransport is implemented by a monitor to be able to receive data from a river application.

type OpType

type OpType int

OpType is the type of operation we are attempting to do.

const (
	// UnknownOp indicates we don't know what type of Operation this is.
	// This is always a bug.
	UnknownOp OpType = 0
	// SubscribeOp indicates we are trying to subscribe to certain variables.
	SubscribeOp OpType = 1
	// DropOp indicates we are trying to remove certain variables from
	// monitoring.
	DropOp OpType = 2
)

func (OpType) IsOpType

func (OpType) IsOpType()

IsOpType is used to indicate this type is Optype.

type Operation

type Operation struct {
	// Type is the operation type that is happening.
	Type OpType

	// Subscribe contains data if the Type === SubscribeOp.
	Subscribe Subscribe

	// Drop contains data if the Type == DropOp.
	Drop Drop

	// Response is the response to this operation. If it its nil, then it
	// succeeded. Otherwise there was a failure.
	Response chan error
}

Operation is an instruction from the monitor to a river application.

func (Operation) Validate

func (o Operation) Validate() error

Validate validates the operation has the correct attributes et.

type RiverTransport

type RiverTransport interface {
	// Connect connects to the remote monitor.
	Connect() error
	// Receive returns a channel that we read Operations from.
	Receive() <-chan Operation
	// Send sends a variable to the monitor.
	Send(v data.VarState) error
	// Close closes the Transport's connection.
	Close()
}

RiverTransport is used to implement a client for talking to a monitor over some type of underlying transport (websocket, grpc, etc). All methods must be type safe.

type Source

type Source struct {
	// App is the name of the application, as reported by the sender.
	// This may not be empty.  It may not contain ":".
	App string
	// Shard is a collection of applications sharing some type of relationship.
	// Maybe a kubernetes pod or other construct.  This may not contain ":".
	// This may be empty.
	Shard string
	// IP is the IP address that the river instance is connected from.
	IP net.IP
	// Port is the port that the river instance connected from.
	Port int32
	// Instance is a particular instance of an app on a IP:Port combination, to
	// distiguish the app from other instances. This can be empty.
	Instance int32
}

Source is the river app that is connecting to a monitor.

func (Source) String

func (s Source) String() string

String implements Stringer. You should not rely on this for tests as this format can change.

func (Source) Validate

func (s Source) Validate() error

Validate validates the Source.

type Subscribe

type Subscribe struct {
	// Name is the name of the variable to subscribe to.
	Name string
	// Interval is the minimum time between updates.
	Interval time.Duration
}

Subscribe describes a monitors attempt to subscribe to a variable.

func (Subscribe) Validate

func (s Subscribe) Validate() error

Validate validates that the Subscribe contains data within constraints.

type Var

type Var struct {
	// Name is the name of the variable.
	Name string
	// Source is the source of the variable.
	Source Source
	// Type is the type of variable.
	Type VarType
	// Int is an int64.
	Int int64
	// Float is a float64.
	Float float64
	// String is a string.
	String string
}

Var is a monitored variable that is transported from a river instance to a monitor.

type VarType

type VarType int

VarType indicates the type of variable that is being stored.

const (
	// UnknownVar indicates that the program is broken if this is seen.
	UnknownVar VarType = 0
	// IntVar indicates we storing an int64.
	IntVar VarType = 1
	// FloatVar indicates we are storign a float64.
	FloatVar VarType = 2
	// StringVar indicates we are storing a string.
	StringVar VarType = 3
)

func (VarType) IsVarType

func (VarType) IsVarType()

IsVarType indicates that this is a VarType.

Jump to

Keyboard shortcuts

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