transforms

package
v3.2.0-dev.30 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatchByCountOnly = iota
	BatchByTimeOnly
	BatchByTimeAndCount
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AESProtection

type AESProtection struct {
	SecretName     string
	SecretValueKey string
	EncryptionKey  string
}

func NewAESProtection

func NewAESProtection(secretName string, secretValueKey string) *AESProtection

NewAESProtection creates, initializes and returns a new instance of AESProtection configured to retrieve the encryption key from the Secret Store

func (*AESProtection) Encrypt

func (protection *AESProtection) Encrypt(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

Encrypt encrypts a string, []byte, or json.Marshaller type using AES 256 encryption. It also signs the data using a SHA512 hash. It will return a Base64 encode []byte of the encrypted data.

type BatchConfig

type BatchConfig struct {
	IsEventData bool
	MergeOnSend bool
	// contains filtered or unexported fields
}

BatchConfig ...

func NewBatchByCount

func NewBatchByCount(batchThreshold int) (*BatchConfig, error)

NewBatchByCount create, initializes and returns a new instance for BatchConfig

func NewBatchByTime

func NewBatchByTime(timeInterval string) (*BatchConfig, error)

NewBatchByTime create, initializes and returns a new instance for BatchConfig

func NewBatchByTimeAndCount

func NewBatchByTimeAndCount(timeInterval string, batchThreshold int) (*BatchConfig, error)

NewBatchByTimeAndCount create, initializes and returns a new instance for BatchConfig

func (*BatchConfig) Batch

func (batch *BatchConfig) Batch(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

Batch ...

type BatchMode

type BatchMode int

BatchMode Enum for choosing behavior of Batch. Default is CountAndTime.

type Compression

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

func NewCompression

func NewCompression() *Compression

NewCompression creates, initializes and returns a new instance of Compression

func (*Compression) CompressWithGZIP

func (compression *Compression) CompressWithGZIP(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

CompressWithGZIP compresses data received as either a string,[]byte, or json.Marshaller using gzip algorithm and returns a base64 encoded string as a []byte.

func (*Compression) CompressWithZLIB

func (compression *Compression) CompressWithZLIB(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

CompressWithZLIB compresses data received as either a string,[]byte, or json.Marshaller using zlib algorithm and returns a base64 encoded string as a []byte.

type Conversion

type Conversion struct {
}

Conversion houses various built in conversion transforms (XML, JSON, CSV)

func NewConversion

func NewConversion() *Conversion

NewConversion creates, initializes and returns a new instance of Conversion

func (*Conversion) TransformToJSON

func (f *Conversion) TransformToJSON(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, stringType interface{})

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 received.

func (*Conversion) TransformToXML

func (f *Conversion) TransformToXML(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, stringType interface{})

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 received.

type EventWrapper

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

func NewEventWrapperBinaryReading

func NewEventWrapperBinaryReading(profileName string, deviceName string, resourceName string, mediaType string) *EventWrapper

NewEventWrapperBinaryReading is provided to interact with EventWrapper to add a binary reading

func NewEventWrapperObjectReading

func NewEventWrapperObjectReading(profileName string, deviceName string, resourceName string) *EventWrapper

NewEventWrapperObjectReading is provided to interact with EventWrapper to add a object reading type

func NewEventWrapperSimpleReading

func NewEventWrapperSimpleReading(profileName string, deviceName string, resourceName string, valueType string) *EventWrapper

NewEventWrapperSimpleReading is provided to interact with EventWrapper to add a simple reading

func (*EventWrapper) Wrap

func (ew *EventWrapper) Wrap(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

// Wrap creates an EventRequest using the Event/Reading metadata that have been set.

type Filter

type Filter struct {
	FilterValues []string
	FilterOut    bool
	// contains filtered or unexported fields
}

Filter houses various the parameters for which filter transforms filter on

func NewFilterFor

func NewFilterFor(filterValues []string) *Filter

NewFilterFor creates, initializes and returns a new instance of Filter that defaults FilterOut to false, so it is filtering for specified values

func NewFilterOut

func NewFilterOut(filterValues []string) *Filter

NewFilterOut creates, initializes and returns a new instance of Filter that defaults FilterOut to true, so it is filtering out specified values

func (*Filter) FilterByDeviceName

func (f *Filter) FilterByDeviceName(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, result interface{})

FilterByDeviceName filters based on the specified Device Names, aka Instance of a Device. If FilterOut is false, it filters out those Events not associated with the specified Device Names listed in FilterValues. If FilterOut is true, it out those Events that are associated with the specified Device Names listed in FilterValues.

func (*Filter) FilterByProfileName

func (f *Filter) FilterByProfileName(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, result interface{})

FilterByProfileName filters based on the specified Device Profile, aka Class of Device. If FilterOut is false, it filters out those Events not associated with the specified Device Profile listed in FilterValues. If FilterOut is true, it out those Events that are associated with the specified Device Profile listed in FilterValues.

func (*Filter) FilterByResourceName

func (f *Filter) FilterByResourceName(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, result interface{})

FilterByResourceName filters based on the specified Reading resource names, aka Instance of a Device. If FilterOut is false, it filters out those Event Readings not associated with the specified Resource Names listed in FilterValues. If FilterOut is true, it out those Event Readings that are associated with the specified Resource Names listed in FilterValues. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is received.

func (*Filter) FilterBySourceName

func (f *Filter) FilterBySourceName(ctx interfaces.AppFunctionContext, data interface{}) (continuePipeline bool, result interface{})

FilterBySourceName filters based on the specified Source for the Event, aka resource or command name. If FilterOut is false, it filters out those Events not associated with the specified Source listed in FilterValues. If FilterOut is true, it out those Events that are associated with the specified Source listed in FilterValues.

type HTTPSender

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

HTTPSender ...

func NewHTTPSender

func NewHTTPSender(url string, mimeType string, persistOnError bool) *HTTPSender

NewHTTPSender creates, initializes and returns a new instance of HTTPSender

func NewHTTPSenderWithOptions

func NewHTTPSenderWithOptions(options HTTPSenderOptions) *HTTPSender

NewHTTPSenderWithOptions creates, initializes and returns a new instance of HTTPSender configured with provided options

func NewHTTPSenderWithSecretHeader

func NewHTTPSenderWithSecretHeader(url string, mimeType string, persistOnError bool, headerName string, secretName string, secretValueKey string) *HTTPSender

NewHTTPSenderWithSecretHeader creates, initializes and returns a new instance of HTTPSender configured to use a secret header

func (*HTTPSender) HTTPPost

func (sender *HTTPSender) HTTPPost(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

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. An empty string for the mimetype will default to application/json.

func (*HTTPSender) HTTPPut

func (sender *HTTPSender) HTTPPut(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

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. An empty string for the mimetype will default to application/json.

func (*HTTPSender) SetHttpRequestHeaders added in v3.1.0

func (sender *HTTPSender) SetHttpRequestHeaders(httpRequestHeaders map[string]string)

SetHttpRequestHeaders will set all the header parameters for the http request

type HTTPSenderOptions

type HTTPSenderOptions struct {
	// URL of destination
	URL string
	// MimeType to send to destination
	MimeType string
	// PersistOnError enables use of store & forward loop if true
	PersistOnError bool
	// HTTPHeaderName to use for passing configured secret
	HTTPHeaderName string
	// SecretName is the name of the secret in the SecretStore
	SecretName string
	//  SecretValueKey is the key for the value in the secret data from the SecretStore
	SecretValueKey string
	// URLFormatter specifies custom formatting behavior to be applied to configured URL.
	// If nothing specified, default behavior is to attempt to replace placeholders in the
	// form '{some-context-key}' with the values found in the context storage.
	URLFormatter StringValuesFormatter
	// ContinueOnSendError allows execution of subsequent chained senders after errors if true
	ContinueOnSendError bool
	// ReturnInputData enables chaining multiple HTTP senders if true
	ReturnInputData bool
}

HTTPSenderOptions contains all options available to the sender

type JSONLogic

type JSONLogic struct {
	Rule string
}

JSONLogic ...

func NewJSONLogic

func NewJSONLogic(rule string) *JSONLogic

NewJSONLogic creates, initializes and returns a new instance of HTTPSender

func (*JSONLogic) Evaluate

func (logic *JSONLogic) Evaluate(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

Evaluate ...

type MQTTSecretConfig

type MQTTSecretConfig struct {
	// BrokerAddress should be set to the complete broker address i.e. mqtts://mosquitto:8883/mybroker
	BrokerAddress string
	// ClientId to connect with the broker with.
	ClientId string
	// The name of the secret in secret provider to retrieve your secrets
	SecretName string
	// AutoReconnect indicated whether or not to retry connection if disconnected
	AutoReconnect bool
	// KeepAlive is the interval duration between client sending keepalive ping to broker
	KeepAlive string
	// ConnectTimeout is the duration for timing out on connecting to the broker
	ConnectTimeout string
	// MaxReconnectInterval is the max duration for attempting to reconnect to the broker
	MaxReconnectInterval string
	// Topic that you wish to publish to
	Topic string
	// QoS for MQTT Connection
	QoS byte
	// Retain setting for MQTT Connection
	Retain bool
	// SkipCertVerify
	SkipCertVerify bool
	// AuthMode indicates what to use when connecting to the broker. Options are "none", "cacert" , "usernamepassword", "clientcert".
	// If a CA Cert exists in the SecretName then it will be used for all modes except "none".
	AuthMode string
	// Will contains the Last Will configuration for the MQTT Client
	Will common.WillConfig
}

MQTTSecretConfig ...

type MQTTSecretSender

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

MQTTSecretSender ...

func NewMQTTSecretSender

func NewMQTTSecretSender(mqttConfig MQTTSecretConfig, persistOnError bool) *MQTTSecretSender

NewMQTTSecretSender ...

func NewMQTTSecretSenderWithTopicFormatter

func NewMQTTSecretSenderWithTopicFormatter(mqttConfig MQTTSecretConfig, persistOnError bool, topicFormatter StringValuesFormatter) *MQTTSecretSender

NewMQTTSecretSenderWithTopicFormatter allows passing a function to build a final publish topic from the combination of the configured topic and the input parameters passed to MQTTSend

func (*MQTTSecretSender) ConnectToBroker

func (sender *MQTTSecretSender) ConnectToBroker(lc logger.LoggingClient, sp bootstrapInterfaces.SecretProvider, retryCount int, retryInterval time.Duration)

ConnectToBroker attempts to connect to the MQTT broker for export prior to processing the first data to be exported. If a failure occurs the connection is retried when processing the first data to be exported.

func (*MQTTSecretSender) MQTTSend

func (sender *MQTTSecretSender) MQTTSend(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

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.

func (*MQTTSecretSender) SetOnConnectHandler

func (sender *MQTTSecretSender) SetOnConnectHandler(onConnect MQTT.OnConnectHandler)

SetOnConnect sets the OnConnect Handler before client is connected so client can be captured.

type MetricsProcessor

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

MetricsProcessor contains functions to process the Metric DTO

func NewMetricsProcessor

func NewMetricsProcessor(additionalTags map[string]interface{}) (*MetricsProcessor, error)

NewMetricsProcessor creates a new MetricsProcessor with additional tags to add to the Metrics that are processed

func (*MetricsProcessor) ToLineProtocol

func (mp *MetricsProcessor) ToLineProtocol(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

ToLineProtocol transforms a Metric DTO to a string conforming to Line Protocol syntax which is most commonly used with InfluxDB For more information on Line Protocol see: https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/

type ResponseData

type ResponseData struct {
	ResponseContentType string
}

ResponseData houses transform for outputting data to configured trigger response, i.e. message bus

func NewResponseData

func NewResponseData() *ResponseData

NewResponseData creates, initializes and returns a new instance of ResponseData

func (*ResponseData) SetResponseData

func (f *ResponseData) SetResponseData(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

SetResponseData sets the response data to that passed in from the previous function. It will return an error and stop the pipeline if the input data is not of type []byte, string or json.Marshaller

type StringValuesFormatter

type StringValuesFormatter func(string, interfaces.AppFunctionContext, interface{}) (string, error)

StringValuesFormatter defines a function signature to perform string formatting operations using an AppFunction payload.

type Tags

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

Tags contains the list of Tag key/values

func NewTags

func NewTags(tags map[string]interface{}) *Tags

NewTags creates, initializes and returns a new instance of Tags using generic interface values

func (*Tags) AddTags

func (t *Tags) AddTags(ctx interfaces.AppFunctionContext, data interface{}) (bool, interface{})

AddTags adds the pre-configured list of tags to the Event's tags collection.

Jump to

Keyboard shortcuts

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