Documentation
¶
Index ¶
- Constants
- Variables
- func ByteArrayToString(b []byte) string
- func BytesToInteger(b []byte) int32
- func BytesToLong(b []byte) int64
- func BytesToShort(b []byte) int16
- func BytesToString(b []byte) string
- func CopyOfRange(src []byte, from, to int) []byte
- func ExecuteCommand(command string) (string, string, error)
- func ExecuteCommandSafe(command string, timeoutSeconds int) (string, error)
- func GetConfigDir() string
- func IntegerToBytes(x int32) []byte
- func IsAnotherInstanceRunning() bool
- func LongToBytes(x int64) []byte
- func RemovePIDFile() error
- func ShortToBytes(x int16) []byte
- func StringToBytes(s string) []byte
- func WritePIDFile() error
- type ConfigSwitcherState
- type DockerStatus
- type Either
- type HTTPClient
- func (c *HTTPClient) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *HTTPClient) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *HTTPClient) GetJSON(ctx context.Context, path string, result any) error
- func (c *HTTPClient) Ping(ctx context.Context) (bool, error)
- func (c *HTTPClient) Post(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *HTTPClient) PostJSON(ctx context.Context, path string, body any, result any) error
- func (c *HTTPClient) Put(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *HTTPClient) SetControllerCert(cert *x509.Certificate) error
- func (c *HTTPClient) SetJWTToken(token string)
- type Left
- type LinkStatus
- type LocalLogHandler
- type LocalLogReader
- type ModulesStatus
- type Pair
- type Right
- type TailConfig
- type Unit
Constants ¶
const ( NumberOfModules = 7 ResourceConsumptionManager = 0 ProcessManager = 1 StatusReporter = 2 EdgeletAPI = 3 FieldAgent = 4 ResourceManager = 5 GPSManager = 6 )
Module indices
Size constants
const ( OSGroup = "edgelet" EdgeletDockerContainerNamePrefix = "edgelet_" MicroserviceFile = "microservices.json" )
System constants
const ( FieldAgentPingController = "FAPC" FieldAgentGetChangeList = "FACL" FieldAgentPostStatus = "FAPS" FieldAgentPostDiagnostic = "FAPD" StatusReporterSetStatusReporterSystemTime = "SRST" EdgeletAPIEvent = "LAPI" ResourceConsumptionManagerGetUsageData = "RCUD" ProcessManagerContainersMonitor = "PMCM" ProcessManagerCheckTasks = "PMCT" ResourceManagerGetUsageData = "RMUD" EdgeletAPIControlWebSocketWorker = "LACW" EdgeletAPIMessageWebSocketWorker = "LAMW" ShutdownHook = "SDHK" SupervisorCheckEdgeletAPIStatus = "SCLA" NetworkInterfaceManager = "INIM" )
Event constants
const ( MaxDiskConsumptionLimit = 100.0 PercentageCompletion = 100.0 )
Limits
const (
// PIDFileName is the exported name for the PID file
PIDFileName = pidFileName
)
Variables ¶
var ( SNAP = getEnvOrDefault("SNAP", "") SNAPCommon = getEnvOrDefault("SNAP_COMMON", "") )
Environment variables
var ( WindowsEdgeletPath = getEnvOrDefault("EDGELET_PATH", "./") VarRun = getVarRunPath() ConfigDir = getConfigDir() EdgeletAPITokenPath = ConfigDir + "edgelet-api" ConfigYAMLPath = ConfigDir + "config.yaml" BackupConfigYAMLPath = ConfigDir + "config-bck.yaml" )
Path constants
var (
ErrInvalidSwitcherState = errors.New("invalid switcher state")
)
Functions ¶
func ByteArrayToString ¶
ByteArrayToString returns a string representation of a byte array Example: []byte{1, 2, 3, 4} => "[1, 2, 3, 4]"
func BytesToInteger ¶
BytesToInteger converts a byte array to an integer (int32)
func BytesToLong ¶
BytesToLong converts a byte array to a long (int64)
func BytesToShort ¶
BytesToShort converts a byte array to a short (int16)
func BytesToString ¶
BytesToString converts a byte array to a string (UTF-8)
func CopyOfRange ¶
CopyOfRange copies a range of bytes from src
func ExecuteCommand ¶
ExecuteCommand executes a shell command and returns the output
func ExecuteCommandSafe ¶
ExecuteCommandSafe executes a command with timeout and safety checks
func GetConfigDir ¶
func GetConfigDir() string
GetConfigDir returns the config directory (can be called dynamically) This allows recalculation of config path when SNAP_COMMON changes (e.g., in dev environment)
func IntegerToBytes ¶
IntegerToBytes converts an integer (int32) to a byte array
func IsAnotherInstanceRunning ¶
func IsAnotherInstanceRunning() bool
IsAnotherInstanceRunning checks if another instance of the daemon is running
func LongToBytes ¶
LongToBytes converts a long (int64) to a byte array
func ShortToBytes ¶
ShortToBytes converts a short (int16) to a byte array
func StringToBytes ¶
StringToBytes converts a string to a byte array (UTF-8)
Types ¶
type ConfigSwitcherState ¶
type ConfigSwitcherState string
ConfigSwitcherState represents configuration profile state
const ( ConfigSwitcherStateDefault ConfigSwitcherState = "default" ConfigSwitcherStateDevelopment ConfigSwitcherState = "development" ConfigSwitcherStateProduction ConfigSwitcherState = "production" )
func ParseConfigSwitcherState ¶
func ParseConfigSwitcherState(s string) (ConfigSwitcherState, error)
ParseConfigSwitcherState parses a string to ConfigSwitcherState
func (ConfigSwitcherState) FullValue ¶
func (s ConfigSwitcherState) FullValue() string
FullValue returns the full value string for the state
type DockerStatus ¶
type DockerStatus string
DockerStatus represents Docker daemon status
const ( DockerStatusNotPresent DockerStatus = "NOT_PRESENT" DockerStatusRunning DockerStatus = "RUNNING" DockerStatusStopped DockerStatus = "STOPPED" )
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a wrapper around http.Client with retry logic and JWT support
func NewHTTPClient ¶
func NewHTTPClient(baseURL string) *HTTPClient
NewHTTPClient creates a new HTTP client
func (*HTTPClient) Ping ¶
func (c *HTTPClient) Ping(ctx context.Context) (bool, error)
Ping performs a ping request to check connectivity
func (*HTTPClient) PostJSON ¶
PostJSON performs a POST request with JSON body and unmarshals the JSON response
func (*HTTPClient) SetControllerCert ¶
func (c *HTTPClient) SetControllerCert(cert *x509.Certificate) error
SetControllerCert sets the controller certificate for TLS
func (*HTTPClient) SetJWTToken ¶
func (c *HTTPClient) SetJWTToken(token string)
SetJWTToken sets the JWT token for authentication
type Left ¶
type Left[T any] struct { // contains filtered or unexported fields }
Left represents an error value
type LinkStatus ¶
type LinkStatus string
LinkStatus represents link status
const ( LinkStatusFailedVerification LinkStatus = "FAILED_VERIFICATION" LinkStatusFailedLogin LinkStatus = "FAILED_LOGIN" LinkStatusConnected LinkStatus = "CONNECTED" )
type LocalLogHandler ¶
type LocalLogHandler interface {
OnLogLine(sessionID, iofogUUID, line string)
OnComplete(sessionID string)
OnError(sessionID string, err error)
}
LocalLogHandler is the interface for handling log lines
type LocalLogReader ¶
type LocalLogReader struct {
// contains filtered or unexported fields
}
LocalLogReader reads and streams agent self logs from local log files
func NewLocalLogReader ¶
func NewLocalLogReader(sessionID, iofogUUID, logDirectory string, tailConfig *TailConfig, handler LocalLogHandler) *LocalLogReader
NewLocalLogReader creates a new LocalLogReader
func (*LocalLogReader) IsRunning ¶
func (llr *LocalLogReader) IsRunning() bool
IsRunning returns whether the reader is running
type ModulesStatus ¶
type ModulesStatus string
ModulesStatus represents the status of a module
const ( ModulesStatusStarting ModulesStatus = "STARTING" ModulesStatusRunning ModulesStatus = "RUNNING" ModulesStatusStopped ModulesStatus = "STOPPED" ModulesStatusWarning ModulesStatus = "WARNING" )
type Right ¶
type Right[T any] struct { // contains filtered or unexported fields }
Right represents a success value