protogw

package
v0.0.0-...-3faac0c Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 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 Component

type Component struct {
	ID   uuid.UUID `yaml:"id" json:"id"`
	Name string    `yaml:"name" json:"name"`
}

Component is a generic object

func (*Component) GwKey

func (c *Component) GwKey() string

func (*Component) GwPrefix

func (c *Component) GwPrefix() string

func (*Component) MkKey

func (c *Component) MkKey(id string) string

type GatewayObj

type GatewayObj interface {
	GwPrefix() string // return the gateway scoped prefix of the object class
	GwKey() string    // return the storage key for the object
}

type GaugeState

type GaugeState struct {
	OwnerID     uuid.UUID `yaml:"owner-id" json:"owner-id"`
	Description string    `yaml:"description" json:"description"`
	Value       int       `yaml:"value" json:"value"` // the gauge's "value"
}

GaugeState represents the value of some general measurement.

func (*GaugeState) GwKey

func (g *GaugeState) GwKey() string

func (*GaugeState) GwPrefix

func (g *GaugeState) GwPrefix() string

func (*GaugeState) MkKey

func (g *GaugeState) MkKey(id string) string

type LogRecord

type LogRecord struct {
	TimeStamp time.Time `yaml:"ts" json:"ts"`
	Sender    uuid.UUID `yaml:"sender" json:"sender"`
	Message   string    `yaml:"message" json:"message"`
}

LogRecord is a single log record

func (*LogRecord) GwKey

func (lr *LogRecord) GwKey() string

func (*LogRecord) GwPrefix

func (lr *LogRecord) GwPrefix() string

type ProtoGateway

type ProtoGateway interface {
	Close()

	SetComponent(c Component) error
	GetComponent(id uuid.UUID) (Component, error)
	GetAllComponents() ([]Component, error)

	CreateGauge(id uuid.UUID, desc string) error
	SetGauge(id uuid.UUID, val int) error
	ObserveGauge(ctx context.Context, id uuid.UUID) (<-chan GaugeState, error)

	SendLogRecord(lr LogRecord) error
	GetAllLogs() ([]LogRecord, error)
	ObserveLogs(ctx context.Context) (<-chan LogRecord, error)
}

func MakeProtoGateway

func MakeProtoGateway(gwPrefix string, kvstore kv.KV) ProtoGateway

Jump to

Keyboard shortcuts

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