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) MakeItStop()
- func (s *AppFunctionsSDK) RegisterCustomTriggerFactory(name string, factory func(TriggerConfig) (Trigger, error)) 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) FilterByProfileName(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) FilterByResourceName(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) HTTPPut(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) HTTPPutJSON(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) HTTPPutXML(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) PushToCore(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) SetOutputData(parameters map[string]string) appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) TransformToJSON() appcontext.AppFunction
- func (dynamic AppFunctionsSDKConfigurable) TransformToXML() appcontext.AppFunction
- type BackgroundPublisher
- type ConfigUpdateProcessor
- type Trigger
- type TriggerConfig
- type TriggerContextBuilder
- type TriggerMessageProcessor
Constants ¶
const ( ProfileNames = "profilenames" DeviceNames = "devicenames" ResourceNames = "resourcenames" 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" ResponseContentType = "responsecontenttype" )
const ( // ProfileSuffixPlaceholder is used to create unique names for profiles ProfileSuffixPlaceholder = "<profile>" OptionalPasswordKey = "Password" )
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' 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 un-marshaled (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{} // EdgexClients allows access to the EdgeX clients such as the CommandClient. // Note that the individual clients (e.g EdgexClients.CommandClient) may be nil if the Service (Command) is not configured // in the [Clients] section of the App Service's configuration. // It is highly recommend that the clients are verified to not be nil before use. EdgexClients common.EdgeXClients // RegistryClient is the client used by service to communicate with service registry. RegistryClient registry.Client // 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 ¶
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 ¶
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 specified 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 ¶
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 specified in the configuration. It will also configure the webserver and start listening on the specified port.
func (*AppFunctionsSDK) MakeItStop ¶
func (sdk *AppFunctionsSDK) MakeItStop()
MakeItStop will force the service loop to exit in the same fashion as SIGINT/SIGTERM received from the OS
func (*AppFunctionsSDK) RegisterCustomTriggerFactory ¶
func (s *AppFunctionsSDK) RegisterCustomTriggerFactory(name string, factory func(TriggerConfig) (Trigger, error)) error
RegisterCustomTriggerFactory allows users to register builders for custom trigger types
func (*AppFunctionsSDK) SetFunctionsPipeline ¶
func (sdk *AppFunctionsSDK) SetFunctionsPipeline(transforms ...appcontext.AppFunction) error
SetFunctionsPipeline allows you to define each function 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) AddTags ¶
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 ¶
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 device names of interest to filter for data coming from certain sensors. The Filter by Device Name transform looks at the Event in the message and looks at the device names of interest list, provided by this function, and filters out those messages whose Event is for device names not in the device names of interest. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is received. 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) FilterByProfileName ¶
func (dynamic AppFunctionsSDKConfigurable) FilterByProfileName(parameters map[string]string) appcontext.AppFunction
FilterByProfileName - Specify the profile names of interest to filter for data coming from certain sensors. The Filter by Profile Name transform looks at the Event in the message and looks at the profile names of interest list, provided by this function, and filters out those messages whose Event is for profile names not in the profile names of interest. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is received. 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) FilterByResourceName ¶
func (dynamic AppFunctionsSDKConfigurable) FilterByResourceName(parameters map[string]string) appcontext.AppFunction
FilterByResourceName - Specify the resource name 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 resource name assesses the data in each Event and Reading, and removes readings that have a resource name that is not in the list of resource names 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 received. 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) HTTPPut ¶
func (dynamic AppFunctionsSDKConfigurable) HTTPPut(parameters map[string]string) appcontext.AppFunction
HTTPPut will send data from the previous function to the specified Endpoint via http PUT. 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) HTTPPutJSON ¶
func (dynamic AppFunctionsSDKConfigurable) HTTPPutJSON(parameters map[string]string) appcontext.AppFunction
HTTPPutJSON sends data from the previous function to the specified Endpoint via http PUT 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) HTTPPutXML ¶
func (dynamic AppFunctionsSDKConfigurable) HTTPPutXML(parameters map[string]string) appcontext.AppFunction
HTTPPutXML sends data from the previous function to the specified Endpoint via http PUT 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) 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(parameters map[string]string) 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 BackgroundPublisher ¶
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 ¶
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.
type Trigger ¶
type Trigger interface { // Initialize performs post creation initializations Initialize(wg *sync.WaitGroup, ctx context.Context, background <-chan types.MessageEnvelope) (bootstrap.Deferred, error) }
Trigger interface provides an abstract means to pass messages through the function pipeline
type TriggerConfig ¶
type TriggerConfig struct { Config *common.ConfigurationStruct Logger logger.LoggingClient ContextBuilder TriggerContextBuilder MessageProcessor TriggerMessageProcessor }
TriggerConfig provides a container to pass context needed to user defined triggers
type TriggerContextBuilder ¶
type TriggerContextBuilder func(env types.MessageEnvelope) *appcontext.Context
TriggerContextBuilder provides an interface to construct an appcontext.Context for message
type TriggerMessageProcessor ¶
type TriggerMessageProcessor func(ctx *appcontext.Context, envelope types.MessageEnvelope) error
TriggerMessageProcessor provides an interface that can be used by custom triggers to invoke the runtime