transforms

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Copyright (c) 2019 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	BatchByCountOnly = iota
	BatchByTimeOnly
	BatchByTimeAndCount
)

Variables

This section is empty.

Functions

func ByteToFloat32

func ByteToFloat32(bytes []byte) float32

func ByteToFloat64

func ByteToFloat64(bytes []byte) float64

func BytesToInt

func BytesToInt(b []byte) int

func CreateShiftFlagMap

func CreateShiftFlagMap(flag []string) map[string]string

func CreateShiftMap

func CreateShiftMap(value string) map[string]int

func Float32ToByte

func Float32ToByte(float float32) []byte

func Float64ToByte

func Float64ToByte(float float64) []byte

func FloatToString

func FloatToString(input_num float32) string

Types

type BatchConfig

type BatchConfig struct {
	// 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(edgexcontext *appcontext.Context, params ...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(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

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

func (*Compression) CompressWithZLIB

func (compression *Compression) CompressWithZLIB(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

CompressWithZLIB compresses data received as either a string,[]byte, or json.Marshaler 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) CustomTransformKeyValueToJson added in v1.0.4

func (f Conversion) CustomTransformKeyValueToJson(edgexcontext *appcontext.Context, params ...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) CustomTransformToJson added in v1.0.3

func (f Conversion) CustomTransformToJson(edgexcontext *appcontext.Context, params ...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) TransformToJSON

func (f Conversion) TransformToJSON(edgexcontext *appcontext.Context, params ...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(edgexcontext *appcontext.Context, params ...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 CoreData

type CoreData struct {
	DeviceName  string
	ReadingName string
}

func NewCoreData

func NewCoreData() *CoreData

NewCoreData Is provided to interact with CoreData

func (*CoreData) MarkAsPushed

func (cdc *CoreData) MarkAsPushed(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

MarkAsPushed will make a request to CoreData to mark the event that triggered the pipeline as pushed. This function will not stop the pipeline if an error is returned from core data, however the error is logged.

func (*CoreData) PushToCoreData

func (cdc *CoreData) PushToCoreData(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

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

type Encryption

type Encryption struct {
	Key                  string
	InitializationVector string
}

func NewEncryption

func NewEncryption(key string, initializationVector string) Encryption

NewEncryption creates, initializes and returns a new instance of Encryption

func (Encryption) EncryptWithAES

func (aesData Encryption) EncryptWithAES(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

EncryptWithAES encrypts a string, []byte, or json.Marshaller type using AES encryption. It will return a Base64 encode []byte of the encrypted data.

type Filter

type Filter struct {
	FilterValues []string
	FilterOut    bool
}

Filter houses various the parameters for which filter transforms filter on

func NewFilter

func NewFilter(filterValues []string) Filter

NewFilter creates, initializes and returns a new instance of Filter

func (Filter) FilterByDeviceName

func (f Filter) FilterByDeviceName(edgexcontext *appcontext.Context, params ...interface{}) (continuePipeline bool, result interface{})

FilterByDeviceName filters for data coming from specific devices. It filters out those messages whose Event is for devices not in FilterValues. For example, data generated by a motor does not get passed to functions only interested in data from a thermostat. 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) FilterByValueDescriptor

func (f Filter) FilterByValueDescriptor(edgexcontext *appcontext.Context, params ...interface{}) (continuePipeline bool, result interface{})

FilterByValueDescriptor filters for data from certain types of IoT objects, such as temperatures, motion, and so forth. Reading types not in FilterValues are removed leaving just the readings that match one of the values in FilterValues. For example, pressure reading data does not go to functions only interested in motion data. This function will return an error and stop the pipeline if a non-edgex event is received or if no data is received.

type HTTPSender

type HTTPSender struct {
	URL              string
	MimeType         string
	PersistOnError   bool
	SecretHeaderName string
	SecretPath       string
}

HTTPSender ...

func NewHTTPSender

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

NewHTTPSender creates, initializes and returns a new instance of HTTPSender

func NewHTTPSenderWithSecretHeader

func NewHTTPSenderWithSecretHeader(url string, mimeType string, persistOnError bool, httpHeaderSecretName string, secretPath 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(edgexcontext *appcontext.Context, params ...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(edgexcontext *appcontext.Context, params ...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.

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(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

Evaluate ...

type KeyCertPair

type KeyCertPair struct {
	KeyFile      string
	CertFile     string
	KeyPEMBlock  []byte
	CertPEMBlock []byte
}

KeyCertPair is used to pass key/cert pair to NewMQTTSender KeyPEMBlock and CertPEMBlock will be used if they are not nil then it will fall back to KeyFile and CertFile

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 path in secret provider to retrieve your secrets
	SecretPath string
	// AutoReconnect indicated whether or not to retry connection if disconnected
	AutoReconnect bool
	// 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 SecretPath then it will be used for all modes except "none".
	AuthMode string
}

MQTTSecretConfig ...

type MQTTSecretSender

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

MQTTSecretSender ...

func NewMQTTSecretSender

func NewMQTTSecretSender(mqttConfig MQTTSecretConfig, persistOnError bool) *MQTTSecretSender

NewMQTTSecretSender ...

func (*MQTTSecretSender) MQTTSend

func (sender *MQTTSecretSender) MQTTSend(edgexcontext *appcontext.Context, params ...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.

type MQTTSender

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

func NewMQTTSender

func NewMQTTSender(logging logger.LoggingClient, addr models.Addressable, keyCertPair *KeyCertPair,
	mqttConfig MqttConfig, persistOnError bool) *MQTTSender

NewMQTTSender - create new mqtt sender

func (*MQTTSender) MQTTSend

func (sender *MQTTSender) MQTTSend(edgexcontext *appcontext.Context, params ...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.

type MqttConfig

type MqttConfig struct {
	Qos            byte
	Retain         bool
	AutoReconnect  bool
	SkipCertVerify bool
	User           string
	Password       string
}

MqttConfig contains mqtt client parameters

type OutputData

type OutputData struct {
	ResponseContentType string
}

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

func NewOutputData

func NewOutputData() OutputData

NewOutputData creates, initializes and returns a new instance of OutputData

func (OutputData) SetOutputData

func (f OutputData) SetOutputData(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{})

SetOutputData sets the output 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.Mashaler

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]string) Tags

NewTags creates, initializes and returns a new instance of Tags

func (*Tags) AddTags

func (t *Tags) AddTags(edgexcontext *appcontext.Context, params ...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