site

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DTrace Diagnostic Trace
	DTrace = api.Diagnostic_Trace
	// DDebug Diagnostic Debug
	DDebug = api.Diagnostic_Debug
	// DInfo Diagnostic Info
	DInfo = api.Diagnostic_Info
	// DWarn Diagnostic Warn
	DWarn = api.Diagnostic_Warn
	// DError Diagnostic Error
	DError = api.Diagnostic_Error
	// DCritical Diagnostic Critical
	DCritical = api.Diagnostic_Critical
)
View Source
const (
	OpIncoming               Op = 0
	OpStatus                    = 1
	OpSetup                     = 2
	OpRecycle                   = 3
	OpConfigure                 = 4
	OpReset                     = 5
	OpRestart                   = 6
	OpOn                        = 7
	OpOff                       = 8
	OpCreate                    = 9
	OpDestroy                   = 10
	OpModify                    = 11
	OpConnect                   = 12
	OpDisconnect                = 13
	OpAssetCreateVolume         = 14
	OpAssetDestroyVolume        = 15
	OpAssetModifyVolume         = 16
	OpAssetCreateImage          = 17
	OpAssetDestroyImage         = 18
	OpAssetCreateSiteVolume     = 19
	OpAssetDestroySiteVolume    = 20
	OpAssetModifySiteVolume     = 21
)
View Source
const (
	//TxnFailedPrefix see mergetb/stor
	TxnFailedPrefix = "txn failed"
)

Variables

View Source
var (
	DbPort        = flag.Int("dbport", 2399, "etcd port")
	DbHost        = flag.String("dbhost", "localhost", "etcd host")
	EtcdTimeout   = flag.Int("etcd-timeout", 100, "request timeout (ms)")
	DriverTimeout = flag.Int("driver-timeout", 100, "request timeout (s)")
)
View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound object in data store

View Source
var (
	// Version of the site api
	Version = "undefined"
)

Functions

func Dcritical

func Dcritical(message string, fields map[string]string) *api.Diagnostic

Dcritical produces a critical message with the provided message and fields

func Ddebug

func Ddebug(message string, fields map[string]string) *api.Diagnostic

Ddebug produces a debug message with the provided message and fields

func Delete

func Delete(obj Object) error

Delete see mergetb/stor

func DeleteObjects

func DeleteObjects(objs []Object) error

DeleteObjects see mergetb/stor

func Derror

func Derror(message string, fields map[string]string) *api.Diagnostic

Derror produces an error message with the provided message and fields

func DeviceExists

func DeviceExists(id string) (bool, error)

DeviceExists checks if a device exists given an id

func Dinfo

func Dinfo(message string, fields map[string]string) *api.Diagnostic

Dinfo produces an info message with the provided message and fields

func Dtrace

func Dtrace(message string, fields map[string]string) *api.Diagnostic

Dtrace produces a trace message with the provided message and fields

func Dwarning

func Dwarning(message string, fields map[string]string) *api.Diagnostic

Dwarning produces a warning message with the provided message and fields

func ErrToDiag

func ErrToDiag(err error) *api.Diagnostic

ErrToDiag add error message to diagnostics

func Error

func Error(message string) error

Error Encapsulate err in a structured log and return an abstracted high-level error with message as the payload

func ErrorE

func ErrorE(message string, err error) error

ErrorE Encapsulate err in a structured log and return an abstracted high-level error with message as the payload

func ErrorEF

func ErrorEF(message string, err error, fields log.Fields) error

ErrorEF Encapsulate fields and err in a structured log and return an abstracted high-level error with message as the payload

func ErrorF

func ErrorF(message string, fields log.Fields) error

ErrorF Encapsulate fields in a structured log and return an abstracted high-level error with message as the payload

func EtcdConnect

func EtcdConnect() (*etcd.Client, error)

EtcdConnect Try up to 10 times to connect to etcd

func ForwardAssetRequest added in v0.2.0

func ForwardAssetRequest(op Op, rq *api.AssetRequest) (*api.AssetResponse, error)

ForwardAssetRequest to drivers responsible for handling request

func ForwardIncomingRequest

func ForwardIncomingRequest(rq *api.IncomingRequest) error

ForwardIncomingRequest to drivers

func ForwardMzRequest

func ForwardMzRequest(op Op, rq *api.MzRequest) (*api.MzResponse, error)

ForwardMzRequest to drivers

func ForwardStatusRequest added in v0.1.2

