tray

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdderConfigPath

func AdderConfigPath() string

AdderConfigPath returns the path to the adder config file in the config directory.

func ConfigDir

func ConfigDir() string

ConfigDir returns the platform-specific directory for storing configuration files. It can be overridden by the ADDER_TRAY_CONFIG_DIR environment variable.

func ConfigExists

func ConfigExists() bool

ConfigExists reports whether the configuration file exists on disk.

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to the tray configuration file.

func DefaultIconBytes added in v0.40.0

func DefaultIconBytes() []byte

DefaultIconBytes returns the raw bytes for the default gray icon.

func GenerateAdderConfig

func GenerateAdderConfig(params AdderConfigParams) ([]byte, error)

GenerateAdderConfig builds an adder configuration from the given parameters. The API server is always enabled because adder-tray connects to its /events endpoint for desktop notifications and /healthcheck for status monitoring.

func GetStatusIcon added in v0.40.0

func GetStatusIcon(s Status) fyne.Resource

GetStatusIcon returns a fyne.Resource with the branded logo filtered by status.

func LogDir

func LogDir() string

LogDir returns the platform-specific directory for storing log files. It can be overridden by the ADDER_TRAY_LOG_DIR environment variable.

func SaveConfig

func SaveConfig(cfg TrayConfig) error

SaveConfig writes the tray configuration to disk, creating the config directory if necessary.

func WriteAdderConfig

func WriteAdderConfig(params AdderConfigParams) error

WriteAdderConfig writes the adder configuration to the config directory.

Types

type AdderConfigParams

type AdderConfigParams struct {
	Network  string
	Template MonitorTemplate
	Param    string // The address/drep/pool value depending on Template
	Output   string // Output plugin name (default: "log")
	Format   string // Output format (default: "json")
}

AdderConfigParams holds the parameters for generating an adder configuration.

type App

type App struct {
	// contains filtered or unexported fields
}

App holds references to all major components of the tray application.

func NewApp

func NewApp(fyneApp fyne.App) (*App, error)

NewApp creates and initialises the tray application.

func (*App) Config added in v0.40.0

func (a *App) Config() TrayConfig

Config returns a consistent snapshot of the current tray configuration. It is safe to call from any goroutine.

func (*App) Run

func (a *App) Run()

Run configures the system tray and starts the application loop.

func (*App) Shutdown

func (a *App) Shutdown()

Shutdown requests a graceful shutdown of the tray application.

type ConnectionManager added in v0.40.0

type ConnectionManager struct {
	// contains filtered or unexported fields
}

ConnectionManager manages the EventClient WS connection to adder's API. It replaces the old ProcessManager — the tray no longer manages adder as a subprocess but connects to it as an API client.

func NewConnectionManager added in v0.40.0

func NewConnectionManager(opts ...ConnectionOption) *ConnectionManager

NewConnectionManager creates a ConnectionManager with the given options.

func (*ConnectionManager) Connect added in v0.40.0

func (cm *ConnectionManager) Connect() error

Connect creates and starts an EventClient that connects to adder's /events WebSocket endpoint. Returns an error if already connected.

func (*ConnectionManager) Disconnect added in v0.40.0

func (cm *ConnectionManager) Disconnect()

Disconnect stops the EventClient and cleans up.

func (*ConnectionManager) Events added in v0.40.0

func (cm *ConnectionManager) Events() <-chan event.Event

Events returns a read-only channel of events received from adder.

func (*ConnectionManager) IsConnected added in v0.40.0

func (cm *ConnectionManager) IsConnected() bool

IsConnected reports whether the EventClient is actively connected.

func (*ConnectionManager) Reconnect added in v0.40.0

func (cm *ConnectionManager) Reconnect() error

Reconnect atomically disconnects and reconnects under a single lock acquisition, so concurrent Connect/Disconnect/Reconnect callers cannot interleave and leave the manager in an inconsistent state (e.g., Reconnect reporting "already connected" because another goroutine raced in between the inner Disconnect and Connect).

func (*ConnectionManager) SetAddress added in v0.40.0

func (cm *ConnectionManager) SetAddress(address string)

SetAddress updates the adder API address for future connections.

func (*ConnectionManager) SetPort added in v0.40.0

