providers

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: 9 Imported by: 0

Documentation

Overview

Package providers contains interfaces for internal system providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BakedRule

type BakedRule struct {
	Resources []glob.Glob
	System    SecSystem
	Get       bool
	Command   bool
	History   bool
}

BakedRule is a helper type with pre-compiled regexps.

type IAuthenticatedUser

type IAuthenticatedUser interface {
	Name() string
	DeviceGet(string) bool
	DeviceCommand(string) bool
	DeviceHistory(string) bool
	TriggerGet(string) bool
	TriggerHistory(string) bool
	Workers() bool
	Entities() bool
	Logs() bool
}

IAuthenticatedUser describes authenticated user.

type IBusProvider

type IBusProvider interface {
	Subscribe(channel bus.ChannelName, queue chan bus.RawMessage) error
	SubscribeStr(channel string, queue chan bus.RawMessage) error
	SubscribeToWorker(workerName string, queue chan bus.RawMessage) error
	Unsubscribe(channel string)
	Publish(channel bus.ChannelName, messages ...interface{})
	PublishStr(channel string, messages ...interface{})
	PublishToWorker(workerName string, messages ...interface{})
	Ping() error
}

IBusProvider defines service bus provider logic.

type ICronProvider

type ICronProvider interface {
	AddFunc(spec string, cmd func()) (int, error)
	RemoveFunc(id int)
}

ICronProvider defines cron provider logic.

type IExtendedAPIProvider

type IExtendedAPIProvider interface {
	ILoadedProvider
	ID() string
	Routes() []string
}

IExtendedAPIProvider describes extended API wrapper.

type IGroupProvider

type IGroupProvider interface {
	ID() string
	Devices() []string
	InvokeCommand(enums.Command, map[string]interface{})
}

IGroupProvider describes group device provider.

type IInternalFanOutProvider

type IInternalFanOutProvider interface {
	common.IFanOutProvider

	ChannelInDeviceUpdates() chan *common.MsgDeviceUpdate
	SubscribeTriggerUpdates() (int64, chan string)
	UnSubscribeTriggerUpdates(int64)
	ChannelInTriggerUpdates() chan string
}

IInternalFanOutProvider defines internal interface for the fan-out channel. It extends regular IFanOutProvider which is available for plugins.

type IInternalSecret

type IInternalSecret interface {
	common.ISecretProvider
	UpdateLogger(pluginLogger common.ILoggerProvider)
}

IInternalSecret defines internal secret provider wrapper.

type ILoadedProvider

type ILoadedProvider interface {
	Unload()
}

ILoadedProvider describes loaded provider.

type ILocationProvider

type ILocationProvider interface {
	ID() string
	Icon() string
	Devices() []string
}

ILocationProvider defines UI location.

type INotificationProvider

type INotificationProvider interface {
	GetID() string
	Message(string)
}

INotificationProvider defines notification provider.

type IPluginLoaderProvider

type IPluginLoaderProvider interface {
	LoadPlugin(*PluginLoadRequest) (interface{}, error)
	UpdateLogger(common.ILoggerProvider)
}

IPluginLoaderProvider defines plugin loader provider logic.

type ISecurityProvider

type ISecurityProvider interface {
	GetUser(map[string][]string) (IAuthenticatedUser, error)
}

ISecurityProvider defines security provider.

type IServerProvider

type IServerProvider interface {
	Start()
	InternalCommandInvokeDeviceCommand(glob.Glob, enums.Command, map[string]interface{})
	SendNotificationCommand(glob.Glob, string)
	GetDevice(string) *KnownDevice
	PushMasterDeviceUpdate(*MasterDeviceUpdate)
}

IServerProvider defines server interface which is required by some other internal systems.

type ISettingsProvider

type ISettingsProvider interface {
	SystemLogger() common.ILoggerProvider
	PluginLogger() common.ILoggerProvider
	ServiceBus() IBusProvider
	NodeID() string
	Cron() ICronProvider
	PluginLoader() IPluginLoaderProvider
	Validator() IValidatorProvider
	WorkerSettings() *WorkerSettings
	MasterSettings() *MasterSettings
	IsWorker() bool
	DevicesConfig() []*RawDevice
	Secrets() common.ISecretProvider
	Security() ISecurityProvider
	Triggers() []*RawMasterComponent
	ExtendedAPIs() []*RawMasterComponent
	Notifications() []*RawMasterComponent
	Groups() []*RawMasterComponent
	FanOut() IInternalFanOutProvider
	Storage() IStorageProvider
	Timezone() *time.Location
}

ISettingsProvider defines settings loader provider logic.

type IStorageProvider

type IStorageProvider interface {
	Heartbeat(string)
	State(*common.MsgDeviceUpdate)
	History(string) map[enums.Property]map[int64]interface{}
}

IStorageProvider defines state history storage provider.

type ITriggerProvider

type ITriggerProvider interface {
	GetID() string
	GetLastTriggeredTime() int64
}

ITriggerProvider defines events-trigger.

type IValidatorProvider

type IValidatorProvider interface {
	SetLogger(logger common.ILoggerProvider)
	Validate(interface{}) bool
}

IValidatorProvider defines yaml structures validator logic.

type KnownDevice

type KnownDevice struct {
	Worker   string
	Type     enums.DeviceType
	Commands []string
}

KnownDevice contains data about known device.

type MasterDeviceUpdate

