Documentation ¶
Index ¶
- Constants
- type AppFunctionsSDK
- func (sdk *AppFunctionsSDK) AddBackgroundPublisher(capacity int) BackgroundPublisher
- func (sdk *AppFunctionsSDK) AddRoute(route string, handler func(nethttp.ResponseWriter, *nethttp.Request), ...) error
- func (sdk *AppFunctionsSDK) ApplicationSettings() map[string]string
- func (sdk *AppFunctionsSDK) GetAppSettingStrings(setting string) ([]string, error)
- func (sdk *AppFunctionsSDK) GetSecrets(path string, keys ...string) (map[string]string, error)
- func (sdk *AppFunctionsSDK) Initialize() error
- func (sdk *AppFunctionsSDK) LoadConfigurablePipeline() ([]appcontext.AppFunction, error)
- func (sdk *AppFunctionsSDK) MakeItRun() error
- func (sdk *AppFunctionsSDK) SetFunctionsPipeline(transforms ...appcontext.AppFunction) error
- func (sdk *AppFunctionsSDK) StoreSecrets(path string, secrets map[string]string) error
- type AppFunctionsSDKConfigurable
- func (dynamic AppFunctionsSDKConfigurable) AddTags(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) BatchByCount(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) BatchByTime(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) BatchByTimeAndCount(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) CompressWithGZIP() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) CompressWithZLIB() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) EncryptWithAES(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) FilterByDeviceName(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) FilterByValueDescriptor(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) HTTPPost(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) HTTPPostJSON(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) HTTPPostXML(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) JSONLogic(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) MQTTSecretSend(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) MQTTSend(parameters map[string]string, addr models.Addressable) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) MarkAsPushed() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) PushToCore(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) SetOutputData() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) TransformToJSON() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) TransformToXML() appcontext.AppFunction
- type BackgroundPublisher
- type ConfigUpdateProcessor
Constants ¶
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" Tags = "tags" )
const (
// ProfileSuffixPlaceholder is used to create unique names for profiles
ProfileSuffixPlaceholder = "<profile>"
)
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) AddBackgroundPublisher ¶ added in v1.3.0
func (sdk *AppFunctionsSDK) AddBackgroundPublisher(capacity int) BackgroundPublisher
AddBackgroundPublisher will create a channel of provided capacity to be consumed by the MessageBus output and return a publisher that writes to it
func (*AppFunctionsSDK) AddRoute ¶ added in v1.0.0
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 ¶ added in v1.1.0
func (sdk *AppFunctionsSDK) GetAppSettingStrings(setting string) ([]string, error)
GetAppSettingStrings returns the strings slice for the specified App Setting.
func (*AppFunctionsSDK) GetSecrets ¶ added in v1.1.0
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 ¶ added in v1.0.0
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 ¶ added in v1.1.0
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 ¶ added in v1.0.0
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) AddTags ¶ added in v1.3.0
func (dynamic AppFunctionsSDKConfigurable) AddTags(parameters map[string]string) appcontext.AppFunction
AddTags adds the configured list of tags to Events passed to the transform. This function is a configuration function and returns a function pointer.
func (AppFunctionsSDKConfigurable) BatchByCount ¶ added in v1.1.0
func (dynamic AppFunctionsSDKConfigurable) BatchByCount(parameters map[string]string) appcontext.AppFunction
BatchByCount ...
func (AppFunctionsSDKConfigurable) BatchByTime ¶ added in v1.1.0
func (dynamic AppFunctionsSDKConfigurable) BatchByTime(parameters map[string]string) appcontext.AppFunction
BatchByTime ...
func (AppFunctionsSDKConfigurable) BatchByTimeAndCount ¶ added in v1.1.0
func (dynamic AppFunctionsSDKConfigurable) BatchByTimeAndCount(parameters map[string]string) appcontext.AppFunction
BatchByTimeAndCount ...
func (AppFunctionsSDKConfigurable) CompressWithGZIP ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.1.0
func (dynamic AppFunctionsSDKConfigurable) JSONLogic(parameters map[string]string) appcontext.AppFunction
JSONLogic ...
func (AppFunctionsSDKConfigurable) MQTTSecretSend ¶ added in v1.1.0
func (dynamic AppFunctionsSDKConfigurable) MQTTSecretSend(parameters map[string]string) appcontext.AppFunction
MQTTSecretSend
func (AppFunctionsSDKConfigurable) MQTTSend ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 BackgroundPublisher ¶ added in v1.3.0
type BackgroundPublisher interface { // Publish provided message through the configured MessageBus output Publish(payload []byte, correlationID string, contentType string) }
BackgroundPublisher provides an interface to send messages from background processes through the service's configured MessageBus output
type ConfigUpdateProcessor ¶ added in v1.1.0
type ConfigUpdateProcessor struct {
// contains filtered or unexported fields
}
ConfigUpdateProcessor contains the data need to process configuration updates
func NewConfigUpdateProcessor ¶ added in v1.1.0
func NewConfigUpdateProcessor(sdk *AppFunctionsSDK) *ConfigUpdateProcessor
NewConfigUpdateProcessor creates a new ConfigUpdateProcessor which process configuration updates triggered from the Configuration Provider
func (*ConfigUpdateProcessor) WaitForConfigUpdates ¶ added in v1.1.0
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.