func (cm *ConnectionManager) SetPort(port uint)

SetPort updates the adder API port for future connections.

type ConnectionOption added in v0.40.0

type ConnectionOption func(*ConnectionManager)

ConnectionOption is a functional option for ConnectionManager.

func WithConnectionAddress added in v0.40.0

func WithConnectionAddress(address string) ConnectionOption

WithConnectionAddress sets the adder API address.

func WithConnectionPort added in v0.40.0

func WithConnectionPort(port uint) ConnectionOption

WithConnectionPort sets the adder API port.

func WithConnectionStatusTracker added in v0.40.0

func WithConnectionStatusTracker(t *StatusTracker) ConnectionOption

WithConnectionStatusTracker sets a StatusTracker that the manager updates as the connection state changes.

type EventClient added in v0.39.0

type EventClient struct {
	// contains filtered or unexported fields
}

EventClient connects to adder's /events WebSocket endpoint and delivers parsed events on a channel. It reconnects automatically with exponential backoff when the connection drops.

func NewEventClient added in v0.39.0

func NewEventClient(
	address string,
	port uint,
	opts ...EventClientOption,
) *EventClient

NewEventClient creates an EventClient that will connect to the given address and port.

func (*EventClient) Events added in v0.39.0

func (c *EventClient) Events() <-chan event.Event

Events returns a read-only channel of events received from the server.

func (*EventClient) Start added in v0.39.0

func (c *EventClient) Start() error

Start begins the background connection loop. Returns an error if already started.

func (*EventClient) Stop added in v0.39.0

func (c *EventClient) Stop()

Stop closes the connection and stops reconnection. It is safe to call multiple times or without a prior Start.

type EventClientOption added in v0.39.0

type EventClientOption func(*EventClient)

EventClientOption is a functional option for EventClient.

func WithEventStatusTracker added in v0.39.0

func WithEventStatusTracker(t *StatusTracker) EventClientOption

WithEventStatusTracker sets a StatusTracker that the client updates as its connection state changes. A nil tracker is ignored.

func WithEventTypes added in v0.39.0

func WithEventTypes(types []string) EventClientOption

WithEventTypes sets the event types to subscribe to. The types are sent as a query parameter on the WS URL for server-side filtering.

type MonitorTemplate

type MonitorTemplate int

MonitorTemplate represents a pre-configured monitoring template.

const (
	WatchWallet MonitorTemplate = iota
	TrackDRep
	MonitorPool
)

func (MonitorTemplate) String

func (t MonitorTemplate) String() string

String returns the display name of the template.

type Status added in v0.39.0

type Status int

Status represents the connection status of the tray application.

const (
	StatusStopped      Status = iota
	StatusStarting            // connecting to WS endpoint
	StatusConnected           // WS connection established
	StatusReconnecting        // WS connection lost, retrying
	StatusError               // unrecoverable error
)

func (Status) String added in v0.39.0

func (s Status) String() string

String returns a human-readable status label.

type StatusTracker added in v0.39.0

type StatusTracker struct {
	// contains filtered or unexported fields
}

StatusTracker provides thread-safe status tracking with change notification. It notifies an optional observer when the status changes.

func NewStatusTracker added in v0.39.0

func NewStatusTracker() *StatusTracker

NewStatusTracker creates a StatusTracker with initial status StatusStopped.

func (*StatusTracker) OnChange added in v0.39.0

func (t *StatusTracker) OnChange(fn func(Status))

OnChange registers a callback that is invoked whenever the status changes. It is immediately called once with the current status synchronously. Only one observer can be registered at a time.

func (*StatusTracker) Set added in v0.39.0

func (t *StatusTracker) Set(s Status)

Set updates the status and notifies the observer asynchronously if the status changed.

func (*StatusTracker) Status added in v0.39.0

func (t *StatusTracker) Status() Status

Status returns the current status.

type TrayConfig

type TrayConfig = setup.TrayConfig

TrayConfig is an alias for setup.TrayConfig to maintain backward compatibility.

func DefaultConfig

func DefaultConfig() TrayConfig

DefaultConfig returns a TrayConfig with sensible defaults.

func LoadConfig

func LoadConfig() (TrayConfig, error)

LoadConfig reads the tray configuration from disk. If the file does not exist, it returns the default configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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