Documentation ¶
Overview ¶
package app_indicator provides API to install a system tray Indicator and bind it to a menu. It relies on the github.com/getlantern/systray to display the indicator (icon+label) and perform a basic management of each menu entry (MenuNode).
The GetIndicator() function returns the Indicator singleton.
The Indicator can:
* add to the menu a MenuNode QUICK (an always visible shortcut to a simple operation)
* add to the menu a MenuNode ACTION (the entry point for a more complex operation which can also require more choices)
* instantiate an event handler (Listener)
* communicate with the user through a notification system that exploits changes of the Indicator icon and desktop banners.
USAGE EXAMPLE:
//define execution logic func onReady(){ indicator := app_indicator.GetIndicator() indicator.AddQuick("HOME", "Q_HOME", myFunction) ... } func main(){ //start the indicator app_indicator.Run(onReady,func() {}) }
Index ¶
- Constants
- func DestroyMockedIndicator()
- func DestroyStatus()
- func Run(onReady func(), onExit func())
- func UseMockedGuiProvider()
- type EventTester
- type GuiProviderInterface
- type Icon
- type Indicator
- func (i *Indicator) Action(tag string) (act *MenuNode, present bool)
- func (i *Indicator) AddAction(title string, tag string, callback func(args ...interface{}), ...) *MenuNode
- func (i *Indicator) AddQuick(title string, tag string, callback func(args ...interface{}), ...) *MenuNode
- func (i *Indicator) AddSeparator()
- func (i *Indicator) AgentCtrl() *client.AgentController
- func (i *Indicator) Config() *config
- func (i *Indicator) Disconnect()
- func (i *Indicator) Icon() Icon
- func (i *Indicator) Label() string
- func (i *Indicator) Listen(tag client.NotifyChannel, ...)
- func (i *Indicator) Listener(tag client.NotifyChannel) (listener *Listener, present bool)
- func (i *Indicator) NotificationSetLevel(level NotifyLevel)
- func (i *Indicator) Notify(title string, message string, notifyIcon NotifyIcon, indicatorIcon Icon)
- func (i *Indicator) NotifyNoConnection()
- func (i *Indicator) NotifyPeering(direction PeeringType, event NotifyPeeringEvent, peer *PeerInfo)
- func (i *Indicator) Quick(tag string) (quick *MenuNode, present bool)
- func (i *Indicator) Quit()
- func (i *Indicator) RefreshLabel()
- func (i *Indicator) RefreshStatus()
- func (i *Indicator) SetIcon(ico Icon)
- func (i *Indicator) SetLabel(label string)
- func (i *Indicator) SetMenuTitle(title string)
- func (i *Indicator) ShowError(title, message string)
- func (i *Indicator) ShowErrorNoConnection()
- func (i *Indicator) ShowWarning(title, message string)
- func (i *Indicator) ShowWarningForbiddenTethered()
- func (i *Indicator) StartTimer(tag string, interval time.Duration, callback func(args ...interface{}), ...) error
- func (i *Indicator) Status() StatusInterface
- func (i *Indicator) Timer(tag string) (timer *Timer, present bool)
- type Item
- type Listener
- type MenuNode
- func (n *MenuNode) AddOption(title string, tag string, tooltip string, withCheckbox bool, ...) *MenuNode
- func (n *MenuNode) Channel() chan struct{}
- func (n *MenuNode) Connect(once bool, callback func(args ...interface{}), args ...interface{})
- func (n *MenuNode) Disconnect()
- func (n *MenuNode) FreeListChild(tag string)
- func (n *MenuNode) FreeListChildren()
- func (n *MenuNode) IsChecked() bool
- func (n *MenuNode) IsEnabled() bool
- func (n *MenuNode) IsInvalid() bool
- func (n *MenuNode) IsVisible() bool
- func (n *MenuNode) ListChild(tag string) (child *MenuNode, present bool)
- func (n *MenuNode) ListChildrenLen() int
- func (n *MenuNode) Option(tag string) (opt *MenuNode, present bool)
- func (n *MenuNode) SetIsChecked(isChecked bool)
- func (n *MenuNode) SetIsEnabled(isEnabled bool)
- func (n *MenuNode) SetIsInvalid(isInvalid bool)
- func (n *MenuNode) SetIsVisible(isVisible bool)
- func (n *MenuNode) SetTag(tag string)
- func (n *MenuNode) SetTitle(title string)
- func (n *MenuNode) SetTooltip(tooltip string)
- func (n *MenuNode) Tag() string
- func (n *MenuNode) Title() string
- func (n *MenuNode) UseListChild(title string, tag string) *MenuNode
- type NodeIcon
- type NodeType
- type NotifyIcon
- type NotifyLevel
- type NotifyPeeringEvent
- type PeerInfo
- type PeeringType
- type StatMode
- type StatRun
- type Status
- func (st *Status) ActivePeerings() int
- func (st *Status) AddOrUpdatePeer(data *client.NotifyDataForeignCluster) *PeerInfo
- func (st *Status) GoString() string
- func (st *Status) IsTetheredCompliant() bool
- func (st *Status) Mode() StatMode
- func (st *Status) Peer(clusterId string) (peer *PeerInfo, present bool)
- func (st *Status) Peerings(peering PeeringType) int
- func (st *Status) Peers() int
- func (st *Status) RemovePeer(data *client.NotifyDataForeignCluster) *PeerInfo
- func (st *Status) Running() StatRun
- func (st *Status) SetClusterName(clusterName string)
- func (st *Status) SetMode(mode StatMode) error
- func (st *Status) SetRunning(running StatRun)
- func (st *Status) SetUser(user string)
- func (st *Status) User() string
- type StatusInterface
- type Timer
Constants ¶
const ( NotifyLevelOffDescription = "Notifications OFF" NotifyLevelMinDescription = "Notify with icon" NotifyLevelMaxDescription = "Notify with icon and banner" )
Textual descriptions of the NotifyLevel values
const ( //StatModeAutonomousHeaderDescription is the short description for the AUTONOMOUS mode. StatModeAutonomousHeaderDescription = "AUTONOMOUS" //StatModeAutonomousBodyDescription is the extended description for the AUTONOMOUS mode. StatModeAutonomousBodyDescription = "Be in control of your Liqo: exchange resources with multiple peers" //StatModeTetheredHeaderDescription is the short description for the TETHERED mode. StatModeTetheredHeaderDescription = "TETHERED" //StatModeTetheredBodyDescription is the extended description for the TETHERED mode. StatModeTetheredBodyDescription = "Let a remote peer control your Liqo" //StatModeUnknownDescription is a fallback description for undefined mode received from the graphic input. StatModeUnknownDescription = "unknown" )
Variables ¶
This section is empty.
Functions ¶
func DestroyMockedIndicator ¶
func DestroyMockedIndicator()
DestroyMockedIndicator destroys the Indicator singleton for testing purposes. It works only after calling UseMockedGuiProvider
func DestroyStatus ¶
func DestroyStatus()
DestroyStatus is a testing function used to refresh the Status component.
func Run ¶
func Run(onReady func(), onExit func())
Run starts the Indicator execution, running the onReady() function. After Quit() call, it runs onExit() before exiting. It should be called at the very beginning of main() to lock at main thread.
func UseMockedGuiProvider ¶
func UseMockedGuiProvider()
UseMockedGuiProvider enables a mocked guiProvider that does not interact with the OS graphic server. The real guiProvider internally exploits github.com/getlantern/systray to orchestrate GUI execution.
Function MUST be called before GetGuiProvider in order to be effective.
Types ¶
type EventTester ¶
EventTester is a WaitGroup-based data struct that enables testers to validate concurrent operations performed by the callback associated to an Indicator Listener (which reacts to specific events) or a MenuNode (which reacts when the correspondent graphic menu entry is clicked).
During a test, after calling app-indicator.UseMockedGuiProvider(), you can call GetGuiProvider().NewEventTester() to create a new EventTester. After calling EventTester.Test(), an EventTester.Done() is called after the execution of the associated callback of a Listener or a MenuNode (if MenuNode.Connect() has been previously called).
Inside a test, use EventTester.Add() and EventTester.Wait() to synchronize the execution of Listeners callbacks.
... eventTester := GetGuiProvider.NewEventTester() eventTester.Test() //test changes after a single callback eventTester.Add(1) // trigger Listener-bind callback // wait for callback to return eventTester.Wait() //perform checks on changes and continue
func (*EventTester) Test ¶
func (e *EventTester) Test()
type GuiProviderInterface ¶
type GuiProviderInterface interface { //Run initializes the GUI and starts the event loop, then invokes the onReady callback. It blocks until //Quit() is called. After Quit() call, it runs onExit() before exiting. It should be called before //any other method of the interface. Run(onReady func(), onExit func()) //Quit exits the GUI runtime execution after Run() has been called. Quit() //AddSeparator adds a separator bar to the tray menu. AddSeparator() //SetIcon sets the tray icon. SetIcon(iconBytes []byte) //SetTitle sets the content of the label next to the tray icon. SetTitle(title string) /* AddMenuItem creates and returns an Item, e.g. an entry of the tray menu. The menu works as a stack with only 'push' operation available. Use Item methods (e.g. Item.Hide()) to emulate 'pop' behavior. withCheckbox = true has to be used on Linux builds to force the creation of an Item with an actual checkbox. Otherwise the graphical behavior of Item.Check() is demanded to internal implementation. */ AddMenuItem(withCheckbox bool) Item /* AddSubMenuItem creates and returns a child Item for a parent Item so that it can be displayed as a submenu element in the tray menu. Each Item submenu works as a stack with only 'push' method available. Use Item methods (e.g. Item.Hide()) to emulate 'pop' behavior. withCheckbox = true has to be used on Linux builds to force the creation of an Item with an actual checkbox. Otherwise the graphical behavior of Item.Check() is demanded to internal implementation. */ AddSubMenuItem(parent Item, withCheckbox bool) Item //Mocked returns whether the interaction with the OS graphic server is mocked. Mocked() bool //NewEventTester resets and return the EventTester. You can then call EventTester.Test() to start the testing //mechanism for the events handled by the current Indicator instance. Read more on EventTester documentation. NewEventTester() *EventTester //GetEventTester returns current GuiProvider EventTester instance. Read more on EventTester documentation. // //If testing==true, the EventTester is currently registering the events handled by the Indicator instance in test mode. GetEventTester() (eventTester *EventTester, testing bool) }
GuiProviderInterface wraps the methods to interact with the OS graphic server and manage a tray icon with its menu.
func GetGuiProvider ¶
func GetGuiProvider() GuiProviderInterface
GetGuiProvider returns the guiProvider singleton that provides the functions to interact with the graphic server.
If UseMockedGuiProvider() has been previously called, it returns a mocked guiProvider.
type Icon ¶
type Icon int
Icon represents the icon displayed in the tray bar
const ( IconLiqoMain Icon = iota IconLiqoNoConn IconLiqoOff IconLiqoWarning IconLiqoOrange IconLiqoGreen IconLiqoPurple IconLiqoRed IconLiqoYellow IconLiqoCyan IconLiqoNil )
Icon displayed in the tray bar. It is internally mapped into one of the icons in github.com/liqotech/liqo-agent/assets/tray-agent/icons/tray-abr
type Indicator ¶
type Indicator struct {
// contains filtered or unexported fields
}
Indicator is a stateful data structure that controls the app indicator and its related menu. It can be obtained and initialized calling GetIndicator()
func GetIndicator ¶
func GetIndicator() *Indicator
GetIndicator initializes and returns the Indicator singleton. This function should not be called before Run().
func (*Indicator) Action ¶
Action returns the *MenuNode of the ACTION with this specific tag. If not present, present = false
func (*Indicator) AddAction ¶
func (i *Indicator) AddAction(title string, tag string, callback func(args ...interface{}), args ...interface{}) *MenuNode
AddAction adds an ACTION to the indicator menu. It is visible by default.
title : label displayed in the menu tag : unique tag for the ACTION callback : callback function to be executed at each 'clicked' event. If callback == nil, the function can be set afterwards using (*Indicator).Connect() .
func (*Indicator) AddQuick ¶
func (i *Indicator) AddQuick(title string, tag string, callback func(args ...interface{}), args ...interface{}) *MenuNode
AddQuick adds a QUICK to the indicator menu. It is visible by default.
title : label displayed in the menu tag : unique tag for the QUICK callback : callback function to be executed at each 'clicked' event. If callback == nil, the function can be set afterwards using (*MenuNode).Connect() .
func (*Indicator) AddSeparator ¶
func (i *Indicator) AddSeparator()
AddSeparator adds a separator line to the indicator menu
func (*Indicator) AgentCtrl ¶
func (i *Indicator) AgentCtrl() *client.AgentController
AgentCtrl returns the Indicator AgentController that interacts with the cluster.
func (*Indicator) Config ¶
func (i *Indicator) Config() *config
Config returns the Indicator config.
func (*Indicator) Disconnect ¶
func (i *Indicator) Disconnect()
Disconnect exits all the event handlers associated with any Indicator MenuNode via the Connect() method.
func (*Indicator) Listen ¶
func (i *Indicator) Listen(tag client.NotifyChannel, callback func(data client.NotifyDataGeneric, args ...interface{}), args ...interface{})
Listen starts a Listener for a specific channel, executing callback when a notification arrives.
func (*Indicator) Listener ¶
func (i *Indicator) Listener(tag client.NotifyChannel) (listener *Listener, present bool)
Listener returns the registered Listener for the specified NotifyChannel. If such Listener does not exist, present == false.
func (*Indicator) NotificationSetLevel ¶
func (i *Indicator) NotificationSetLevel(level NotifyLevel)
NotificationSetLevel sets the level of the indicator notification system:
NotifyLevelOff: disable all notifications NotifyLevelMin: Indicator notifies events only using Indicator's icon and label NotifyLevelMax: Indicator notifies events using Indicator's icon and label and desktop banners
func (*Indicator) Notify ¶
func (i *Indicator) Notify(title string, message string, notifyIcon NotifyIcon, indicatorIcon Icon)
Notify manages Indicator notification logic. Depending on the current NotifyLevel of the Indicator, it changes the Indicator tray icon and displays a desktop banner, having title 'title' and 'message' as body. If present in client.EnvLiqoPath, also 'notifyIcon' is shown inside the banner.
The "nil" values can be used for both 'notifyIcon' and 'indicatorIcon':
NotifyIconNil : don't show a notification icon IconLiqoNil : don't change current Indicator icon
func (*Indicator) NotifyNoConnection ¶
func (i *Indicator) NotifyNoConnection()
NotifyNoConnection is an already configured Notify() call to notify the absence of connection with the cluster pointed by $LIQO_KCONFIG.
func (*Indicator) NotifyPeering ¶
func (i *Indicator) NotifyPeering(direction PeeringType, event NotifyPeeringEvent, peer *PeerInfo)
NotifyPeering is a semi-configured Notify() call to notify events related to peerings involving a specific peer.
func (*Indicator) Quick ¶
Quick returns the *MenuNode of the QUICK with this specific tag. If such QUICK does not exist, present == false.
func (*Indicator) RefreshLabel ¶
func (i *Indicator) RefreshLabel()
RefreshLabel updates the content of the Indicator label with the total number of both incoming and outgoing peerings currently active.
func (*Indicator) RefreshStatus ¶
func (i *Indicator) RefreshStatus()
RefreshStatus updates the contents of the STATUS MenuNode and the Indicator Label.
func (*Indicator) SetIcon ¶
SetIcon sets the Indicator tray icon. If 'ico' is not a valid argument or ico == IconLiqoNil, SetIcon does nothing.
func (*Indicator) SetMenuTitle ¶
SetMenuTitle sets the text content of the TITLE MenuNode, displayed as the menu header.
func (*Indicator) ShowErrorNoConnection ¶
func (i *Indicator) ShowErrorNoConnection()
ShowErrorNoConnection is an already configured ShowError() call to warn the user about kubeconfig misconfiguration.
func (*Indicator) ShowWarning ¶
ShowWarning displays a Warning window box.
func (*Indicator) ShowWarningForbiddenTethered ¶
func (i *Indicator) ShowWarningForbiddenTethered()
ShowWarningForbiddenTethered is an already configured ShowWarning() call to warn users when they attempt to set the TETHERED mode without the required conditions.
func (*Indicator) StartTimer ¶
func (i *Indicator) StartTimer(tag string, interval time.Duration, callback func(args ...interface{}), args ...interface{}) error
StartTimer registers a new Timer in charge of controlling the loop execution of callback. The Timer starts automatically and can be controlled using (*Timer).SetActive() .
tag : Timer id.
interval : specifies the time interval after which the callback execution is triggered.
func (*Indicator) Status ¶
func (i *Indicator) Status() StatusInterface
Status return the Indicator status.
type Item ¶
type Item interface { //Check checks the Item. Check() //Uncheck unchecks the Item. Uncheck() //Checked returns whether the Item is checked. Checked() bool //Enable enables the Item, making it clickable. Enable() //Disable disables the Item, preventing it to be clickable. Disable() //Disabled returns whether the Item is disabled, i.e. not clickable. Disabled() bool //Show makes the Item visible in the menu. Show() //Hide hides the Item from the menu. Hide() //SetTitle sets the content of the Item that will be displayed in the menu. SetTitle(title string) //SetTooltip sets a tooltip for the Item displayed after a 'mouse hover' event. //Currently, this is ineffective on Linux builds. SetTooltip(tooltip string) }
Item is an interface representing the actual item that gets pushed (and displayed) in the stack of the tray menu.
type Listener ¶
type Listener struct { //Tag specifies the type of notification channel on which it listens to Tag client.NotifyChannel //StopChan lets control the Listener event loop StopChan chan struct{} //NotifyChan is the client.NotifyChannel on which it listens to NotifyChan chan client.NotifyDataGeneric }
Listener is an event listener that can react calling a specific callback.
type MenuNode ¶
type MenuNode struct { //protection for concurrent access to MenuNode attributes. sync.RWMutex // contains filtered or unexported fields }
MenuNode is a stateful wrapper type that provides a better management of the Item type and additional features, such as submenus.
func (*MenuNode) AddOption ¶
func (n *MenuNode) AddOption(title string, tag string, tooltip string, withCheckbox bool, callback func(args ...interface{}), args ...interface{}) *MenuNode
AddOption adds an OPTION to the MenuNode as a choice for the submenu.
title : label displayed in the menu tag : unique tag for the OPTION callback : callback function to be executed at each 'clicked' event. If callback == nil, the function can be set afterwards using n.Connect() . withCheckbox : if true, add a graphic checkbox on the menu element.
func (*MenuNode) Channel ¶
func (n *MenuNode) Channel() chan struct{}
Channel returns the ClickedChan chan of the MenuNode which reacts to the 'clicked' event
func (*MenuNode) Connect ¶
Connect instantiates a listener for the 'clicked' event of the node. If once == true, the event handler is at most executed once.
func (*MenuNode) Disconnect ¶
func (n *MenuNode) Disconnect()
Disconnect removes the event handler (if any) from the MenuNode.
func (*MenuNode) FreeListChild ¶
FreeListChild marks a LIST MenuNode and its nested children as unused, graphically removing them from the submenu of MenuNode n in the tray menu. This is a no-op in case of tagged child missing.
func (*MenuNode) FreeListChildren ¶
func (n *MenuNode) FreeListChildren()
FreeListChildren recursively marks all children LIST MenuNode as unused, graphically removing it from the submenu of MenuNode n in the tray menu.
func (*MenuNode) IsEnabled ¶
IsEnabled returns if the MenuNode label is clickable by the user (if displayed).
func (*MenuNode) IsInvalid ¶
IsInvalid returns if the content of the LIST MenuNode is no more up to date and has to be refreshed by application logic.
func (*MenuNode) ListChild ¶
ListChild returns a tagged LIST MenuNode from the ones currently in use.
func (*MenuNode) ListChildrenLen ¶
ListChildrenLen returns the number of LIST MenuNode currently in use.
func (*MenuNode) Option ¶
Option returns the *MenuNode of the OPTION with this specific tag. If such OPTION does not exist, present = false.
func (*MenuNode) SetIsChecked ¶
SetIsChecked (un)check the MenuNode.
func (*MenuNode) SetIsEnabled ¶
SetIsEnabled change MenuNode possibility to be clickable.
func (*MenuNode) SetIsInvalid ¶
SetIsInvalid change the validity of MenuNode content. If isInvalid==true, the content of the LIST MenuNode is no more up to date and has to be refreshed by application logic.
func (*MenuNode) SetIsVisible ¶
SetIsVisible change the MenuNode visibility in the menu.
func (*MenuNode) SetTooltip ¶
SetTooltip sets a 'mouse hover' tooltip for the MenuNode. This is a no-op for Linux builds.
type NodeIcon ¶
type NodeIcon string
NodeIcon represents a string prefix helping to graphically distinguish different kinds of Menu entries (NodeType).
type NodeType ¶
type NodeType int
NodeType defines the kind of a MenuNode, each one with specific features.
NodeType distinguishes different kinds of MenuNodes:
ROOT: root of the Menu Tree. QUICK: simple shortcut to perform quick actions, e.g. navigation commands. It is always visible. ACTION: launch an application command. It can open command submenu (if present). OPTION: submenu choice. LIST: placeholder item used to dynamically display application output. TITLE: node with special text formatting used to display menu header. STATUS: non clickable node that displays status information.
const ( //NodeTypeRoot represents a NodeType of a ROOT MenuNode: root of the Menu Tree. NodeTypeRoot NodeType = iota //NodeTypeQuick represents a NodeType of a QUICK MenuNode: simple shortcut to perform quick actions, //e.g. navigation commands. It is always visible. NodeTypeQuick //NodeTypeAction represents a NodeType of an ACTION MenuNode: launches an application command. //It can open command submenu (if present). NodeTypeAction //NodeTypeOption represents a NodeType of an OPTION MenuNode: submenu choice (hidden by default). NodeTypeOption //NodeTypeList represents a NodeType of a LIST MenuNode: placeholder MenuNode used to dynamically //display application output. NodeTypeList //NodeTypeTitle represents a NodeType of a TITLE MenuNode: node with special text formatting //used to display the menu header. NodeTypeTitle //NodeTypeStatus represents a NodeType of a STATUS MenuNode: non clickable node that displays status information //about Liqo. NodeTypeStatus )
set of defined NodeType kinds
type NotifyIcon ¶
type NotifyIcon int
NotifyIcon represents the Liqo set of icons displayed in the desktop banners.
const ( NotifyIconNil NotifyIcon = iota NotifyIconDefault NotifyIconWhite NotifyIconError NotifyIconWarning )
Liqo icon set for the Indicator notification system.
type NotifyLevel ¶
type NotifyLevel int
NotifyLevel is the level of the indicator notification system:
const ( //NotifyLevelOff: disable all notifications NotifyLevelOff NotifyLevel = iota //NotifyLevelMin: Indicator notifies events only using Indicator's icon and label NotifyLevelMin //NotifyLevelMax: Indicator notifies events using Indicator's icon and label and desktop banners NotifyLevelMax )
Allowed modes for the Indicator notification system
type NotifyPeeringEvent ¶
type NotifyPeeringEvent int
NotifyPeeringEvent defines a type of event regarding a peering with a foreign cluster.
const ( //NotifyEventPeeringOn defines the event of a peering that has been established. NotifyEventPeeringOn NotifyPeeringEvent = iota //NotifyEventPeeringOff defines the event of a peering that has been torn down. NotifyEventPeeringOff )
type PeerInfo ¶
type PeerInfo struct { //ForeignClusterResourceName identifies the name of the associated ForeignCluster CRD. ForeignClusterResourceName string ClusterID string ClusterName string //Unknown identifies whether the peer has no provided ClusterName. //In this case, UnknownId contains a valid serial identifier. Unknown bool //UnknownId contains a serial number that identifies the peer in case no ClusterName is provided //(Unknown == true). UnknownId int OutPeeringConnected bool InPeeringConnected bool sync.RWMutex }
PeerInfo contains some basic information on a peer.
type PeeringType ¶
type PeeringType bool
PeeringType defines a type of peering with a foreign cluster.
const ( //PeeringIncoming defines a peering where the home cluster shares its own resources with a foreign cluster. PeeringIncoming PeeringType = true //PeeringOutgoing defines a peering where the home cluster is consuming the resources of a foreign cluster. PeeringOutgoing PeeringType = false )
type StatMode ¶
type StatMode int
StatMode defines the Working Modes for Liqo, i.e. abstraction models designed to cover some common use cases. Each Mode represents a set of allowed operations and statuses.
const ( /*StatModeAutonomous defines the AUTONOMOUS working mode. The device uses its own on-board intelligence, i.e. it connects to its local K8s API server and lets the local orchestrator control the scheduling. - It can work as a stand-alone cluster, consuming only its own resources - It can connect to multiple peers, both consuming (under its control) foreign resources and sharing its proprietary resources to other peers. The system acts as a set of cooperating nodes, exploiting each foreign cluster's VirtualKubelet seen by the local scheduler. Each sharing operation is independent of the others. */ StatModeAutonomous StatMode = iota /* StatModeTethered defines the TETHERED working mode. The device can choose to connect to a single foreign Liqo peer (e.g. the corporate network), allowing the remote orchestrator to control the usage of its resources. When the tethered peering is established, the remote peer, working in Autonomous mode, uses its own API Server and takes control of the shared resources. Every resource request made by the device is forwarded to the remote peer which will perform a proper scheduling. */ StatModeTethered )
type Status ¶
type Status struct { //mutex for the Status. sync.RWMutex // contains filtered or unexported fields }
Status defines a data structure containing information about the current status of the Liqo instance, e.g. if it is running, the selected working mode and a summary of the active peerings.
func (*Status) ActivePeerings ¶
ActivePeerings returns the amount of active peerings.
func (*Status) AddOrUpdatePeer ¶
func (st *Status) AddOrUpdatePeer(data *client.NotifyDataForeignCluster) *PeerInfo
AddOrUpdatePeer updates the internal information on an existing or newly discovered peer. In case no info about the peer's common name is provided, a placeholder "unknown identifier" is assigned to allow the user to visually distinguish between different unknown peers. When the number of unknown peers is decremented to 0, the identifier number is reset.
func (*Status) GoString ¶
GoString produces a textual digest on the main status data managed by a Status instance.
func (*Status) IsTetheredCompliant ¶
IsTetheredCompliant checks if the TETHERED mode is eligible accordingly to current status. The result can be used to display information.
func (*Status) Peer ¶
Peer returns data related to a cluster if it is currently discovered by the home cluster.
func (*Status) Peerings ¶
func (st *Status) Peerings(peering PeeringType) int
Peerings returns the number of active peerings of type PeeringType.
func (*Status) Peers ¶
Peers returns the number of Liqo peers discovered by the home cluster and currently available.
func (*Status) RemovePeer ¶
func (st *Status) RemovePeer(data *client.NotifyDataForeignCluster) *PeerInfo
RemovePeer removes a peer from the currently registered ones.
func (*Status) SetClusterName ¶
SetClusterName sets the common name of the cluster LiqoAgent is currently connected to.
func (*Status) SetMode ¶
SetMode sets the working mode for Liqo. If the operation is not allowed for current configuration, it returns an error.
func (*Status) SetRunning ¶
SetRunning changes the running status of Liqo. Transition to StatRunOff implies the end of all active peerings.
type StatusInterface ¶
type StatusInterface interface { //User returns the Liqo Name of the home cluster connected to the Agent. User() string //SetUser sets the Liqo Name of the home cluster connected to the Agent. SetUser(user string) //Running returns the running status of Liqo. Running() StatRun //SetRunning changes the running status of Liqo. Transition to StatRunOff //implies the end of all active peerings. SetRunning(running StatRun) //Mode returns the current working mode of Liqo. Mode() StatMode //SetMode sets the working mode for Liqo. //If the operation is not allowed for current configuration, it returns an error. SetMode(mode StatMode) error /*IsTetheredCompliant checks if the TETHERED mode is eligible accordingly to current status. The result can be used to display information. This method is not to be intended as a preliminary test for an actual mode change. In this case you must use SetMode() which exploits a "Compare&Change" protection. */ IsTetheredCompliant() bool //Peerings returns the number of active peerings of type PeeringType. Peerings(peering PeeringType) int //ActivePeerings returns the amount of active peerings. ActivePeerings() int //Peers returns the number of Liqo peers discovered by the home cluster and currently available. Peers() int //Peer returns data related to a cluster if it is currently discovered by the home cluster. Peer(clusterId string) (peer *PeerInfo, present bool) //AddOrUpdatePeer updates the internal information on an existing or newly discovered peer. //In case no info about the peer's common name is provided, a placeholder "unknown identifier" //is assigned to allow the user to visually distinguish between different unknown peers. //When the number of unknown peers is decremented to 0, the identifier number is reset. AddOrUpdatePeer(data *client.NotifyDataForeignCluster) *PeerInfo //RemovePeer removes a peer from the currently registered ones. RemovePeer(data *client.NotifyDataForeignCluster) *PeerInfo //SetClusterName sets the common name of the cluster LiqoAgent is currently connected to. SetClusterName(clusterName string) //GoString produces a textual digest on the main status data managed by //a Status instance. GoString() string }
StatusInterface wraps the methods to manage the Indicator status.
func GetStatus ¶
func GetStatus() StatusInterface
GetStatus initializes and returns the Status singleton. This function should not be called before Run().
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is a data structure that allows to control a time triggered loop execution of a callback.