func Command(commandID uint16, callback func(map[string]interface{}) (map[string]interface{}, error))
Command Defines a handling function for a mesh network messsage as a command - Command messages are sent by SendRequest, SendMany, USend, USendMany
func GetBool(data map[string]interface{}, name string) bool
GetBool returns a bool from the mesh network request/response data
func GetBytes(data map[string]interface{}, name string) []byte
GetBytes returns a byte array from the mesh network request/response data
func GetFloat64(data map[string]interface{}, name string) float64
GetFloat64 returns a float64 from the mesh network request/response data
func GetInt(data map[string]interface{}, name string) int
GetInt returns an int from the mesh network request/response data
func GetInt16(data map[string]interface{}, name string) int16
GetInt16 returns an int16 from the mesh network request/response data
func GetInt32(data map[string]interface{}, name string) int32
GetInt32 returns an int32 from the mesh network request/response data
func GetInt64(data map[string]interface{}, name string) int64
GetInt64 returns an int64 from the mesh network request/response data
func GetInt8(data map[string]interface{}, name string) int8
GetInt8 returns an int8 from the mesh network request/response data
func GetMyEndPoint() string
GetMyEndPoint Returns its own mesh network end point
func GetMyNodeEndPoint() string
GetMyNodeEndPoint returns the server endpoint (internet) its own node
func GetMyNodeType() string
GetMyNodeType Returns the node type of itself
func GetNodeAddresses(ignoreList []string) []string
GetNodeAddresses Returns all node addresses
func GetNodeAddressesByRole(nRole string) []string
GetNodeAddressesByRole Return the addresses of nodes by type
func GetNodeAddressesByType(nType string) []string
GetNodeAddressesByType Return the addresses of nodes by type
func GetNodeEndPoint(nodeAddr string) string
GetNodeEndPoint returns the server endpoint (internet) of a node by its mesh node address - only TCP, UDP, and HTTP
func GetNodeRoleByType(nType string) string
GetNodeRoleByType Returns node role by node type. Possible values are: HTTP, TCP, UDP, WS, and empty if node type is invalid
func GetNodeTypes() []string
GetNodeTypes returns all node types currently in the Diarkis cluster
func GetNodeValue(nodeAddr string, name string) interface{}
GetNodeValue Returns a metadata value of a node by its address
func GetNodeValues(nodeAddr string) map[string]interface{}
GetNodeValues Returns all metadata values of a node by its address
func GetString(data map[string]interface{}, name string) string
GetString returns a string from the mesh network request/response data
func GetUint16(data map[string]interface{}, name string) uint16
GetUint16 returns a uint16 from the mesh network request/response data
func GetUint32(data map[string]interface{}, name string) uint32
GetUint32 returns a uint32 from the mesh network request/response data
func GetUint64(data map[string]interface{}, name string) uint64
GetUint64 returns a uint64 from the mesh network request/response data
func GetUint8(data map[string]interface{}, name string) uint8
GetUint8 returns a uint8 from the mesh network request/response data
func Guest(confpath string)
Guest starts mesh network as a guest meaning that the process can only send and receive messages but does not become part of the mesh node
func IsCommandDuplicate(commandID uint16) bool
IsCommandDuplicate returns true if commandID is used elsewhere
func IsMyNodeOnline() bool
IsMyNodeOnline returns false if the node is offline (received SIGTERM)
When the node is offline, the connected clients will be raising OnOffline event
func IsMyNodeTaken() bool
IsMyNodeTaken returns true if the node is taken ((mesh.SetStatus(util.MeshStatusTaken))
When a node is thaken, the taken node will not be returned by HTTP server as available server.
func IsNodeOnline(nodeAddr string) bool
IsNodeOnline Returns true if the given node is online
When the node is offline, the connected clients will be raising OnOffline event
func IsNodeTaken(nodeAddr string) bool
IsNodeTaken returns false if the node is taken (mesh.SetStatus(util.MeshStatusTaken))
When a node is thaken, the taken node will not be returned by HTTP server as available server.
func OnUpdate(handler func())
OnUpdate Registers a callback on announcer update event
func OnUpdated(handler func())
OnUpdated Registers a callback on announcer updated event
func Send(commandID uint16, addr string, data map[string]interface{})
Send Sends a mesh network message to a given node - addr = <address>:<port>
func SendMany(commandID uint16, addrs []string, data map[string]interface{}, limit int)
SendMany Sends a mesh network message to multiple nodes
commandID - Mesh message command ID addrs - A list of mesh node addreses to send the message to data - Data map to be sent limit - Maximum number of node to send the message at a time
func SendRequest(commandID uint16, addr string, data map[string]interface{}, callback func(error, map[string]interface{}))
SendRequest Sends a mesh network requesst to another node - addr = <address>:<port> and expects a response back from it
func SetAppName(name string)
SetAppName creates a name space within the mars-server in order to have multiple diarkis clusters
func SetEndPoint(endPoint string)
SetEndPoint Sets its own end point
func SetNodeRole(role string)
SetNodeRole [INTERNAL USE ONLY]
func SetNodeType(_nodeType string)
SetNodeType Sets a type to a name
func SetNodeValue(name string, val interface{})
SetNodeValue Sets a metadata value to a node
func SetStatus(status int)
SetStatus Sets its status
func Setup(confpath string)
Setup Loads a configuration file into memory - pass an empty string to load nothing
func StartAsMARS(confpath string)
StartAsMARS Starts the server as MARS server - For now this is meant to be used for mars-server ONLY
func USend(commandID uint16, addr string, data map[string]interface{})
USend Sends an unreliable message to a given node - addr = <address>:<port>
func USendMany(command uint16, addrs []string, data map[string]interface{}, limit int)
USendMany Sends an unreliable mesh network message to multiple nodes
commandID - Mesh message command ID addrs - A list of mesh node addreses to send the message to data - Data map to be sent limit - Maximum number of node to send the message at a time
Node a mesh network node data structure
type Node struct { Addr string Type string Role string Values map[string]interface{} Self bool }
func GetNode(nodeAddr string) *Node
GetNode Returns a node by its address
func GetNodeByEndPoint(endPoint string) *Node
GetNodeByEndPoint Returns a node by its server end point - only WebSocket, TCP, UDP, and HTTP