Documentation ¶
Overview ¶
Package dipper is a library used for developing drivers for Honeydipper.
Index ¶
- Constants
- Variables
- func CatchError(err interface{}, handler func())
- func CombineMap(dst map[string]interface{}, src interface{}) map[string]interface{}
- func Compare(actual string, criteria interface{}) bool
- func CompareAll(actual interface{}, criteria interface{}) bool
- func CompareMap(actual interface{}, criteria interface{}) bool
- func DecryptAll(rpc *RPCCaller, from interface{})
- func DeepCopy(m interface{}) (interface{}, error)
- func DeepCopyMap(m map[string]interface{}) (map[string]interface{}, error)
- func DeserializeContent(content []byte) (ret interface{})
- func GetIP() string
- func GetLogger(module string, verbosity string, logFiles ...*os.File) *logging.Logger
- func GetMapData(from interface{}, path string) (ret interface{}, ok bool)
- func GetMapDataBool(from interface{}, path string) (ret bool, ok bool)
- func GetMapDataStr(from interface{}, path string) (ret string, ok bool)
- func IDMapDel(m IDMap, key string)
- func IDMapGet(m IDMap, key string) interface{}
- func IDMapPut(m IDMap, val interface{}) string
- func IgnoreError(expectedError interface{})
- func InitIDMap(m IDMap)
- func Interpolate(source interface{}, data interface{}) interface{}
- func InterpolateGoTemplate(pattern string, data interface{}) string
- func InterpolateStr(pattern string, data interface{}) string
- func LockCheckDeleteMap(lock *sync.Mutex, resource interface{}, key interface{}, ...) (ret interface{})
- func LockComm(out io.Writer)
- func LockGetMap(lock *sync.Mutex, resource interface{}, key interface{}) (ret interface{}, ok bool)
- func LockSetMap(lock *sync.Mutex, resource interface{}, key interface{}, val interface{}) (ret interface{})
- func MergeMap(dst map[string]interface{}, src interface{}) map[string]interface{}
- func Must(ret interface{}, err error) interface{}
- func MustDeepCopy(m interface{}) interface{}
- func MustDeepCopyMap(m map[string]interface{}) map[string]interface{}
- func MustGetMapData(from interface{}, path string) interface{}
- func MustGetMapDataBool(from interface{}, path string) bool
- func MustGetMapDataStr(from interface{}, path string) string
- func PanicError(args ...interface{})
- func ParseYaml(pattern string) interface{}
- func RandString(n int) string
- func Recursive(from interface{}, ...)
- func RecursiveWithPrefix(parent interface{}, prefixes string, key interface{}, from interface{}, ...)
- func RegexParser(key string, val interface{}) (ret interface{}, replace bool)
- func RemoveComm(out io.Writer)
- func SafeExitOnError(args ...interface{})
- func SendMessage(out io.Writer, msg *Message)
- func SerializeContent(content interface{}) (ret []byte)
- func UnlockComm(out io.Writer)
- type CommandProvider
- func (p *CommandProvider) Init(channel string, subject string, defaultWriter io.Writer)
- func (p *CommandProvider) Return(call *Message, retval *Message)
- func (p *CommandProvider) ReturnError(call *Message, pattern string, args ...interface{}) error
- func (p *CommandProvider) Router(msg *Message)
- func (p *CommandProvider) UnpackLabels(msg *Message) (retry int, timeout, backoff_ms time.Duration)
- type Driver
- func (d *Driver) GetLogger() *logging.Logger
- func (d *Driver) GetName() string
- func (d *Driver) GetOption(path string) (interface{}, bool)
- func (d *Driver) GetOptionStr(path string) (string, bool)
- func (d *Driver) GetStream(feature string) io.Writer
- func (d *Driver) Ping(msg *Message)
- func (d *Driver) ReceiveOptions(msg *Message)
- func (d *Driver) Run()
- func (d *Driver) SendMessage(m *Message)
- type IDMap
- type IDMapMeta
- type Message
- type MessageHandler
- type RPCCaller
- func (c *RPCCaller) Call(feature string, method string, params interface{}) ([]byte, error)
- func (c *RPCCaller) CallNoWait(feature string, method string, params interface{}) error
- func (c *RPCCaller) CallRaw(feature string, method string, params []byte) ([]byte, error)
- func (c *RPCCaller) CallRawNoWait(feature string, method string, params []byte, rpcID string) (ret error)
- func (c *RPCCaller) HandleReturn(m *Message)
- func (c *RPCCaller) Init(parent RPCCallerStub, channel string, subject string)
- type RPCCallerStub
- type RPCHandler
- type RPCProvider
Constants ¶
const ( ChannelEventbus = "eventbus" ChannelState = "state" ChannelRPC = "rpc" EventbusMessage = "message" EventbusCommand = "command" EventbusReturn = "return" )
channel names and subject names
const ( SUCCESS = "success" FAILURE = "failure" ERROR = "error" )
const MaxID = 13684
MaxID : the maximum rpcID
Variables ¶
var CommLocks = map[io.Writer]*sync.Mutex{}
CommLocks : comm channels are protected with locks
var FuncMap = template.FuncMap{ "fromPath": MustGetMapData, "now": time.Now, "duration": time.ParseDuration, "ISO8601": func(t time.Time) string { return t.Format(time.RFC3339) }, "toYaml": func(v interface{}) string { s, err := yaml.Marshal(v) if err != nil { panic(err) } return string(s) }, }
FuncMap : used to add functions to the go templates
var IDMapMetadata = map[IDMap]*IDMapMeta{}
IDMapMetadata : actual metadata for all IDMap objects
var Logger *logging.Logger
Logger provides methods to log to the configured logger backend.
var MasterCommLock = sync.Mutex{}
MasterCommLock : the lock used to protect the comm locks
Functions ¶
func CatchError ¶
func CatchError(err interface{}, handler func())
CatchError : use this in defer to catch a certain error
func CombineMap ¶ added in v1.0.0
CombineMap : combine the data form two maps without merging them
func CompareAll ¶
func CompareAll(actual interface{}, criteria interface{}) bool
CompareAll : compare all conditions against an event data structure
func CompareMap ¶ added in v1.0.0
func CompareMap(actual interface{}, criteria interface{}) bool
CompareMap : compare a map to a map
func DecryptAll ¶ added in v1.0.1
func DecryptAll(rpc *RPCCaller, from interface{})
DecryptAll find and decrypt all eyaml style encrypted data in the given data structure
func DeepCopy ¶
func DeepCopy(m interface{}) (interface{}, error)
DeepCopy : performs a deep copy of the map or slice.
func DeepCopyMap ¶ added in v1.0.0
DeepCopyMap : performs a deep copy of the given map m.
func DeserializeContent ¶
func DeserializeContent(content []byte) (ret interface{})
DeserializeContent : decode the content into interface
func GetMapData ¶
GetMapData : get the data from the deep map following a KV path
func GetMapDataBool ¶
GetMapDataBool : get the data as bool from the deep map following a KV path
func GetMapDataStr ¶
GetMapDataStr : get the data as string from the deep map following a KV path
func IgnoreError ¶
func IgnoreError(expectedError interface{})
IgnoreError : use this function in defer statement to ignore a particular error
func Interpolate ¶
func Interpolate(source interface{}, data interface{}) interface{}
Interpolate : go through the map data structure to find and parse all the templates
func InterpolateGoTemplate ¶ added in v1.0.0
InterpolateGoTemplate : parse the string as go template
func InterpolateStr ¶
InterpolateStr : interpolate a string and return a string
func LockCheckDeleteMap ¶
func LockCheckDeleteMap(lock *sync.Mutex, resource interface{}, key interface{}, checkValue interface{}) (ret interface{})
LockCheckDeleteMap : acquire a lock and delete the entry from the map and return the previous value if available
func LockGetMap ¶
LockGetMap : acquire a lock and look up a key in the map then return the result
func LockSetMap ¶
func LockSetMap(lock *sync.Mutex, resource interface{}, key interface{}, val interface{}) (ret interface{})
LockSetMap : acquire a lock and set the value in the map by index and return the previous value if available
func MergeMap ¶ added in v1.0.0
MergeMap : merge the data from source to destination with some overriding rule
func Must ¶ added in v1.7.0
func Must(ret interface{}, err error) interface{}
Must is used to catch function return with error
func MustDeepCopy ¶ added in v1.0.0
func MustDeepCopy(m interface{}) interface{}
MustDeepCopy : performs a deep copy of the given map or slice, panic if run into errors
func MustDeepCopyMap ¶ added in v1.0.0
MustDeepCopyMap : performs a deep copy of the given map m, panic if run into errors
func MustGetMapData ¶
func MustGetMapData(from interface{}, path string) interface{}
MustGetMapData : get the data from the deep map following a KV path, may raise errors
func MustGetMapDataBool ¶
MustGetMapDataBool : get the data as bool from the deep map following a KV path or panic
func MustGetMapDataStr ¶
MustGetMapDataStr : get the data as string from the deep map following a KV path, may raise errors
func PanicError ¶
func PanicError(args ...interface{})
PanicError accepts multiple variables and will panic if the last variable is not nil. It is used to wrap around functions that return error as the last return value.
dipper.PanicError(io.ReadFull(&b, lval))
The io.ReadFull return length read and an error. If error is returned, the function will panic.
func ParseYaml ¶
func ParseYaml(pattern string) interface{}
ParseYaml : load the data in the string as yaml
func Recursive ¶
func Recursive(from interface{}, process func(key string, val interface{}) (newval interface{}, ok bool))
Recursive : enumerate all the data element deep into the map call the function provided
func RecursiveWithPrefix ¶
func RecursiveWithPrefix( parent interface{}, prefixes string, key interface{}, from interface{}, process func(key string, val interface{}) (newval interface{}, ok bool), )
RecursiveWithPrefix : enumerate all the data element deep into the map call the function provided
func RegexParser ¶
RegexParser : used with Recursive to process the data in the conditions so they can be used for matching
func RemoveComm ¶
RemoveComm : remove the lock when the comm channel is closed
func SafeExitOnError ¶
func SafeExitOnError(args ...interface{})
SafeExitOnError : use this function in defer statement to ignore errors
func SendMessage ¶
SendMessage : send a message to the io.Writer, may change the message to raw
func SerializeContent ¶
func SerializeContent(content interface{}) (ret []byte)
SerializeContent : encode payload content into bytes
Types ¶
type CommandProvider ¶
type CommandProvider struct { Commands map[string]MessageHandler ReturnWriter io.Writer Channel string Subject string }
CommandProvider : an interface for providing Command handling feature
func (*CommandProvider) Init ¶
func (p *CommandProvider) Init(channel string, subject string, defaultWriter io.Writer)
Init : initializing rpc provider
func (*CommandProvider) Return ¶
func (p *CommandProvider) Return(call *Message, retval *Message)
Return : return a value to rpc caller
func (*CommandProvider) ReturnError ¶
func (p *CommandProvider) ReturnError(call *Message, pattern string, args ...interface{}) error
ReturnError: send an error message return to caller and create an error
func (*CommandProvider) Router ¶
func (p *CommandProvider) Router(msg *Message)
Router : route the message to rpc handlers
func (*CommandProvider) UnpackLabels ¶ added in v1.3.0
func (p *CommandProvider) UnpackLabels(msg *Message) (retry int, timeout, backoff_ms time.Duration)
UnpackLabels loads necessary variables out of the labels
type Driver ¶
type Driver struct { RPCCaller RPCProvider CommandProvider Name string Service string State string In io.Reader Out io.Writer Options interface{} MessageHandlers map[string]MessageHandler Start MessageHandler Stop MessageHandler Reload MessageHandler ReadySignal chan bool APITimeout time.Duration }
Driver : the helper stuct for creating a honey-dipper driver in golang
func (*Driver) GetLogger ¶
func (d *Driver) GetLogger() *logging.Logger
GetLogger : getting a logger for the driver
func (*Driver) GetOptionStr ¶
GetOptionStr : get the string data from options map with the key
func (*Driver) ReceiveOptions ¶
ReceiveOptions : receive options from daemon
func (*Driver) SendMessage ¶
SendMessage : send a prepared message to daemon
type IDMap ¶
type IDMap interface{}
IDMap : a map that store values with automatically generated keys
type Message ¶
type Message struct { // on the wire Channel string Subject string Size int Labels map[string]string Payload interface{} // runtime meta info in memory IsRaw bool Reply chan Message ReturnTo io.Writer }
Message : the message passed between components of the system
func DeserializePayload ¶
DeserializePayload : decode a message payload from bytes
func FetchMessage ¶
FetchMessage : fetch message from input from daemon service
may block or throw io.EOF based on the fcntl setting
func FetchRawMessage ¶
FetchRawMessage : fetch encoded message from input from daemon service
may block or throw io.EOF based on the fcntl setting
func MessageCopy ¶
MessageCopy : performs a deep copy of the given map m.
func SerializePayload ¶
SerializePayload : encode a message payload return the modified message
type MessageHandler ¶
type MessageHandler func(*Message)
MessageHandler : a type of functions that take a pointer to a message and handle it
type RPCCaller ¶
type RPCCaller struct { Parent RPCCallerStub Channel string Subject string Result map[string]chan interface{} Lock sync.Mutex Counter int }
RPCCaller : an object that makes RPC calls
func (*RPCCaller) CallNoWait ¶
CallNoWait : making a RPC call to another driver with structured data not expecting any return
func (*RPCCaller) CallRawNoWait ¶
func (c *RPCCaller) CallRawNoWait(feature string, method string, params []byte, rpcID string) (ret error)
CallRawNoWait : making a RPC call to another driver with raw data not expecting return
func (*RPCCaller) HandleReturn ¶
HandleReturn : receiving return of a RPC call
type RPCCallerStub ¶ added in v1.0.1
RPCCallerStub is an interface which every RPC caller should implement
type RPCHandler ¶
RPCHandler : a type of functions that handle RPC calls between drivers
type RPCProvider ¶
type RPCProvider struct { RPCHandlers map[string]MessageHandler DefaultReturn io.Writer Channel string Subject string }
RPCProvider : an interface for providing RPC handling feature
func (*RPCProvider) Init ¶
func (p *RPCProvider) Init(channel string, subject string, defaultWriter io.Writer)
Init : initializing rpc provider
func (*RPCProvider) Return ¶
func (p *RPCProvider) Return(call *Message, retval *Message)
Return : return a value to rpc caller
func (*RPCProvider) ReturnError ¶
func (p *RPCProvider) ReturnError(call *Message, reason string)
ReturnError : return error to rpc caller
func (*RPCProvider) Router ¶
func (p *RPCProvider) Router(msg *Message)
Router : route the message to rpc handlers
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_dipper is a generated GoMock package.
|
Package mock_dipper is a generated GoMock package. |