type MasterDeviceUpdate struct {
	ID       string
	Name     string
	State    map[string]interface{}
	Commands []string
	Type     enums.DeviceType
}

MasterDeviceUpdate contains data required for pushing update for device running on master. Usually it's a group.

type MasterSettings

type MasterSettings struct {
	Port         int                   `yaml:"port" validate:"required,port" default:"8000"`
	DelayedStart int                   `yaml:"delayedStart" validate:"gte=0"`
	UOM          enums.UOM             `yaml:"units" default:"imperial"`
	Timezone     string                `yaml:"timezone" default:"Local"`
	Locations    []*RawMasterComponent `yaml:"-"`
}

MasterSettings has configured data for master node.

type PluginLoadRequest

type PluginLoadRequest struct {
	SystemType         systems.SystemType
	PluginProvider     string
	RawConfig          []byte
	InitData           interface{}
	ExpectedType       reflect.Type
	DownloadTimeoutSec int
}

PluginLoadRequest has data required for loading a new plugin.

type RawDevice

type RawDevice struct {
	Plugin     string
	DeviceType enums.DeviceType
	Selector   *RawDeviceSelector
	StrConfig  string
	Name       string
	IsAPI      bool
}

RawDevice has data describing data about device, loaded from config files.

type RawDeviceSelector

type RawDeviceSelector struct {
	Name      string            `yaml:"name"`
	Selectors map[string]string `yaml:"workerSelectors"`
}

RawDeviceSelector has data required for understanding which worker should be picked for the device.

type RawMasterComponent

type RawMasterComponent struct {
	Name      string
	Provider  string
	RawConfig []byte
}

RawMasterComponent has configuration for master component.

type SecRole

type SecRole struct {
	Name  string        `yaml:"name" validate:"required"`
	Users []string      `yaml:"users" validate:"unique,min=1"`
	Rules []SecRoleRule `yaml:"rules" validate:"min=1"`
}

SecRole has data, describing single security role.

type SecRoleRule

type SecRoleRule struct {
	System    string    `yaml:"system" validate:"required,oneof=* device core"`
	Resources []string  `yaml:"resources" validate:"unique,min=1"`
	Verbs     []SecVerb `yaml:"-"`
	StrVerb   []string  `yaml:"verbs" validate:"unique,min=1,oneof=* get command history"`
}

SecRoleRule has data, describing single security rule.

type SecSystem

type SecSystem int

SecSystem describes possible role's rule system.

const (
	// SecSystemAll describes all possible systems.
	SecSystemAll SecSystem = iota
	// SecSystemDevice describes devices' system.
	SecSystemDevice
	// SecSystemCore describes core components.
	SecSystemCore
	// SecSystemTrigger describes triggers' system.
	SecSystemTrigger
)

func SecSystemString

func SecSystemString(s string) (SecSystem, error)

SecSystemString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SecSystemValues

func SecSystemValues() []SecSystem

SecSystemValues returns all values of the enum

func (SecSystem) IsASecSystem

func (i SecSystem) IsASecSystem() bool

IsASecSystem returns "true" if the value is listed in the enum definition. "false" otherwise

func (SecSystem) MarshalJSON

func (i SecSystem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for SecSystem

func (SecSystem) MarshalText

func (i SecSystem) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for SecSystem

func (SecSystem) MarshalYAML

func (i SecSystem) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for SecSystem

func (SecSystem) String

func (i SecSystem) String() string

func (*SecSystem) UnmarshalJSON

func (i *SecSystem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for SecSystem

func (*SecSystem) UnmarshalText

func (i *SecSystem) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for SecSystem

func (*SecSystem) UnmarshalYAML

func (i *SecSystem) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for SecSystem

type SecVerb

type SecVerb int

SecVerb describes allowed rules for the role.

const (
	// SecVerbAll describes all allowed operation rules.
	SecVerbAll SecVerb = iota
	// SecVerbGet describes get operation rule.
	SecVerbGet
	// SecVerbCommand describes execute command rule.
	SecVerbCommand
	// SecVerbHistory describes get history command rule
	SecVerbHistory
)

func SecVerbString

func SecVerbString(s string) (SecVerb, error)

SecVerbString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SecVerbValues

func SecVerbValues() []SecVerb

SecVerbValues returns all values of the enum

func (SecVerb) IsASecVerb

func (i SecVerb) IsASecVerb() bool

IsASecVerb returns "true" if the value is listed in the enum definition. "false" otherwise

func (SecVerb) MarshalJSON

func (i SecVerb) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for SecVerb

func (SecVerb) MarshalText

func (i SecVerb) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for SecVerb

func (SecVerb) MarshalYAML

func (i SecVerb) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for SecVerb

func (SecVerb) String

func (i SecVerb) String() string

func (*SecVerb) UnmarshalJSON

func (i *SecVerb) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for SecVerb

func (*SecVerb) UnmarshalText

func (i *SecVerb) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for SecVerb

func (*SecVerb) UnmarshalYAML

func (i *SecVerb) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for SecVerb

type WorkerSettings

type WorkerSettings struct {
	Name       string            `yaml:"name"`
	Properties map[string]string `yaml:"properties"`
	MaxDevices int               `yaml:"maxDevices" validate:"gte=0,lte=1000" default:"99"`
	Timezone   string            `yaml:"timezone" default:"Local"`
}

WorkerSettings has configured data for worker node.

Jump to

Keyboard shortcuts

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