appsdk

package
v1.9.10 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValueDescriptors = "valuedescriptors"
	DeviceNames      = "devicenames"
	FilterOut        = "filterout"
	Key              = "key"
	InitVector       = "initvector"
	Url              = "url"
	MimeType         = "mimetype"
	PersistOnError   = "persistonerror"
	Cert             = "cert"
	SkipVerify       = "skipverify"
	Qos              = "qos"
	Retain           = "retain"
	AutoReconnect    = "autoreconnect"
	DeviceName       = "devicename"
	ReadingName      = "readingname"
	Rule             = "rule"
	BatchThreshold   = "batchthreshold"
	TimeInterval     = "timeinterval"
	SecretHeaderName = "secretheadername"
	SecretPath       = "secretpath"
	BrokerAddress    = "brokeraddress"
	ClientID         = "clientid"
	Topic            = "topic"
	AuthMode         = "authmode"
	CertFile         = "clientcertfile"
	KeyFile          = "clientkeyfile"
	CAFile           = "cafile"
)
View Source
const (
	// ProfileSuffixPlaceholder is used to create unique names for profiles
	ProfileSuffixPlaceholder = "<profile>"
)
View Source
const SDKKey key = 0

SDKKey is the context key for getting the sdk context. Its value of zero is arbitrary. If this package defined other context keys, they would have different integer values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppFunctionsSDK

type AppFunctionsSDK struct {
	// ServiceKey is the application services's key used for Configuration and Registration when the Registry is enabled
	ServiceKey string
	// LoggingClient is the EdgeX logger client used to log messages
	LoggingClient logger.LoggingClient
	// TargetType is the expected type of the incoming data. Must be set to a pointer to an instance of the type.
	// Defaults to &models.Event{} if nil. The income data is unmarshaled (JSON or CBOR) in to the type,
	// except when &[]byte{} is specified. In this case the []byte data is pass to the first function in the Pipeline.
	TargetType interface{}
	// contains filtered or unexported fields
}

AppFunctionsSDK provides the necessary struct to create an instance of the Application Functions SDK. Be sure and provide a ServiceKey when creating an instance of the SDK. After creating an instance, you'll first want to call .Initialize(), to start up the SDK. Secondly, provide the desired transforms for your pipeline by calling .SetFunctionsPipeline(). Lastly, call .MakeItRun() to start listening for events based on your configured trigger.

func (*AppFunctionsSDK) AddRoute

func (sdk *AppFunctionsSDK) AddRoute(route string, handler func(nethttp.ResponseWriter, *nethttp.Request), methods ...string) error

AddRoute allows you to leverage the existing webserver to add routes.

func (*AppFunctionsSDK) ApplicationSettings

func (sdk *AppFunctionsSDK) ApplicationSettings() map[string]string

ApplicationSettings returns the values specifed in the custom configuration section.

func (*AppFunctionsSDK) GetAppSettingStrings

func (sdk *AppFunctionsSDK) GetAppSettingStrings(setting string) ([]string, error)

GetAppSettingStrings returns the strings slice for the specified App Setting.

func (*AppFunctionsSDK) GetSecrets

func (sdk *AppFunctionsSDK) GetSecrets(path string, keys ...string) (map[string]string, error)

GetSecrets retrieves secrets from a secret store. path specifies the type or location of the secrets to retrieve. If specified it is appended to the base path from the SecretConfig keys specifies the secrets which to retrieve. If no keys are provided then all the keys associated with the specified path will be returned.

func (*AppFunctionsSDK) Initialize

func (sdk *AppFunctionsSDK) Initialize() error

Initialize will parse command line flags, register for interrupts, initialize the logging system, and ingest configuration.

func (*AppFunctionsSDK) LoadConfigurablePipeline

func (sdk *AppFunctionsSDK) LoadConfigurablePipeline() ([]appcontext.AppFunction, error)

LoadConfigurablePipeline ...

