utils

package
v0.0.0-...-8f3712b Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package utils contains various helpers.

Index

Constants

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

View Source
var Arch string

Arch describes build architecture.

View Source
var ConfigDir = ""

ConfigDir allows to re-write default config directory.

View Source
var LongTimeNoSee int64 = 2 * 60

LongTimeNoSee defines for how long worker/master is treated as a live server.

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

func IsLongTimeNoSee(lastSeen int64) bool

IsLongTimeNoSee checks whether worker/master wasn't seen for a long time.

func NewCron

func NewCron() providers.ICronProvider

NewCron creates a new scheduler.

func NewPluginLoader

NewPluginLoader creates a new plugins loader.

func NewValidator

NewValidator constructs a new validator.

func NormalizeDeviceName

func NormalizeDeviceName(raw string) string

NormalizeDeviceName validates that final device name is correct.

func TimeNow

func TimeNow() int64

TimeNow returns epoch UTC.

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 ErrDownload

type ErrDownload struct {
}

ErrDownload defines download error.

func (*ErrDownload) Error

func (*ErrDownload) Error() string

Error formats output.

type ErrInitPanic

type ErrInitPanic struct {
}

ErrInitPanic defines a panic during the Init call.

func (*ErrInitPanic) Error

func (*ErrInitPanic) Error() string

Error formats output.

type ErrInvalidConfig

type ErrInvalidConfig struct {
}

ErrInvalidConfig defines wrong configuration error.

func (*ErrInvalidConfig) Error

func (*ErrInvalidConfig) Error() string

Error formats output.

type ErrNoEntryPoint

type ErrNoEntryPoint struct {
}

ErrNoEntryPoint defines an absent Load method in a plugin.

func (*ErrNoEntryPoint) Error

func (*ErrNoEntryPoint) Error() string

Error formats output.

type ErrNoInit

type ErrNoInit struct {
}

ErrNoInit defines an absent Init method in a plugin interface.

func (*ErrNoInit) Error

func (*ErrNoInit) Error() string

Error formats output.

type ErrWrongInterface

type ErrWrongInterface struct {
}

ErrWrongInterface defines unexpected interface implemented by plugin.

func (*ErrWrongInterface) Error

func (*ErrWrongInterface) Error() string

Error formats output.

type ErrWrongSettingsSignature

type ErrWrongSettingsSignature struct {
}

ErrWrongSettingsSignature defines unexpected interface implemented by plugin's settings object.

func (*ErrWrongSettingsSignature) Error

Error formats output.

type ErrWrongSignature

type ErrWrongSignature struct {
}

ErrWrongSignature defines that Load method has wrong params.

func (*ErrWrongSignature) Error

func (*ErrWrongSignature) Error() string

Error formats output.

Jump to

Keyboard shortcuts

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