Documentation ¶
Overview ¶
This package provides a basic EdgeX Foundry device service implementation meant to be embedded in an application, similar in approach to the builtin net/http package.
Index ¶
- Constants
- func DriverConfigs() map[string]string
- func Main(serviceName string, serviceVersion string, proto interface{}, ...)
- type Bootstrap
- type DeviceService
- func (s *DeviceService) AddDevice(device models.Device) (string, error)
- func (s *DeviceService) AddDeviceAutoEvent(deviceName string, event models.AutoEvent) error
- func (s *DeviceService) AddDeviceProfile(profile models.DeviceProfile) (string, error)
- func (s *DeviceService) AddProvisionWatcher(watcher models.ProvisionWatcher) (string, error)
- func (s *DeviceService) AddRoute(route string, handler func(http.ResponseWriter, *http.Request), ...) error
- func (s *DeviceService) AsyncReadings() bool
- func (s *DeviceService) DeviceCommand(deviceName string, commandName string) (models.DeviceCommand, bool)
- func (s *DeviceService) DeviceDiscovery() bool
- func (s *DeviceService) DeviceProfiles() []models.DeviceProfile
- func (s *DeviceService) DeviceResource(deviceName string, deviceResource string) (models.DeviceResource, bool)
- func (s *DeviceService) Devices() []models.Device
- func (s *DeviceService) DriverConfigs() map[string]string
- func (s *DeviceService) GetDeviceByName(name string) (models.Device, error)
- func (s *DeviceService) GetLoggingClient() logger.LoggingClient
- func (s *DeviceService) GetMetricsManager() interfaces.MetricsManager
- func (s *DeviceService) GetProfileByName(name string) (models.DeviceProfile, error)
- func (s *DeviceService) GetProvisionWatcherByName(name string) (models.ProvisionWatcher, error)
- func (s *DeviceService) GetSecretProvider() interfaces.SecretProvider
- func (s *DeviceService) Initialize(serviceName, serviceVersion string, proto interface{})
- func (s *DeviceService) ListenForCustomConfigChanges(configToWatch interface{}, sectionName string, ...) error
- func (s *DeviceService) LoadCustomConfig(customConfig UpdatableConfig, sectionName string) error
- func (s *DeviceService) Name() string
- func (s *DeviceService) ProvisionWatchers() []models.ProvisionWatcher
- func (s *DeviceService) RemoveDeviceAutoEvent(deviceName string, event models.AutoEvent) error
- func (s *DeviceService) RemoveDeviceByName(name string) error
- func (s *DeviceService) RemoveDeviceProfileByName(name string) error
- func (s *DeviceService) RemoveProvisionWatcher(name string) error
- func (s *DeviceService) SetDeviceOpState(name string, state models.OperatingState) error
- func (s *DeviceService) Stop(force bool)
- func (s *DeviceService) UpdateDevice(device models.Device) error
- func (s *DeviceService) UpdateDeviceOperatingState(deviceName string, state string) error
- func (s *DeviceService) UpdateDeviceProfile(profile models.DeviceProfile) error
- func (s *DeviceService) UpdateFromContainer(r *mux.Router, dic *di.Container)
- func (s *DeviceService) UpdateProvisionWatcher(watcher models.ProvisionWatcher) error
- func (s *DeviceService) Version() string
- type UpdatableConfig
Constants ¶
const EnvInstanceName = "EDGEX_INSTANCE_NAME"
Variables ¶
This section is empty.
Functions ¶
func DriverConfigs ¶
DriverConfigs retrieves the driver specific configuration TODO remove this in EDGEX3.0
Types ¶
type Bootstrap ¶
type Bootstrap struct {
// contains filtered or unexported fields
}
Bootstrap contains references to dependencies required by the BootstrapHandler.
func NewBootstrap ¶
NewBootstrap is a factory method that returns an initialized Bootstrap receiver struct.
type DeviceService ¶
type DeviceService struct { ServiceName string LoggingClient logger.LoggingClient RegistryClient registry.Client SecretProvider interfaces.SecretProvider MetricsManager interfaces.MetricsManager // contains filtered or unexported fields }
func RunningService ¶
func RunningService() *DeviceService
RunningService returns the Service instance which is running
func (*DeviceService) AddDevice ¶
func (s *DeviceService) AddDevice(device models.Device) (string, error)
AddDevice adds a new Device to the Device Service and Core Metadata Returns new Device id or non-nil error.
func (*DeviceService) AddDeviceAutoEvent ¶
func (s *DeviceService) AddDeviceAutoEvent(deviceName string, event models.AutoEvent) error
AddDeviceAutoEvent adds a new AutoEvent to the Device with given name
func (*DeviceService) AddDeviceProfile ¶
func (s *DeviceService) AddDeviceProfile(profile models.DeviceProfile) (string, error)
AddDeviceProfile adds a new DeviceProfile to the Device Service and Core Metadata Returns new DeviceProfile id or non-nil error.
func (*DeviceService) AddProvisionWatcher ¶
func (s *DeviceService) AddProvisionWatcher(watcher models.ProvisionWatcher) (string, error)
AddProvisionWatcher adds a new Watcher to the cache and Core Metadata Returns new Watcher id or non-nil error.
func (*DeviceService) AddRoute ¶
func (s *DeviceService) AddRoute(route string, handler func(http.ResponseWriter, *http.Request), methods ...string) error
AddRoute allows leveraging the existing internal web server to add routes specific to Device Service.
func (*DeviceService) AsyncReadings ¶
func (s *DeviceService) AsyncReadings() bool
AsyncReadings returns a bool value to indicate whether the asynchronous reading is enabled.
func (*DeviceService) DeviceCommand ¶
func (s *DeviceService) DeviceCommand(deviceName string, commandName string) (models.DeviceCommand, bool)
DeviceCommand retrieves the specific DeviceCommand instance from cache according to the Device name and Command name
func (*DeviceService) DeviceDiscovery ¶
func (s *DeviceService) DeviceDiscovery() bool
func (*DeviceService) DeviceProfiles ¶
func (s *DeviceService) DeviceProfiles() []models.DeviceProfile
DeviceProfiles return all managed DeviceProfiles from cache
func (*DeviceService) DeviceResource ¶
func (s *DeviceService) DeviceResource(deviceName string, deviceResource string) (models.DeviceResource, bool)
DeviceResource retrieves the specific DeviceResource instance from cache according to the Device name and Device Resource name
func (*DeviceService) Devices ¶
func (s *DeviceService) Devices() []models.Device
Devices return all managed Devices from cache
func (*DeviceService) DriverConfigs ¶ added in v2.3.0
func (s *DeviceService) DriverConfigs() map[string]string
DriverConfigs retrieves the driver specific configuration
func (*DeviceService) GetDeviceByName ¶
func (s *DeviceService) GetDeviceByName(name string) (models.Device, error)
GetDeviceByName returns the Device by its name if it exists in the cache, or returns an error.
func (*DeviceService) GetLoggingClient ¶ added in v2.3.0
func (s *DeviceService) GetLoggingClient() logger.LoggingClient
GetLoggingClient returns the logger.LoggingClient
func (*DeviceService) GetMetricsManager ¶ added in v2.3.0
func (s *DeviceService) GetMetricsManager() interfaces.MetricsManager
GetMetricsManager returns the Metrics Manager used to register counter, gauge, gaugeFloat64 or timer metric types from github.com/rcrowley/go-metrics
func (*DeviceService) GetProfileByName ¶
func (s *DeviceService) GetProfileByName(name string) (models.DeviceProfile, error)
GetProfileByName returns the Profile by its name if it exists in the cache, or returns an error.
func (*DeviceService) GetProvisionWatcherByName ¶
func (s *DeviceService) GetProvisionWatcherByName(name string) (models.ProvisionWatcher, error)
GetProvisionWatcherByName returns the Watcher by its name if it exists in the cache, or returns an error.
func (*DeviceService) GetSecretProvider ¶ added in v2.3.0
func (s *DeviceService) GetSecretProvider() interfaces.SecretProvider
GetSecretProvider returns the SecretProvider
func (*DeviceService) Initialize ¶
func (s *DeviceService) Initialize(serviceName, serviceVersion string, proto interface{})
func (*DeviceService) ListenForCustomConfigChanges ¶
func (s *DeviceService) ListenForCustomConfigChanges( configToWatch interface{}, sectionName string, changedCallback func(interface{})) error
ListenForCustomConfigChanges uses the Config Processor from go-mod-bootstrap to attempt to listen for changes to the specified custom configuration section. LoadCustomConfig must be called previously so that the instance of svc.configProcessor has already been set.
func (*DeviceService) LoadCustomConfig ¶
func (s *DeviceService) LoadCustomConfig(customConfig UpdatableConfig, sectionName string) error
LoadCustomConfig uses the Config Processor from go-mod-bootstrap to attempt to load service's custom configuration. It uses the same command line flags to process the custom config in the same manner as the standard configuration.
func (*DeviceService) Name ¶
func (s *DeviceService) Name() string
Name returns the name of this Device Service
func (*DeviceService) ProvisionWatchers ¶
func (s *DeviceService) ProvisionWatchers() []models.ProvisionWatcher
ProvisionWatchers return all managed Watchers from cache
func (*DeviceService) RemoveDeviceAutoEvent ¶
func (s *DeviceService) RemoveDeviceAutoEvent(deviceName string, event models.AutoEvent) error
RemoveDeviceAutoEvent removes an AutoEvent from the Device with given name
func (*DeviceService) RemoveDeviceByName ¶
func (s *DeviceService) RemoveDeviceByName(name string) error
RemoveDeviceByName removes the specified Device by name from the cache and ensures that the instance in Core Metadata is also removed.
func (*DeviceService) RemoveDeviceProfileByName ¶
func (s *DeviceService) RemoveDeviceProfileByName(name string) error
RemoveDeviceProfileByName removes the specified DeviceProfile by name from the cache and ensures that the instance in Core Metadata is also removed.
func (*DeviceService) RemoveProvisionWatcher ¶
func (s *DeviceService) RemoveProvisionWatcher(name string) error
RemoveProvisionWatcher removes the specified Watcher by name from the cache and ensures that the instance in Core Metadata is also removed.
func (*DeviceService) SetDeviceOpState ¶ added in v2.3.0
func (s *DeviceService) SetDeviceOpState(name string, state models.OperatingState) error
SetDeviceOpState sets the operating state of device
func (*DeviceService) UpdateDevice ¶
func (s *DeviceService) UpdateDevice(device models.Device) error
UpdateDevice updates the Device in the cache and ensures that the copy in Core Metadata is also updated.
func (*DeviceService) UpdateDeviceOperatingState ¶
func (s *DeviceService) UpdateDeviceOperatingState(deviceName string, state string) error
UpdateDeviceOperatingState updates the Device's OperatingState with given name in Core Metadata and device service cache.
func (*DeviceService) UpdateDeviceProfile ¶
func (s *DeviceService) UpdateDeviceProfile(profile models.DeviceProfile) error
UpdateDeviceProfile updates the DeviceProfile in the cache and ensures that the copy in Core Metadata is also updated.
func (*DeviceService) UpdateFromContainer ¶
func (s *DeviceService) UpdateFromContainer(r *mux.Router, dic *di.Container)
func (*DeviceService) UpdateProvisionWatcher ¶
func (s *DeviceService) UpdateProvisionWatcher(watcher models.ProvisionWatcher) error
UpdateProvisionWatcher updates the Watcher in the cache and ensures that the copy in Core Metadata is also updated.
func (*DeviceService) Version ¶
func (s *DeviceService) Version() string
Version returns the version number of this Device Service
type UpdatableConfig ¶
type UpdatableConfig interface { interfaces.UpdatableConfig }
UpdatableConfig interface allows services to have custom configuration populated from configuration stored in the Configuration Provider (aka Consul). Services using custom configuration must implement this interface on their custom configuration, even if they do not use Configuration Provider. If they do not use the Configuration Provider they can have a dummy implementation of this interface. This wraps the actual interface from go-mod-bootstrap so device service code doesn't have to have the additional direct import of go-mod-bootstrap.