common

package
v1.0.1-0...-a908c99 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientData     = "Data"
	ClientMetadata = "Metadata"
	ClientLogging  = "Logging"

	APIv1Prefix = "/api/v1"
	Colon       = ":"
	HttpScheme  = "http://"
	HttpProto   = "HTTP"

	ConfigDirectory    = "./res"
	ConfigFileName     = "configuration.toml"
	ConfigRegistryStem = "edgex/devices/1.0/"
	WritableKey        = "/Writable"
	RegistryFailLimit  = 3

	APICallbackRoute        = APIv1Prefix + "/callback"
	APIValueDescriptorRoute = APIv1Prefix + "/valuedescriptor"
	APIDiscoveryRoute       = APIv1Prefix + "/discovery"
	APIPingRoute            = APIv1Prefix + "/ping"

	IdVar        string = "id"
	NameVar      string = "name"
	CommandVar   string = "command"
	GetCmdMethod string = "get"
	SetCmdMethod string = "set"

	CorrelationHeader = clients.CorrelationHeader
)

Variables

View Source
var (
	ServiceName           string
	ServiceVersion        string
	CurrentConfig         *Config
	CurrentDeviceService  contract.DeviceService
	UseRegistry           bool
	ServiceLocked         bool
	Driver                dsModels.ProtocolDriver
	EventClient           coredata.EventClient
	AddressableClient     metadata.AddressableClient
	DeviceClient          metadata.DeviceClient
	DeviceServiceClient   metadata.DeviceServiceClient
	DeviceProfileClient   metadata.DeviceProfileClient
	LoggingClient         logger.LoggingClient
	ValueDescriptorClient coredata.ValueDescriptorClient
)

Functions

func BuildAddr

func BuildAddr(host string, port string) string

func CommandValueToReading

func CommandValueToReading(cv *dsModels.CommandValue, devName string, encoding string) *contract.Reading

func CompareCoreCommands

func CompareCoreCommands(a []contract.Command, b []contract.Command) bool

func CompareDeviceCommands

func CompareDeviceCommands(a []contract.ProfileResource, b []contract.ProfileResource) bool

func CompareDeviceProfiles

func CompareDeviceProfiles(a contract.DeviceProfile, b contract.DeviceProfile) bool

func CompareDeviceResources

func CompareDeviceResources(a []contract.DeviceResource, b []contract.DeviceResource) bool

func CompareDeviceServices

func CompareDeviceServices(a contract.DeviceService, b contract.DeviceService) bool

func CompareDevices

func CompareDevices(a contract.Device, b contract.Device) bool

func CompareResourceOperations

func CompareResourceOperations(a []contract.ResourceOperation, b []contract.ResourceOperation) bool

func CompareStrStrMap

func CompareStrStrMap(a map[string]string, b map[string]string) bool

func CompareStrings

func CompareStrings(a []string, b []string) bool

func SendEvent

func SendEvent(event *dsModels.Event)

func VerifyIdFormat

func VerifyIdFormat(id string, drName string) error

Types

type AppError

type AppError interface {
	Error() error
	Message() string
	Code() int
}

func NewBadRequestError

func NewBadRequestError(msg string, err error) AppError

func NewLockedError

func NewLockedError(msg string, err error) AppError

func NewNotFoundError

func NewNotFoundError(msg string, err error) AppError

func NewServerError

func NewServerError(msg string, err error) AppError

type ClientInfo

type ClientInfo struct {
	// Name is the client service name
	Name string
	// Host is the hostname or IP address of a service.
	Host string
	// Port defines the port on which to access a given service
	Port int
	// Protocol indicates the protocol to use when accessing a given service
	Protocol string
	// Timeout specifies a timeout (in milliseconds) for
	// processing REST calls from other services.
	Timeout int
}

ClientInfo provides the host and port of another service in the eco-system.

func (ClientInfo) Url

func (c ClientInfo) Url() string

type Config

type Config struct {
	// WritableInfo contains configuration settings that can be changed in the Registry .
	Writable WritableInfo
	// Service contains RegistryService-specific settings.
	Service ServiceInfo
	// Registry contains registry-specific settings.
	Registry RegistryService
	// Clients is a map of services used by a DS.
	Clients map[string]ClientInfo
	// Device contains device-specific configuration settings.
	Device DeviceInfo
	// Logging contains logging-specific configuration settings.
	Logging LoggingInfo
	// Watchers is a map provisionwatchers to be created on startup.
	Watchers map[string]WatcherInfo
	// DeviceList is the list of pre-define Devices
	DeviceList []DeviceConfig `consul:"-"`
	// Driver is a string map contains customized configuration for the protocol driver implemented based on Device SDK
	Driver map[string]string
}