func (*AppFunctionsSDK) MakeItRun

func (sdk *AppFunctionsSDK) MakeItRun() error

MakeItRun will initialize and start the trigger as specifed in the configuration. It will also configure the webserver and start listening on the specified port.

func (*AppFunctionsSDK) SetFunctionsPipeline

func (sdk *AppFunctionsSDK) SetFunctionsPipeline(transforms ...appcontext.AppFunction) error

SetFunctionsPipeline allows you to define each fgitunction to execute and the order in which each function will be called as each event comes in.

func (*AppFunctionsSDK) StoreSecrets

func (sdk *AppFunctionsSDK) StoreSecrets(path string, secrets map[string]string) error

StoreSecrets stores the secrets to a secret store. it sets the values requested at provided keys path specifies the type or location of the secrets to store. If specified it is appended to the base path from the SecretConfig secrets map specifies the "key": "value" pairs of secrets to store

type AppFunctionsSDKConfigurable

type AppFunctionsSDKConfigurable struct {
	Sdk *AppFunctionsSDK
}

AppFunctionsSDKConfigurable contains the helper functions that return the function pointers for building the configurable function pipeline. They transform the parameters map from the Pipeline configuration in to the actual actual parameters required by the function.

func (AppFunctionsSDKConfigurable) BatchByCount

func (dynamic AppFunctionsSDKConfigurable) BatchByCount(parameters map[string]string) appcontext.AppFunction

BatchByCount ...

func (AppFunctionsSDKConfigurable) BatchByTime

func (dynamic AppFunctionsSDKConfigurable) BatchByTime(parameters map[string]string) appcontext.AppFunction

BatchByTime ...

func (AppFunctionsSDKConfigurable) BatchByTimeAndCount

func (dynamic AppFunctionsSDKConfigurable) BatchByTimeAndCount(parameters map[string]string) appcontext.AppFunction

BatchByTimeAndCount ...

func (AppFunctionsSDKConfigurable) CompressWithGZIP

func (dynamic AppFunctionsSDKConfigurable) CompressWithGZIP() appcontext.AppFunction

CompressWithGZIP compresses data received as either a string,[]byte, or json.Marshaler using gzip algorithm and returns a base64 encoded string as a []byte. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) CompressWithZLIB

func (dynamic AppFunctionsSDKConfigurable) CompressWithZLIB() appcontext.AppFunction

CompressWithZLIB compresses data received as either a string,[]byte, or json.Marshaler using zlib algorithm and returns a base64 encoded string as a []byte. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) EncryptWithAES

func (dynamic AppFunctionsSDKConfigurable) EncryptWithAES(parameters map[string]string) appcontext.AppFunction

EncryptWithAES encrypts either a string, []byte, or json.Marshaller type using AES encryption. It will return a byte[] of the encrypted data. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) FilterByDeviceName

func (dynamic AppFunctionsSDKConfigurable) FilterByDeviceName(parameters map[string]string) appcontext.AppFunction

FilterByDeviceName - Specify the devices of interest to filter for data coming from certain sensors. The Filter by Device transform looks at the Event in the message and looks at the devices of interest list, provided by this function, and filters out those messages whose Event is for devices not on the devices of interest. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is recieved. For example, data generated by a motor does not get passed to functions only interested in data from a thermostat. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) FilterByValueDescriptor

func (dynamic AppFunctionsSDKConfigurable) FilterByValueDescriptor(parameters map[string]string) appcontext.AppFunction

FilterByValueDescriptor - Specify the value descriptors of interest to filter for data from certain types of IoT objects, such as temperatures, motion, and so forth, that may come from an array of sensors or devices. The Filter by Value Descriptor assesses the data in each Event and Reading, and removes readings that have a value descriptor that is not in the list of value descriptors of interest for the application. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is recieved. For example, pressure reading data does not go to functions only interested in motion data. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) HTTPPost

func (dynamic AppFunctionsSDKConfigurable) HTTPPost(parameters map[string]string) appcontext.AppFunction

