Documentation ¶
Index ¶
- Constants
- Variables
- func Dcritical(message string, fields map[string]string) *api.Diagnostic
- func Ddebug(message string, fields map[string]string) *api.Diagnostic
- func Delete(obj Object) error
- func DeleteObjects(objs []Object) error
- func Derror(message string, fields map[string]string) *api.Diagnostic
- func DeviceExists(id string) (bool, error)
- func Dinfo(message string, fields map[string]string) *api.Diagnostic
- func Dtrace(message string, fields map[string]string) *api.Diagnostic
- func Dwarning(message string, fields map[string]string) *api.Diagnostic
- func ErrToDiag(err error) *api.Diagnostic
- func Error(message string) error
- func ErrorE(message string, err error) error
- func ErrorEF(message string, err error, fields log.Fields) error
- func ErrorF(message string, fields log.Fields) error
- func EtcdConnect() (*etcd.Client, error)
- func ForwardAssetRequest(op Op, rq *api.AssetRequest) (*api.AssetResponse, error)
- func ForwardIncomingRequest(rq *api.IncomingRequest) error
- func ForwardMzRequest(op Op, rq *api.MzRequest) (*api.MzResponse, error)
- func ForwardStatusRequest(rq *api.StatusRequest) (*api.StatusResponse, error)
- func Health() *api.HealthResponse
- func InitLogging()
- func InsertDevice(driver, id string) error
- func InsertDriver(name, host string, port int) error
- func IsTxnFailed(err error) bool
- func LoadConfig()
- func NewDiag(code int, format string, args ...interface{}) *api.Diagnostic
- func Read(obj Object) error
- func ReadNew(obj Object) error
- func ReadObjects(objs []Object) (int, error)
- func Register(rq *api.RegisterRequest) error
- func RemoveDevices(devices []string) error
- func RunObjectTx(otx ObjectTx) error
- func TxnFailed(message string) error
- func Unregister(rq *api.UnregisterRequest) error
- func Write(obj Object, opts ...etcd.OpOption) error
- func WriteObjects(objs []Object, opts ...etcd.OpOption) error
- type Config
- type DeviceInfo
- type DriverInfo
- type ElasticConfig
- type Object
- type ObjectTx
- type Op
Constants ¶
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 )
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 )
const (
//TxnFailedPrefix see mergetb/stor
TxnFailedPrefix = "txn failed"
)
Variables ¶
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)") )
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound object in data store
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 Derror ¶
func Derror(message string, fields map[string]string) *api.Diagnostic
Derror produces an error message with the provided message and fields
func DeviceExists ¶
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 ¶
Error Encapsulate err in a structured log and return an abstracted high-level error with message as the payload
func ErrorE ¶
ErrorE Encapsulate err in a structured log and return an abstracted high-level error with message as the payload
func ErrorEF ¶
ErrorEF Encapsulate fields and err in a structured log and return an abstracted high-level error with message as the payload
func ErrorF ¶
ErrorF Encapsulate fields in a structured log and return an abstracted high-level error with message as the payload
func EtcdConnect ¶
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 ¶
ForwardMzRequest to drivers
func ForwardStatusRequest ¶ added in v0.1.2
func ForwardStatusRequest(rq *api.StatusRequest) (*api.StatusResponse, error)
ForwardStatusRequest forwards request to drivers
func InsertDevice ¶
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 ¶
InsertDriver insert top level driver information
func NewDiag ¶
func NewDiag(code int, format string, args ...interface{}) *api.Diagnostic
NewDiag creates a new Diagnostic struct
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 ¶
RemoveDevices removes a set of devices from a site TODO: mechanism to check that the device is authorized to remove specified key
func Unregister ¶
func Unregister(rq *api.UnregisterRequest) error
Unregister a set of devices (from driver) with commander
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
type DeviceInfo ¶
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 ¶
ElasticConfig host,port tuple