Documentation
¶
Overview ¶
Package utils contains various helpers.
Index ¶
- Constants
- Variables
- func GetCurrentWorkingDir() string
- func GetDefaultConfigsDir() string
- func GetRandomName() string
- func IsLongTimeNoSee(lastSeen int64) bool
- func NewCron() providers.ICronProvider
- func NewPluginLoader(ctor *ConstructPluginLoader) providers.IPluginLoaderProvider
- func NewValidator(logger common.ILoggerProvider) providers.IValidatorProvider
- func NormalizeDeviceName(raw string) string
- func TimeNow() int64
- func VerifyDeviceProvider(configType string) enums.DeviceType
- type ConstructPluginLoader
- type ErrDownload
- type ErrInitPanic
- type ErrInvalidConfig
- type ErrNoEntryPoint
- type ErrNoInit
- type ErrWrongInterface
- type ErrWrongSettingsSignature
- type ErrWrongSignature
Constants ¶
const ( // PluginEntryPointMethodName is the name of main plugin method. PluginEntryPointMethodName = "Load" // PluginInterfaceInitMethodName is the name of first initialization method. PluginInterfaceInitMethodName = "Init" // PluginCDNUrlFormat is format for bintray CDN. PluginCDNUrlFormat = "https://dl.bintray.com/go-home-io/%s/%s" )
Variables ¶
var Arch string
Arch describes build architecture.
var ConfigDir = ""
ConfigDir allows to re-write default config directory.
var LongTimeNoSee int64 = 2 * 60
LongTimeNoSee defines for how long worker/master is treated as a live server.
var Version string
Version describes build version.
Functions ¶
func GetCurrentWorkingDir ¶
func GetCurrentWorkingDir() string
GetCurrentWorkingDir returns application working directory.
func GetDefaultConfigsDir ¶
func GetDefaultConfigsDir() string
GetDefaultConfigsDir returns default config directory which is cwd/configs.
func GetRandomName ¶
func GetRandomName() string
GetRandomName returns random name for the device. Method uses Docker names generator.
func IsLongTimeNoSee ¶
IsLongTimeNoSee checks whether worker/master wasn't seen for a long time.
func NewPluginLoader ¶
func NewPluginLoader(ctor *ConstructPluginLoader) providers.IPluginLoaderProvider
NewPluginLoader creates a new plugins loader.
func NewValidator ¶
func NewValidator(logger common.ILoggerProvider) providers.IValidatorProvider
NewValidator constructs a new validator.
func NormalizeDeviceName ¶
NormalizeDeviceName validates that final device name is correct.
func VerifyDeviceProvider ¶
func VerifyDeviceProvider(configType string) enums.DeviceType
VerifyDeviceProvider transforms device provider from yaml config into actual type.
Types ¶
type ConstructPluginLoader ¶
type ConstructPluginLoader struct { PluginsFolder string PluginsProxy string Validator providers.IValidatorProvider Logger common.ILoggerProvider }
ConstructPluginLoader contains params required for creating a new plugin loader instance.
type ErrInvalidConfig ¶
type ErrInvalidConfig struct { }
ErrInvalidConfig defines wrong configuration error.
type ErrNoEntryPoint ¶
type ErrNoEntryPoint struct { }
ErrNoEntryPoint defines an absent Load method in a plugin.
type ErrNoInit ¶
type ErrNoInit struct { }
ErrNoInit defines an absent Init method in a plugin interface.
type ErrWrongInterface ¶
type ErrWrongInterface struct { }
ErrWrongInterface defines unexpected interface implemented by plugin.
type ErrWrongSettingsSignature ¶
type ErrWrongSettingsSignature struct { }
ErrWrongSettingsSignature defines unexpected interface implemented by plugin's settings object.
func (*ErrWrongSettingsSignature) Error ¶
func (*ErrWrongSettingsSignature) Error() string
Error formats output.
type ErrWrongSignature ¶
type ErrWrongSignature struct { }
ErrWrongSignature defines that Load method has wrong params.