HTTPPost will send data from the previous function to the specified Endpoint via http POST. If no previous function exists, then the event that triggered the pipeline will be used. Passing an empty string to the mimetype method will default to application/json. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) HTTPPostJSON

func (dynamic AppFunctionsSDKConfigurable) HTTPPostJSON(parameters map[string]string) appcontext.AppFunction

HTTPPostJSON sends data from the previous function to the specified Endpoint via http POST with a mime type of application/json. If no previous function exists, then the event that triggered the pipeline will be used. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) HTTPPostXML

func (dynamic AppFunctionsSDKConfigurable) HTTPPostXML(parameters map[string]string) appcontext.AppFunction

HTTPPostXML sends data from the previous function to the specified Endpoint via http POST with a mime type of application/xml. If no previous function exists, then the event that triggered the pipeline will be used. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) JSONLogic

func (dynamic AppFunctionsSDKConfigurable) JSONLogic(parameters map[string]string) appcontext.AppFunction

JSONLogic ...

func (AppFunctionsSDKConfigurable) MQTTSecretSend

func (dynamic AppFunctionsSDKConfigurable) MQTTSecretSend(parameters map[string]string) appcontext.AppFunction

MQTTSecretSend

func (AppFunctionsSDKConfigurable) MQTTSend

func (dynamic AppFunctionsSDKConfigurable) MQTTSend(parameters map[string]string, addr models.Addressable) appcontext.AppFunction

MQTTSend sends data from the previous function to the specified MQTT broker. If no previous function exists, then the event that triggered the pipeline will be used. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) MarkAsPushed

func (dynamic AppFunctionsSDKConfigurable) MarkAsPushed() appcontext.AppFunction

MarkAsPushed will make a request to CoreData to mark the event that triggered the pipeline as pushed. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) PushToCore

func (dynamic AppFunctionsSDKConfigurable) PushToCore(parameters map[string]string) appcontext.AppFunction

PushToCore pushes the provided value as an event to CoreData using the device name and reading name that have been set. If validation is turned on in CoreServices then your deviceName and readingName must exist in the CoreMetadata and be properly registered in EdgeX. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) SetOutputData

func (dynamic AppFunctionsSDKConfigurable) SetOutputData() appcontext.AppFunction

SetOutputData sets the output data to that passed in from the previous function. It will return an error and stop the pipeline if data passed in is not of type []byte, string or json.Mashaler This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) TransformToJSON

func (dynamic AppFunctionsSDKConfigurable) TransformToJSON() appcontext.AppFunction

TransformToJSON transforms an EdgeX event to JSON. It will return an error and stop the pipeline if a non-edgex event is received or if no data is recieved. This function is a configuration function and returns a function pointer.

func (AppFunctionsSDKConfigurable) TransformToXML

func (dynamic AppFunctionsSDKConfigurable) TransformToXML() appcontext.AppFunction

TransformToXML transforms an EdgeX event to XML. It will return an error and stop the pipeline if a non-edgex event is received or if no data is recieved. This function is a configuration function and returns a function pointer.

type ConfigUpdateProcessor

type ConfigUpdateProcessor struct {
	// contains filtered or unexported fields
}

ConfigUpdateProcessor contains the data need to process configuration updates

func NewConfigUpdateProcessor

func NewConfigUpdateProcessor(sdk *AppFunctionsSDK) *ConfigUpdateProcessor

NewConfigUpdateProcessor creates a new ConfigUpdateProcessor which process configuration updates triggered from the Configuration Provider

func (*ConfigUpdateProcessor) WaitForConfigUpdates

func (processor *ConfigUpdateProcessor) WaitForConfigUpdates(configUpdated config.UpdatedStream)

WaitForConfigUpdates waits for signal that configuration has been updated (triggered from by Configuration Provider) and then determines what was updated and does any special processing, if needed, for the updates.

Jump to

Keyboard shortcuts

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