app_indicator

package
v0.0.0-...-c4606bf Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

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

View Source
const (
	NotifyLevelOffDescription = "Notifications OFF"
	NotifyLevelMinDescription = "Notify with icon"
	NotifyLevelMaxDescription = "Notify with icon and banner"
)

Textual descriptions of the NotifyLevel values

View Source
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

type EventTester struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

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

func (i *Indicator) Action(tag string) (act *MenuNode, present bool)

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) Icon

func (i *Indicator) Icon() Icon

Icon returns the icon-id of the Indicator tray icon currently set.

func (*Indicator) Label

func (i *Indicator) Label() string

Label returns the text content of Indicator tray label.

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

func (i *Indicator) Quick(tag string) (quick *MenuNode, present bool)

Quick returns the *MenuNode of the QUICK with this specific tag. If such QUICK does not exist, present == false.

func (*Indicator) Quit

func (i *Indicator) Quit()

Quit stops the indicator execution.

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

func (i *Indicator) SetIcon(ico Icon)

SetIcon sets the Indicator tray icon. If 'ico' is not a valid argument or ico == IconLiqoNil, SetIcon does nothing.

func (*Indicator) SetLabel

func (i *Indicator) SetLabel(label string)

SetLabel sets the text content of Indicator tray label.

func (*Indicator) SetMenuTitle

func (i *Indicator) SetMenuTitle(title string)

SetMenuTitle sets the text content of the TITLE MenuNode, displayed as the menu header.

func (*Indicator) ShowError

func (i *Indicator) ShowError(title, message string)

ShowError displays an Error window box.

func (*Indicator) ShowErrorNoConnection

func (i *Indicator) ShowErrorNoConnection()

ShowErrorNoConnection is an already configured ShowError() call to warn the user about kubeconfig misconfiguration.

func (*Indicator) ShowWarning

func (i *Indicator) ShowWarning(title, message string)

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.

func (*Indicator) Timer

func (i *Indicator) Timer(tag string) (timer *Timer, present bool)

Timer returns the registered Timer for the specified tag. If such Timer does not exist, present == false.

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 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 (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 (n *MenuNode) Channel() chan struct{}

Channel returns the ClickedChan chan of the MenuNode which reacts to the 'clicked' event

func (n *MenuNode) Connect(once bool, callback func(args ...interface{}), args ...interface{})

Connect instantiates a listener for the 'clicked' event of the node. If once == true, the event handler is at most executed once.

func (n *MenuNode) Disconnect()

Disconnect removes the event handler (if any) from the MenuNode.

func (n *MenuNode) FreeListChild(tag string)

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 (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 (n *MenuNode) IsChecked() bool

IsChecked returns if MenuNode has been checked.

func (n *MenuNode) IsEnabled() bool

IsEnabled returns if the MenuNode label is clickable by the user (if displayed).

func (n *MenuNode) IsInvalid() bool

IsInvalid returns if the content of the LIST MenuNode is no more up to date and has to be refreshed by application logic.

func (n *MenuNode) IsVisible() bool

IsVisible returns if the MenuNode is currently displayed in the menu.

func (n *MenuNode) ListChild(tag string) (child *MenuNode, present bool)

ListChild returns a tagged LIST MenuNode from the ones currently in use.

func (n *MenuNode) ListChildrenLen() int

ListChildrenLen returns the number of LIST MenuNode currently in use.

func (n *MenuNode) Option(tag string) (opt *MenuNode, present bool)

Option returns the *MenuNode of the OPTION with this specific tag. If such OPTION does not exist, present = false.

func (n *MenuNode) SetIsChecked(isChecked bool)

SetIsChecked (un)check the MenuNode.

func (n *MenuNode) SetIsEnabled(isEnabled bool)

SetIsEnabled change MenuNode possibility to be clickable.

func (n *MenuNode) SetIsInvalid(isInvalid bool)

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 (n *MenuNode) SetIsVisible(isVisible bool)

SetIsVisible change the MenuNode visibility in the menu.

func (n *MenuNode) SetTag(tag string)

SetTag sets the the MenuNode tag.

func (n *MenuNode) SetTitle(title string)

SetTitle sets the text content of the MenuNode label.

func (n *MenuNode) SetTooltip(tooltip string)

SetTooltip sets a 'mouse hover' tooltip for the MenuNode. This is a no-op for Linux builds.

func (n *MenuNode) Tag() string

Tag returns the MenuNode tag.

func (n *MenuNode) Title() string

Title returns the text content of the menu entry. Eventual check tick for checked MenuNode is not included.

func (n *MenuNode) UseListChild(title string, tag string) *MenuNode

UseListChild returns a child LIST MenuNode ready to use and visible to users. The node can use them to dynamically display to the user the output of application functions.

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
)

func (StatMode) GoString

func (sm StatMode) GoString() string

GoString implements the fmt.GoStringer interface. This method is used to display an extended text format for a StatMode.

func (StatMode) String

func (sm StatMode) String() string

String converts in human-readable format the StatMode information.

type StatRun

type StatRun bool

StatRun defines the running status of Liqo.

const (
	//StatRunOff defines the 'OFF' running status of Liqo.
	StatRunOff StatRun = false
	//StatRunOn defines the 'ON' running status of Liqo.
	StatRunOn StatRun = true
)

func (StatRun) String

func (rs StatRun) String() string

String converts in human-readable format the StatRun information.

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

func (st *Status) ActivePeerings() int

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

func (st *Status) GoString() string

GoString produces a textual digest on the main status data managed by a Status instance.

func (*Status) IsTetheredCompliant

func (st *Status) IsTetheredCompliant() bool

IsTetheredCompliant checks if the TETHERED mode is eligible accordingly to current status. The result can be used to display information.

func (*Status) Mode

func (st *Status) Mode() StatMode

Mode returns the current working mode of Liqo.

func (*Status) Peer

func (st *Status) Peer(clusterId string) (peer *PeerInfo, present bool)

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

func (st *Status) Peers() int

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) Running

func (st *Status) Running() StatRun

Running returns the running status of Liqo.

func (*Status) SetClusterName

func (st *Status) SetClusterName(clusterName string)

SetClusterName sets the common name of the cluster LiqoAgent is currently connected to.

func (*Status) SetMode

func (st *Status) SetMode(mode StatMode) error

SetMode sets the working mode for Liqo. If the operation is not allowed for current configuration, it returns an error.

func (*Status) SetRunning

func (st *Status) SetRunning(running StatRun)

SetRunning changes the running status of Liqo. Transition to StatRunOff implies the end of all active peerings.

func (*Status) SetUser

func (st *Status) SetUser(user string)

SetUser sets the Liqo Name of the home cluster connected to the Agent.

func (*Status) User

func (st *Status) User() string

User returns the Liqo Name of the home cluster connected to the Agent.

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.

func (*Timer) Active

func (t *Timer) Active() bool

Active returns if the Timer is currently active, i.e. timed calls of the associated callback are allowed.

func (*Timer) SetActive

func (t *Timer) SetActive(active bool)

SetActive controls the Timer behavior, allowing or not future calls of the associated callback.

Jump to

Keyboard shortcuts

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