func ForwardStatusRequest(rq *api.StatusRequest) (*api.StatusResponse, error)

ForwardStatusRequest forwards request to drivers

func Health

func Health() *api.HealthResponse

Health checks and returns the health of the drivers

func InitLogging

func InitLogging()

InitLogging sets the initial log level to Debug

func InsertDevice

func InsertDevice(driver, id string) error

InsertDevice insert top level device information TODO authentication on who can insert where, two drivers named "A" shouldnt happen but how do we handle it if they do, how do we know which is the first to register and which is the second?

func InsertDriver

func InsertDriver(name, host string, port int) error

InsertDriver insert top level driver information

func IsTxnFailed

func IsTxnFailed(err error) bool

IsTxnFailed see mergetb/stor

func LoadConfig

func LoadConfig()

LoadConfig reads in merge.yml into the global config

func NewDiag

func NewDiag(code int, format string, args ...interface{}) *api.Diagnostic

NewDiag creates a new Diagnostic struct

func Read

func Read(obj Object) error

Read see mergetb/stor

func ReadNew

func ReadNew(obj Object) error

ReadNew see mergetb/stor

func ReadObjects

func ReadObjects(objs []Object) (int, error)

ReadObjects see mergetb/stor

func Register

func Register(rq *api.RegisterRequest) error

Register a set of devices with a driver to the commander TODO: before commander responds, it should do lookup to prevent reflected spoofs

func RemoveDevices

func RemoveDevices(devices []string) error

RemoveDevices removes a set of devices from a site TODO: mechanism to check that the device is authorized to remove specified key

func RunObjectTx

func RunObjectTx(otx ObjectTx) error

RunObjectTx see mergetb/stor

func TxnFailed

func TxnFailed(message string) error

TxnFailed see mergetb/stor

func Unregister

func Unregister(rq *api.UnregisterRequest) error

Unregister a set of devices (from driver) with commander

func Write

func Write(obj Object, opts ...etcd.OpOption) error

Write see mergetb/stor

func WriteObjects

func WriteObjects(objs []Object, opts ...etcd.OpOption) error

WriteObjects see mergetb/stor

Types

type Config

type Config struct {
	//Optional - When present the commander will send logs to elasticsearch
	Elasticsearch *ElasticConfig
}

Config is a wrapper for Elastic(Search)Config

func GetConfig

func GetConfig() Config

GetConfig returns the global config (ElasticConfig)

type DeviceInfo

type DeviceInfo struct {
	ID     string
	Driver string
	// contains filtered or unexported fields
}

DeviceInfo stores the driver and id of a device

func (*DeviceInfo) GetVersion

func (d *DeviceInfo) GetVersion() int64

GetVersion returns version from device info

func (*DeviceInfo) Key

func (d *DeviceInfo) Key() string

Key the etcd key used to prefix device info

func (*DeviceInfo) SetVersion

func (d *DeviceInfo) SetVersion(v int64)

SetVersion stors version to device info

func (*DeviceInfo) Value

func (d *DeviceInfo) Value() interface{}

Value returns the device info struct

type DriverInfo

type DriverInfo struct {
	Name string
	Host string
	Port int
	// contains filtered or unexported fields
}

DriverInfo struct container connection info for a driver

func (*DriverInfo) Endpoint

func (d *DriverInfo) Endpoint() string

Endpoint returns the host:port string of the driver info

func (*DriverInfo) GetVersion

func (d *DriverInfo) GetVersion() int64

GetVersion returns version from driver info

func (*DriverInfo) Key

func (d *DriverInfo) Key() string

Key the etcd key used to prefix driver info

func (*DriverInfo) SetVersion

func (d *DriverInfo) SetVersion(v int64)

SetVersion stors version to driver info

func (*DriverInfo) Value

func (d *DriverInfo) Value() interface{}

Value returns the driver info struct

type ElasticConfig

type ElasticConfig struct {
	Host string
	Port int
}

ElasticConfig host,port tuple

type Object

type Object interface {
	Key() string
	GetVersion() int64
	SetVersion(int64)
	Value() interface{}
}

Object all obejcts that go to and fro from the database implement this interface

type ObjectTx

type ObjectTx struct {
	Put    []Object
	Delete []Object
}

ObjectTx see mergetb/stor

type Op

type Op int

Op is the operation

func (Op) String

func (op Op) String() string

Jump to

Keyboard shortcuts

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