Config is a struct which contains all of a DS's configuration settings.

type DeviceConfig

type DeviceConfig struct {
	// Name is the Device name
	Name string
	// Profile is the profile name of the Device
	Profile string

	Description string
	// Other labels applied to the device to help with searching
	Labels []string
	// Protocols for the device - stores protocol properties
	Protocols map[string]dsModels.ProtocolProperties
	// AutoEvent supports auto-generated events sourced from a device service
	AutoEvents []dsModels.AutoEvent
}

DeviceConfig is the definition of Devices which will be auto created when the Device Service starts up

type DeviceInfo

type DeviceInfo struct {
	// DataTransform specifies whether or not the DS perform transformations
	// specified by valuedescriptor on a actuation or query command.
	DataTransform bool
	// InitCmd specifies a device resource command which is automatically
	// generated whenever a new device is added to the DS.
	InitCmd string
	// InitCmdArgs specify arguments to be used when building the InitCmd.
	InitCmdArgs string
	// MaxCmdOps defines the maximum number of resource operations that
	// can be sent to a Driver in a single command.
	MaxCmdOps int
	// MaxCmdValueLen is the maximum string length of a command parameter or
	// result (including the valuedescriptor name) that can be returned
	// by a Driver.
	MaxCmdValueLen int
	// InitCmd specifies a device resource command which is automatically
	// generated whenever a new device is removed from the DS.
	RemoveCmd string
	// RemoveCmdArgs specify arguments to be used when building the RemoveCmd.
	RemoveCmdArgs string
	// ProfilesDir specifies a directory which contains deviceprofile
	// files which should be imported on startup.
	ProfilesDir string
}

DeviceInfo is a struct which contains device specific configuration settings.

type LoggingInfo

type LoggingInfo struct {
	// EnableRemote defines whether to use Logging Service
	EnableRemote bool
	// File is the pathname of a local log file to be created.
	File string
}

LoggingInfo is a struct which contains logging specific configuration settings.

type RegistryService

type RegistryService struct {
	// Host is the hostname or IP address of a RegistryService.
	Host string
	// Port is the HTTP port of a RegistryService.
	Port int
	// Type of Registry implementation to use, i.e. consul
	Type string
	// Timeout specifies a timeout (in milliseconds) for
	// processing REST calls from other services.
	Timeout int
	// Health check interval
	CheckInterval string
	// Maximum number of retries
	FailLimit int
	// Time to wait until next retry
	FailWaitTime int64
}

type ServiceInfo

type ServiceInfo struct {
	// Host is the hostname or IP address of the service.
	Host string
	// Port is the HTTP port of the service.
	Port int
	// ConnectRetries is the number of times the DS will try to connect to all dependent services.
	// If exceeded for even one dependent service, the DS will exit.
	ConnectRetries int
	// Labels are...
	Labels []string
	// OpenMsg specifies a string logged on DS startup.
	OpenMsg string
	// Timeout (in milliseconds) specifies both
	// - timeout for processing REST calls and
	// - interval time the DS will wait between each retry call.
	Timeout int
	// EnableAsyncReadings to determine whether the Device Service would deal with the asynchronous readings
	EnableAsyncReadings bool
	// AsyncBufferSize defines the size of asynchronous channel
	AsyncBufferSize int
}

ServiceInfo is a struct which contains service related configuration settings.

type Telemetry

type Telemetry struct {
	Alloc,
	TotalAlloc,
	Sys,
	Mallocs,
	Frees,
	LiveObjects uint64
}

Telemetry provides metrics (on a given device service) to system management.

type WatcherInfo

type WatcherInfo struct {
	Profile     string
	Key         string
	MatchString string
}

WatcherInfo is a struct which contains provisionwatcher configuration settings.

type WritableInfo

type WritableInfo struct {
	// Level is the logging level of writing log message
	LogLevel string
}

WritableInfo is a struct which contains configuration settings that can be changed in the Registry .

Jump to

Keyboard shortcuts

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