diff --git a/app-service-template/Makefile b/app-service-template/Makefile index 05b6700e9..475b268b5 100644 --- a/app-service-template/Makefile +++ b/app-service-template/Makefile @@ -10,7 +10,7 @@ APPVERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0) # This pulls the version of the SDK from the go.mod file. If the SDK is the only required module, # it must first remove the word 'required' so the offset of $2 is the same if there are multiple required modules -SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/app-functions-sdk-go v' | sed 's/require//g' | awk '{print $$2}') +SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/app-functions-sdk-go/v2 v' | sed 's/require//g' | awk '{print $$2}') MICROSERVICE=new-app-service GOFLAGS=-ldflags "-X github.com/edgexfoundry/app-functions-sdk-go/v2/internal.SDKVersion=$(SDKVERSION) -X github.com/edgexfoundry/app-functions-sdk-go/v2/internal.ApplicationVersion=$(APPVERSION)" diff --git a/app-service-template/res/configuration.toml b/app-service-template/res/configuration.toml index f0eb6cafc..4e4364d89 100644 --- a/app-service-template/res/configuration.toml +++ b/app-service-template/res/configuration.toml @@ -2,18 +2,19 @@ # https://docs.edgexfoundry.org/1.3/microservices/application/GeneralAppServiceConfig/ [Writable] LogLevel = 'INFO' - [Writable.StoreAndForward] - Enabled = false - RetryInterval = '5m' - MaxRetryCount = 10 - # TODO: if not running in secure mode, but do have secrets then add them here. - [Writable.InsecureSecrets] - [Writable.InsecureSecrets.DB] - path = "redisdb" - [Writable.InsecureSecrets.DB.Secrets] - username = "" - password = "" + [Writable.StoreAndForward] + Enabled = false + RetryInterval = '5m' + MaxRetryCount = 10 + + # TODO: if not running in secure mode, but do have secrets then add them here. + [Writable.InsecureSecrets] + [Writable.InsecureSecrets.DB] + path = "redisdb" + [Writable.InsecureSecrets.DB.Secrets] + username = "" + password = "" [Service] BootTimeout = '30s' @@ -52,8 +53,8 @@ ServerName = '' TokenFile = '/vault/config/assets/resp-init.json' AdditionalRetryAttempts = 10 RetryWaitPeriod = "1s" - [SecretStore.Authentication] - AuthType = 'X-Vault-Token' + [SecretStore.Authentication] + AuthType = 'X-Vault-Token' [Clients] [Clients.CoreData] @@ -61,39 +62,46 @@ RetryWaitPeriod = "1s" Host = 'localhost' Port = 48080 -[Binding] +[Trigger] Type="edgex-messagebus" SubscribeTopics="events, edgex/events" PublishTopic="event-xml" #TODO: remove if service is NOT publishing back to the message bus - -[MessageBus] -Type = 'zero' - [MessageBus.SubscribeHost] + [Trigger.EdgexMessageBus] + Type = 'zero' + [Trigger.EdgexMessageBus.SubscribeHost] Host = 'localhost' Port = 5563 Protocol = 'tcp' - [MessageBus.PublishHost] # TODO: Remove if service is NOT publishing back to the message bus + [Trigger.EdgexMessageBus.PublishHost] # TODO: Remove if service is NOT publishing back to the message bus Host = '*' Port = 5564 Protocol = 'tcp' -# TODO: If using mqtt messagebus, Uncomment this section and remove above [Binding] & [MessageBus], -# Otherwise remove this commentedout block -#[Binding] +# TODO: If using mqtt messagebus, Uncomment this section and remove above [Trigger] section, +# Otherwise remove this commented out block +#[Trigger] #Type="edgex-messagebus" #SubscribeTopics="events, edgex/events/#" #PublishTopic="event-xml" # TODO: Remove if service is NOT publishing back to the message bus -# -#[MessageBus] -# Type = 'mqtt' -# [MessageBus.SubscribeHost] +# [Trigger.EdgexMessageBus] +# Type = 'mqtt' +# [Trigger.EdgexMessageBus.SubscribeHost] +# Host = 'localhost' +# Port = 1883 +# Protocol = 'tcp' +# [Trigger.EdgexMessageBus.PublishHost] # TODO: Remove if service is NOT publishing back to the message bus # Host = 'localhost' # Port = 1883 # Protocol = 'tcp' -# [MessageBus.PublishHost] # TODO: Remove if service is NOT publishing back to the message bus -# Host = 'localhost' -# Port = 1883 -# Protocol = 'tcp' +# [Trigger.EdgexMessageBus.Optional] +# ClientId ="new-app-service" +# Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once) +# KeepAlive = "10" # Seconds (must be 2 or greater) +# Retained = "false" +# AutoReconnect = "true" +# ConnectTimeout = "30" # Seconds +# SkipCertVerify = "false" + [ApplicationSettings] # TODO: Add custom settings needed by your app service diff --git a/appsdk/sdk.go b/appsdk/sdk.go index 829fc7905..bdb5d26f8 100644 --- a/appsdk/sdk.go +++ b/appsdk/sdk.go @@ -64,10 +64,9 @@ const ( envProfile = "EDGEX_PROFILE" envServiceKey = "EDGEX_SERVICE_KEY" - bindingTypeMessageBus = "MESSAGEBUS" - bindingTypeEdgeXMessageBus = "EDGEX-MESSAGEBUS" - bindingTypeMQTT = "EXTERNAL-MQTT" - bindingTypeHTTP = "HTTP" + TriggerTypeMessageBus = "EDGEX-MESSAGEBUS" + TriggerTypeMQTT = "EXTERNAL-MQTT" + TriggerTypeHTTP = "HTTP" OptionalPasswordKey = "Password" ) @@ -423,15 +422,15 @@ func (sdk *AppFunctionsSDK) Initialize() error { // If using the RedisStreams MessageBus implementation then need to make sure the // password for the Redis DB is set in the MessageBus Optional properties. - bindingType := strings.ToUpper(sdk.config.Binding.Type) - if (bindingType == bindingTypeMessageBus || bindingType == bindingTypeEdgeXMessageBus) && - sdk.config.MessageBus.Type == messaging.RedisStreams { + triggerType := strings.ToUpper(sdk.config.Trigger.Type) + if triggerType == TriggerTypeMessageBus && + sdk.config.Trigger.EdgexMessageBus.Type == messaging.RedisStreams { credentials, err := sdk.secretProvider.GetSecrets(sdk.config.Database.Type) if err != nil { return fmt.Errorf("unable to set RedisStreams password from DB credentials") } - sdk.config.MessageBus.Optional[OptionalPasswordKey] = credentials[secret.PasswordKey] + sdk.config.Trigger.EdgexMessageBus.Optional[OptionalPasswordKey] = credentials[secret.PasswordKey] } // We do special processing when the writeable section of the configuration changes, so have diff --git a/appsdk/sdk_test.go b/appsdk/sdk_test.go index f03c2a28d..7fffc72d4 100644 --- a/appsdk/sdk_test.go +++ b/appsdk/sdk_test.go @@ -41,7 +41,7 @@ var lc logger.LoggingClient func TestMain(m *testing.M) { // No remote and no file results in STDOUT logging only - lc = logger.NewMockClient() + lc = logger.NewClient("cc", "DEBUG") m.Run() } @@ -88,7 +88,7 @@ func TestSetupHTTPTrigger(t *testing.T) { sdk := AppFunctionsSDK{ LoggingClient: lc, config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ + Trigger: common.TriggerInfo{ Type: "htTp", }, }, @@ -105,8 +105,8 @@ func TestSetupMessageBusTrigger(t *testing.T) { sdk := AppFunctionsSDK{ LoggingClient: lc, config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, }, }, } @@ -122,8 +122,8 @@ func TestSetFunctionsPipelineNoTransforms(t *testing.T) { sdk := AppFunctionsSDK{ LoggingClient: lc, config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, }, }, } @@ -137,8 +137,8 @@ func TestSetFunctionsPipelineOneTransform(t *testing.T) { LoggingClient: lc, runtime: &runtime.GolangRuntime{}, config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, }, }, } diff --git a/appsdk/triggerfactory.go b/appsdk/triggerfactory.go index 31d60d55c..56b0d83f5 100644 --- a/appsdk/triggerfactory.go +++ b/appsdk/triggerfactory.go @@ -1,5 +1,5 @@ // -// Copyright (c) 2020 Technotects +// Copyright (c) 2020 Technocrats // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -56,25 +56,24 @@ func (sdk *AppFunctionsSDK) defaultTriggerContextBuilder(env types.MessageEnvelo } // RegisterCustomTriggerFactory allows users to register builders for custom trigger types -func (s *AppFunctionsSDK) RegisterCustomTriggerFactory(name string, +func (sdk *AppFunctionsSDK) RegisterCustomTriggerFactory(name string, factory func(TriggerConfig) (Trigger, error)) error { nu := strings.ToUpper(name) - if nu == bindingTypeEdgeXMessageBus || - nu == bindingTypeMessageBus || - nu == bindingTypeHTTP || - nu == bindingTypeMQTT { + if nu == TriggerTypeMessageBus || + nu == TriggerTypeHTTP || + nu == TriggerTypeMQTT { return errors.New(fmt.Sprintf("cannot register custom trigger for builtin type (%s)", name)) } - if s.customTriggerFactories == nil { - s.customTriggerFactories = make(map[string]func(sdk *AppFunctionsSDK) (Trigger, error), 1) + if sdk.customTriggerFactories == nil { + sdk.customTriggerFactories = make(map[string]func(sdk *AppFunctionsSDK) (Trigger, error), 1) } - s.customTriggerFactories[nu] = func(sdk *AppFunctionsSDK) (Trigger, error) { + sdk.customTriggerFactories[nu] = func(sdk *AppFunctionsSDK) (Trigger, error) { return factory(TriggerConfig{ - Config: s.config, - Logger: s.LoggingClient, + Config: sdk.config, + Logger: sdk.LoggingClient, ContextBuilder: sdk.defaultTriggerContextBuilder, MessageProcessor: sdk.defaultTriggerMessageProcessor, }) @@ -86,19 +85,18 @@ func (s *AppFunctionsSDK) RegisterCustomTriggerFactory(name string, // setupTrigger configures the appropriate trigger as specified by configuration. func (sdk *AppFunctionsSDK) setupTrigger(configuration *common.ConfigurationStruct, runtime *runtime.GolangRuntime) Trigger { var t Trigger - // Need to make dynamic, search for the binding that is input + // Need to make dynamic, search for the trigger that is input - switch triggerType := strings.ToUpper(configuration.Binding.Type); triggerType { - case bindingTypeHTTP: + switch triggerType := strings.ToUpper(configuration.Trigger.Type); triggerType { + case TriggerTypeHTTP: sdk.LoggingClient.Info("HTTP trigger selected") t = &http.Trigger{Configuration: configuration, Runtime: runtime, Webserver: sdk.webserver, EdgeXClients: sdk.EdgexClients} - case bindingTypeMessageBus, - bindingTypeEdgeXMessageBus: // Allows for more explicit name now that we have plain MQTT option also + case TriggerTypeMessageBus: sdk.LoggingClient.Info("EdgeX MessageBus trigger selected") t = &messagebus.Trigger{Configuration: configuration, Runtime: runtime, EdgeXClients: sdk.EdgexClients} - case bindingTypeMQTT: + case TriggerTypeMQTT: sdk.LoggingClient.Info("External MQTT trigger selected") t = mqtt.NewTrigger(configuration, runtime, sdk.EdgexClients, sdk.secretProvider) @@ -111,7 +109,7 @@ func (sdk *AppFunctionsSDK) setupTrigger(configuration *common.ConfigurationStru return nil } } else { - sdk.LoggingClient.Error(fmt.Sprintf("Invalid Trigger type of '%s' specified", configuration.Binding.Type)) + sdk.LoggingClient.Error(fmt.Sprintf("Invalid Trigger type of '%s' specified", configuration.Trigger.Type)) } } diff --git a/appsdk/triggerfactory_test.go b/appsdk/triggerfactory_test.go index a7b2c1f29..d862ab989 100644 --- a/appsdk/triggerfactory_test.go +++ b/appsdk/triggerfactory_test.go @@ -37,17 +37,7 @@ import ( ) func TestRegisterCustomTriggerFactory_HTTP(t *testing.T) { - name := strings.ToTitle(bindingTypeHTTP) - - sdk := AppFunctionsSDK{} - err := sdk.RegisterCustomTriggerFactory(name, nil) - - require.Error(t, err, "should throw error") - require.Zero(t, len(sdk.customTriggerFactories), "nothing should be registered") -} - -func TestRegisterCustomTriggerFactory_MessageBus(t *testing.T) { - name := strings.ToTitle(bindingTypeMessageBus) + name := strings.ToTitle(TriggerTypeHTTP) sdk := AppFunctionsSDK{} err := sdk.RegisterCustomTriggerFactory(name, nil) @@ -57,7 +47,7 @@ func TestRegisterCustomTriggerFactory_MessageBus(t *testing.T) { } func TestRegisterCustomTriggerFactory_EdgeXMessageBus(t *testing.T) { - name := strings.ToTitle(bindingTypeEdgeXMessageBus) + name := strings.ToTitle(TriggerTypeMessageBus) sdk := AppFunctionsSDK{} err := sdk.RegisterCustomTriggerFactory(name, nil) @@ -67,7 +57,7 @@ func TestRegisterCustomTriggerFactory_EdgeXMessageBus(t *testing.T) { } func TestRegisterCustomTriggerFactory_MQTT(t *testing.T) { - name := strings.ToTitle(bindingTypeMQTT) + name := strings.ToTitle(TriggerTypeMQTT) sdk := AppFunctionsSDK{} err := sdk.RegisterCustomTriggerFactory(name, nil) @@ -100,8 +90,8 @@ func TestRegisterCustomTrigger(t *testing.T) { func TestSetupTrigger_HTTP(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "http", + Trigger: common.TriggerInfo{ + Type: TriggerTypeHTTP, }, }, LoggingClient: logger.MockLogger{}, @@ -113,27 +103,11 @@ func TestSetupTrigger_HTTP(t *testing.T) { require.IsType(t, &http.Trigger{}, trigger, "should be an http trigger") } -func TestSetupTrigger_MessageBus(t *testing.T) { - sdk := AppFunctionsSDK{ - config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "messagebus", - }, - }, - LoggingClient: logger.MockLogger{}, - } - - trigger := sdk.setupTrigger(sdk.config, sdk.runtime) - - require.NotNil(t, trigger, "should be defined") - require.IsType(t, &messagebus.Trigger{}, trigger, "should be a messagebus trigger") -} - func TestSetupTrigger_EdgeXMessageBus(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "edgex-messagebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, }, }, LoggingClient: logger.MockLogger{}, @@ -148,8 +122,8 @@ func TestSetupTrigger_EdgeXMessageBus(t *testing.T) { func TestSetupTrigger_MQTT(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "external-mqtt", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMQTT, }, }, LoggingClient: logger.MockLogger{}, @@ -164,7 +138,7 @@ func TestSetupTrigger_MQTT(t *testing.T) { type mockCustomTrigger struct { } -func (*mockCustomTrigger) Initialize(wg *sync.WaitGroup, ctx context.Context, background <-chan types.MessageEnvelope) (bootstrap.Deferred, error) { +func (*mockCustomTrigger) Initialize(_ *sync.WaitGroup, _ context.Context, _ <-chan types.MessageEnvelope) (bootstrap.Deferred, error) { return nil, nil } @@ -173,16 +147,17 @@ func TestSetupTrigger_CustomType(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ + Trigger: common.TriggerInfo{ Type: triggerName, }, }, LoggingClient: logger.MockLogger{}, } - sdk.RegisterCustomTriggerFactory(triggerName, func(c TriggerConfig) (Trigger, error) { + err := sdk.RegisterCustomTriggerFactory(triggerName, func(c TriggerConfig) (Trigger, error) { return &mockCustomTrigger{}, nil }) + require.NoError(t, err) trigger := sdk.setupTrigger(sdk.config, sdk.runtime) @@ -195,16 +170,17 @@ func TestSetupTrigger_CustomType_Error(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ + Trigger: common.TriggerInfo{ Type: triggerName, }, }, LoggingClient: logger.MockLogger{}, } - sdk.RegisterCustomTriggerFactory(triggerName, func(c TriggerConfig) (Trigger, error) { + err := sdk.RegisterCustomTriggerFactory(triggerName, func(c TriggerConfig) (Trigger, error) { return &mockCustomTrigger{}, errors.New("this should force returning nil even though we'll have a value") }) + require.NoError(t, err) trigger := sdk.setupTrigger(sdk.config, sdk.runtime) @@ -216,7 +192,7 @@ func TestSetupTrigger_CustomType_NotFound(t *testing.T) { sdk := AppFunctionsSDK{ config: &common.ConfigurationStruct{ - Binding: common.BindingInfo{ + Trigger: common.TriggerInfo{ Type: triggerName, }, }, diff --git a/internal/common/config.go b/internal/common/config.go index 6a0456885..5c7251ce8 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -20,7 +20,6 @@ import ( "time" bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/v2/config" - "github.com/edgexfoundry/go-mod-messaging/v2/pkg/types" "github.com/edgexfoundry/app-functions-sdk-go/v2/internal/store/db" @@ -42,25 +41,21 @@ type WritableInfo struct { // ConfigurationStruct // swagger:model ConfigurationStruct type ConfigurationStruct struct { - // Writable + // Writable contains the configuration that change be change on the fly Writable WritableInfo - // Registry + // Registry contains the configuration for connecting the Registry service Registry bootstrapConfig.RegistryInfo - // Service + // Service contains the standard 'service' configuration for the Application service Service ServiceInfo - // MessageBus - MessageBus types.MessageBusConfig - // MqttBroker - ExternalMqtt ExternalMqttConfig - // Binding - Binding BindingInfo - // ApplicationSettings + // Trigger contains the configuration for the Function Pipeline Trigger + Trigger TriggerInfo + // ApplicationSettings contains the custom configuration for the Application service ApplicationSettings map[string]string - // Clients + // Clients contains the configuration for connecting to the dependent Edgex clients Clients map[string]bootstrapConfig.ClientInfo - // Database + // Database contains the configuration for connection to the Database Database db.DatabaseInfo - // SecretStore + // SecretStore contains the configuration for connection to the Secret Store when in secure mode SecretStore bootstrapConfig.SecretStoreInfo } @@ -79,16 +74,21 @@ type ServiceInfo struct { Timeout string } -// BindingInfo contains Metadata associated with each binding -type BindingInfo struct { +// TriggerInfo contains Metadata associated with each Trigger +type TriggerInfo struct { // Type of trigger to start pipeline - // - // example: messagebus - // required: true - // enum: messagebus (edgex-messagebus), http, external-mqtt - Type string - SubscribeTopics string // Comma separated list of topics. - PublishTopic string + // enum: http, edgex-messagebus, or external-mqtt + Type string + // SubscribeTopics is a comma separated list of topics + // Used when Type=edgex-messagebus, or Type=external-mqtt + SubscribeTopics string + // PublishTopic is the topic to publish pipeline output (if any) to + // Used when Type=edgex-messagebus, or Type=external-mqtt + PublishTopic string + // Used when Type=edgex-messagebus + EdgexMessageBus types.MessageBusConfig + // Used when Type=external-mqtt + ExternalMqtt ExternalMqttConfig } // ExternalMqttConfig contains the MQTT broker configuration for MQTT Trigger diff --git a/internal/trigger/messagebus/messaging.go b/internal/trigger/messagebus/messaging.go index 9322172aa..af43dce03 100644 --- a/internal/trigger/messagebus/messaging.go +++ b/internal/trigger/messagebus/messaging.go @@ -50,18 +50,18 @@ func (trigger *Trigger) Initialize(appWg *sync.WaitGroup, appCtx context.Context var err error lc := trigger.EdgeXClients.LoggingClient - lc.Infof("Initializing Message Bus Trigger for '%s'", trigger.Configuration.MessageBus.Type) + lc.Infof("Initializing Message Bus Trigger for '%s'", trigger.Configuration.Trigger.EdgexMessageBus.Type) - trigger.client, err = messaging.NewMessageClient(trigger.Configuration.MessageBus) + trigger.client, err = messaging.NewMessageClient(trigger.Configuration.Trigger.EdgexMessageBus) if err != nil { return nil, err } - if len(strings.TrimSpace(trigger.Configuration.Binding.SubscribeTopics)) == 0 { + if len(strings.TrimSpace(trigger.Configuration.Trigger.SubscribeTopics)) == 0 { // Still allows subscribing to blank topic to receive all messages - trigger.topics = append(trigger.topics, types.TopicChannel{Topic: trigger.Configuration.Binding.SubscribeTopics, Messages: make(chan types.MessageEnvelope)}) + trigger.topics = append(trigger.topics, types.TopicChannel{Topic: trigger.Configuration.Trigger.SubscribeTopics, Messages: make(chan types.MessageEnvelope)}) } else { - topics := util.DeleteEmptyAndTrim(strings.FieldsFunc(trigger.Configuration.Binding.SubscribeTopics, util.SplitComma)) + topics := util.DeleteEmptyAndTrim(strings.FieldsFunc(trigger.Configuration.Trigger.SubscribeTopics, util.SplitComma)) for _, topic := range topics { trigger.topics = append(trigger.topics, types.TopicChannel{Topic: topic, Messages: make(chan types.MessageEnvelope)}) } @@ -75,17 +75,17 @@ func (trigger *Trigger) Initialize(appWg *sync.WaitGroup, appCtx context.Context } lc.Infof("Subscribing to topic(s): '%s' @ %s://%s:%d", - trigger.Configuration.Binding.SubscribeTopics, - trigger.Configuration.MessageBus.SubscribeHost.Protocol, - trigger.Configuration.MessageBus.SubscribeHost.Host, - trigger.Configuration.MessageBus.SubscribeHost.Port) + trigger.Configuration.Trigger.SubscribeTopics, + trigger.Configuration.Trigger.EdgexMessageBus.SubscribeHost.Protocol, + trigger.Configuration.Trigger.EdgexMessageBus.SubscribeHost.Host, + trigger.Configuration.Trigger.EdgexMessageBus.SubscribeHost.Port) - if len(trigger.Configuration.MessageBus.PublishHost.Host) > 0 { + if len(trigger.Configuration.Trigger.EdgexMessageBus.PublishHost.Host) > 0 { lc.Infof("Publishing to topic: '%s' @ %s://%s:%d", - trigger.Configuration.Binding.PublishTopic, - trigger.Configuration.MessageBus.PublishHost.Protocol, - trigger.Configuration.MessageBus.PublishHost.Host, - trigger.Configuration.MessageBus.PublishHost.Port) + trigger.Configuration.Trigger.PublishTopic, + trigger.Configuration.Trigger.EdgexMessageBus.PublishHost.Protocol, + trigger.Configuration.Trigger.EdgexMessageBus.PublishHost.Host, + trigger.Configuration.Trigger.EdgexMessageBus.PublishHost.Port) } // Need to have a go func for each subscription so we know with topic the data was received for. @@ -122,13 +122,13 @@ func (trigger *Trigger) Initialize(appWg *sync.WaitGroup, appCtx context.Context case bg := <-background: go func() { - err := trigger.client.Publish(bg, trigger.Configuration.Binding.PublishTopic) + err := trigger.client.Publish(bg, trigger.Configuration.Trigger.PublishTopic) if err != nil { lc.Errorf("Failed to publish background Message to bus, %v", err) return } - lc.Debugf("Published background message to bus on %s topic", trigger.Configuration.Binding.PublishTopic) + lc.Debugf("Published background message to bus on %s topic", trigger.Configuration.Trigger.PublishTopic) lc.Tracef("%s=%s", clients.CorrelationHeader, bg.CorrelationID) }() } @@ -136,7 +136,7 @@ func (trigger *Trigger) Initialize(appWg *sync.WaitGroup, appCtx context.Context }() if err := trigger.client.Subscribe(trigger.topics, messageErrors); err != nil { - return nil, fmt.Errorf("failed to subscribe to topic(s) '%s': %s", trigger.Configuration.Binding.SubscribeTopics, err.Error()) + return nil, fmt.Errorf("failed to subscribe to topic(s) '%s': %s", trigger.Configuration.Trigger.SubscribeTopics, err.Error()) } deferred := func() { @@ -186,13 +186,13 @@ func (trigger *Trigger) processMessage(logger logger.LoggingClient, triggerTopic Payload: edgexContext.OutputData, ContentType: contentType, } - err := trigger.client.Publish(outputEnvelope, trigger.Configuration.Binding.PublishTopic) + err := trigger.client.Publish(outputEnvelope, trigger.Configuration.Trigger.PublishTopic) if err != nil { logger.Errorf("Failed to publish Message to bus, %v", err) return } - logger.Debugf("Published message to bus on '%s' topic", trigger.Configuration.Binding.PublishTopic) + logger.Debugf("Published message to bus on '%s' topic", trigger.Configuration.Trigger.PublishTopic) logger.Tracef("%s=%s", clients.CorrelationHeader, message.CorrelationID) } } diff --git a/internal/trigger/messagebus/messaging_test.go b/internal/trigger/messagebus/messaging_test.go index b0a09175e..685d8904d 100644 --- a/internal/trigger/messagebus/messaging_test.go +++ b/internal/trigger/messagebus/messaging_test.go @@ -41,7 +41,10 @@ import ( "github.com/stretchr/testify/require" ) -var logClient logger.LoggingClient +// Note the constant TriggerTypeMessageBus can not be used due to cyclic imports +const TriggerTypeMessageBus = "EDGEX-MESSAGEBUS" + +var lc logger.LoggingClient var addEventRequest = createTestEventRequest() var expectedEvent = addEventRequest.Event @@ -53,36 +56,38 @@ func createTestEventRequest() requests.AddEventRequest { return request } -func init() { - logClient = logger.NewMockClient() +func TestMain(m *testing.M) { + lc = logger.NewMockClient() + m.Run() } func TestInitialize(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "publish", SubscribeTopics: "events", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5563, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5563, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + + PublishHost: types.HostInfo{ + Host: "*", + Port: 5563, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5563, + Protocol: "tcp", + }, }, }, } goRuntime := &runtime.GolangRuntime{} - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} _, _ = trigger.Initialize(&sync.WaitGroup{}, context.Background(), nil) assert.NotNil(t, trigger.client, "Expected client to be set") assert.Equal(t, 1, len(trigger.topics)) @@ -93,29 +98,30 @@ func TestInitialize(t *testing.T) { func TestInitializeBadConfiguration(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "publish", SubscribeTopics: "events", - }, - MessageBus: types.MessageBusConfig{ - Type: "aaaa", //as type is not "zero", should return an error on client initialization - PublishHost: types.HostInfo{ - Host: "*", - Port: 5568, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5568, - Protocol: "tcp", + + EdgexMessageBus: types.MessageBusConfig{ + Type: "aaaa", //as type is not "zero", should return an error on client initialization + PublishHost: types.HostInfo{ + Host: "*", + Port: 5568, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5568, + Protocol: "tcp", + }, }, }, } goRuntime := &runtime.GolangRuntime{} - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} _, err := trigger.Initialize(&sync.WaitGroup{}, context.Background(), nil) assert.Error(t, err) } @@ -123,22 +129,22 @@ func TestInitializeBadConfiguration(t *testing.T) { func TestInitializeAndProcessEventWithNoOutput(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "", SubscribeTopics: "", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5566, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5564, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5566, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5564, + Protocol: "tcp", + }, }, }, } @@ -156,7 +162,7 @@ func TestInitializeAndProcessEventWithNoOutput(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) goRuntime.SetTransforms([]appcontext.AppFunction{transform1}) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} _, _ = trigger.Initialize(&sync.WaitGroup{}, context.Background(), nil) payload, err := json.Marshal(addEventRequest) @@ -191,22 +197,22 @@ func TestInitializeAndProcessEventWithNoOutput(t *testing.T) { func TestInitializeAndProcessEventWithOutput(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "PublishTopic", SubscribeTopics: "SubscribeTopic", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5586, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5584, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5586, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5584, + Protocol: "tcp", + }, }, }, } @@ -229,7 +235,7 @@ func TestInitializeAndProcessEventWithOutput(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) goRuntime.SetTransforms([]appcontext.AppFunction{transform1}) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} testClientConfig := types.MessageBusConfig{ SubscribeHost: types.HostInfo{ @@ -247,7 +253,7 @@ func TestInitializeAndProcessEventWithOutput(t *testing.T) { testClient, err := messaging.NewMessageClient(testClientConfig) //new client to publish & subscribe require.NoError(t, err, "Failed to create test client") - testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Binding.PublishTopic, Messages: make(chan types.MessageEnvelope)}} + testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Trigger.PublishTopic, Messages: make(chan types.MessageEnvelope)}} testMessageErrors := make(chan error) err = testClient.Subscribe(testTopics, testMessageErrors) //subscribe in order to receive transformed output to the bus @@ -289,22 +295,22 @@ func TestInitializeAndProcessEventWithOutput(t *testing.T) { func TestInitializeAndProcessEventWithOutput_InferJSON(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "PublishTopic", SubscribeTopics: "SubscribeTopic", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5701, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5702, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5701, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5702, + Protocol: "tcp", + }, }, }, } @@ -324,7 +330,7 @@ func TestInitializeAndProcessEventWithOutput_InferJSON(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) goRuntime.SetTransforms([]appcontext.AppFunction{transform1}) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} testClientConfig := types.MessageBusConfig{ SubscribeHost: types.HostInfo{ @@ -342,7 +348,7 @@ func TestInitializeAndProcessEventWithOutput_InferJSON(t *testing.T) { testClient, err := messaging.NewMessageClient(testClientConfig) //new client to publish & subscribe require.NoError(t, err, "Failed to create test client") - testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Binding.PublishTopic, Messages: make(chan types.MessageEnvelope)}} + testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Trigger.PublishTopic, Messages: make(chan types.MessageEnvelope)}} testMessageErrors := make(chan error) err = testClient.Subscribe(testTopics, testMessageErrors) //subscribe in order to receive transformed output to the bus @@ -384,22 +390,22 @@ func TestInitializeAndProcessEventWithOutput_InferJSON(t *testing.T) { func TestInitializeAndProcessEventWithOutput_AssumeCBOR(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "PublishTopic", SubscribeTopics: "SubscribeTopic", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5703, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5704, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5703, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5704, + Protocol: "tcp", + }, }, }, } @@ -418,7 +424,7 @@ func TestInitializeAndProcessEventWithOutput_AssumeCBOR(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) goRuntime.SetTransforms([]appcontext.AppFunction{transform1}) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} testClientConfig := types.MessageBusConfig{ SubscribeHost: types.HostInfo{ @@ -436,7 +442,7 @@ func TestInitializeAndProcessEventWithOutput_AssumeCBOR(t *testing.T) { testClient, err := messaging.NewMessageClient(testClientConfig) //new client to publish & subscribe require.NoError(t, err, "Failed to create test client") - testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Binding.PublishTopic, Messages: make(chan types.MessageEnvelope)}} + testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Trigger.PublishTopic, Messages: make(chan types.MessageEnvelope)}} testMessageErrors := make(chan error) err = testClient.Subscribe(testTopics, testMessageErrors) //subscribe in order to receive transformed output to the bus @@ -476,22 +482,22 @@ func TestInitializeAndProcessEventWithOutput_AssumeCBOR(t *testing.T) { func TestInitializeAndProcessBackgroundMessage(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "PublishTopic", SubscribeTopics: "SubscribeTopic", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5588, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5590, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5588, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5590, + Protocol: "tcp", + }, }, }, } @@ -502,7 +508,7 @@ func TestInitializeAndProcessBackgroundMessage(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} testClientConfig := types.MessageBusConfig{ SubscribeHost: types.HostInfo{ @@ -520,7 +526,7 @@ func TestInitializeAndProcessBackgroundMessage(t *testing.T) { testClient, err := messaging.NewMessageClient(testClientConfig) //new client to publish & subscribe require.NoError(t, err, "Failed to create test client") - testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Binding.PublishTopic, Messages: make(chan types.MessageEnvelope)}} + testTopics := []types.TopicChannel{{Topic: trigger.Configuration.Trigger.PublishTopic, Messages: make(chan types.MessageEnvelope)}} testMessageErrors := make(chan error) err = testClient.Subscribe(testTopics, testMessageErrors) //subscribe in order to receive transformed output to the bus @@ -554,22 +560,22 @@ func TestInitializeAndProcessBackgroundMessage(t *testing.T) { func TestInitializeAndProcessEventMultipleTopics(t *testing.T) { config := common.ConfigurationStruct{ - Binding: common.BindingInfo{ - Type: "edgeX-meSsaGebus", + Trigger: common.TriggerInfo{ + Type: TriggerTypeMessageBus, PublishTopic: "", SubscribeTopics: "t1,t2", - }, - MessageBus: types.MessageBusConfig{ - Type: "zero", - PublishHost: types.HostInfo{ - Host: "*", - Port: 5592, - Protocol: "tcp", - }, - SubscribeHost: types.HostInfo{ - Host: "localhost", - Port: 5594, - Protocol: "tcp", + EdgexMessageBus: types.MessageBusConfig{ + Type: "zero", + PublishHost: types.HostInfo{ + Host: "*", + Port: 5592, + Protocol: "tcp", + }, + SubscribeHost: types.HostInfo{ + Host: "localhost", + Port: 5594, + Protocol: "tcp", + }, }, }, } @@ -586,7 +592,7 @@ func TestInitializeAndProcessEventMultipleTopics(t *testing.T) { goRuntime := &runtime.GolangRuntime{} goRuntime.Initialize(nil, nil) goRuntime.SetTransforms([]appcontext.AppFunction{transform1}) - trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: logClient}} + trigger := Trigger{Configuration: &config, Runtime: goRuntime, EdgeXClients: common.EdgeXClients{LoggingClient: lc}} _, err := trigger.Initialize(&sync.WaitGroup{}, context.Background(), nil) require.NoError(t, err) diff --git a/internal/trigger/mqtt/mqtt.go b/internal/trigger/mqtt/mqtt.go index d7b2b5b89..167aec735 100644 --- a/internal/trigger/mqtt/mqtt.go +++ b/internal/trigger/mqtt/mqtt.go @@ -65,8 +65,8 @@ func NewTrigger( func (trigger *Trigger) Initialize(_ *sync.WaitGroup, _ context.Context, background <-chan types.MessageEnvelope) (bootstrap.Deferred, error) { // Convenience short cuts logger := trigger.edgeXClients.LoggingClient - brokerConfig := trigger.configuration.ExternalMqtt - topics := trigger.configuration.Binding.SubscribeTopics + brokerConfig := trigger.configuration.Trigger.ExternalMqtt + topics := trigger.configuration.Trigger.SubscribeTopics logger.Info("Initializing MQTT Trigger") @@ -75,12 +75,12 @@ func (trigger *Trigger) Initialize(_ *sync.WaitGroup, _ context.Context, backgro } if len(strings.TrimSpace(topics)) == 0 { - return nil, fmt.Errorf("missing SubscribeTopics for MQTT Trigger. Must be present in [Binding] section.") + return nil, fmt.Errorf("missing SubscribeTopics for MQTT Trigger. Must be present in [Trigger] section.") } brokerUrl, err := url.Parse(brokerConfig.Url) if err != nil { - return nil, fmt.Errorf("invalid MQTT Broker Url '%s': %s", trigger.configuration.ExternalMqtt.Url, err.Error()) + return nil, fmt.Errorf("invalid MQTT Broker Url '%s': %s", trigger.configuration.Trigger.ExternalMqtt.Url, err.Error()) } opts := pahoMqtt.NewClientOptions() @@ -131,8 +131,8 @@ func (trigger *Trigger) Initialize(_ *sync.WaitGroup, _ context.Context, backgro func (trigger *Trigger) onConnectHandler(mqttClient pahoMqtt.Client) { // Convenience short cuts logger := trigger.edgeXClients.LoggingClient - topics := util.DeleteEmptyAndTrim(strings.FieldsFunc(trigger.configuration.Binding.SubscribeTopics, util.SplitComma)) - qos := trigger.configuration.ExternalMqtt.QoS + topics := util.DeleteEmptyAndTrim(strings.FieldsFunc(trigger.configuration.Trigger.SubscribeTopics, util.SplitComma)) + qos := trigger.configuration.Trigger.ExternalMqtt.QoS for _, topic := range topics { if token := mqttClient.Subscribe(topic, qos, trigger.messageHandler); token.Wait() && token.Error() != nil { @@ -143,14 +143,14 @@ func (trigger *Trigger) onConnectHandler(mqttClient pahoMqtt.Client) { } } - logger.Infof("Subscribed to topic(s) '%s' for MQTT trigger", trigger.configuration.Binding.SubscribeTopics) + logger.Infof("Subscribed to topic(s) '%s' for MQTT trigger", trigger.configuration.Trigger.SubscribeTopics) } func (trigger *Trigger) messageHandler(client pahoMqtt.Client, message pahoMqtt.Message) { // Convenience short cuts logger := trigger.edgeXClients.LoggingClient - brokerConfig := trigger.configuration.ExternalMqtt - topic := trigger.configuration.Binding.PublishTopic + brokerConfig := trigger.configuration.Trigger.ExternalMqtt + topic := trigger.configuration.Trigger.PublishTopic data := message.Payload() contentType := clients.ContentTypeJSON diff --git a/internal/webserver/server.go b/internal/webserver/server.go index 5eb67ba6e..321f933aa 100644 --- a/internal/webserver/server.go +++ b/internal/webserver/server.go @@ -307,7 +307,7 @@ func (webserver *WebServer) ConfigureStandardRoutes() { // // Trigger // -// Available when HTTPTrigger is specified as the binding in configuration. This API +// Available when 'http' is specified as the Trigger Type in configuration. This API // provides a way to initiate and start processing the defined pipeline using the data submitted. // // --- diff --git a/internal/webserver/server_test.go b/internal/webserver/server_test.go index 338a2e55a..ec6d1cd4d 100644 --- a/internal/webserver/server_test.go +++ b/internal/webserver/server_test.go @@ -110,7 +110,7 @@ func TestConfigureAndConfigRoute(t *testing.T) { rr := httptest.NewRecorder() webserver.router.ServeHTTP(rr, req) - expected := `{"Writable":{"LogLevel":"","Pipeline":{"ExecutionOrder":"","UseTargetTypeOfByteArray":false,"Functions":null},"StoreAndForward":{"Enabled":false,"RetryInterval":"","MaxRetryCount":0},"InsecureSecrets":null},"Registry":{"Host":"","Port":0,"Type":""},"Service":{"BootTimeout":"","CheckInterval":"","Host":"","HTTPSCert":"","HTTPSKey":"","ServerBindAddr":"","Port":0,"Protocol":"","StartupMsg":"","ReadMaxLimit":0,"Timeout":""},"MessageBus":{"PublishHost":{"Host":"","Port":0,"Protocol":""},"SubscribeHost":{"Host":"","Port":0,"Protocol":""},"Type":"","Optional":null},"ExternalMqtt":{"Url":"","ClientId":"","ConnectTimeout":"","AutoReconnect":false,"KeepAlive":0,"QoS":0,"Retain":false,"SkipCertVerify":false,"SecretPath":"","AuthMode":""},"Binding":{"Type":"","SubscribeTopics":"","PublishTopic":""},"ApplicationSettings":null,"Clients":null,"Database":{"Type":"","Host":"","Port":0,"Timeout":"","MaxIdle":0,"BatchSize":0},"SecretStore":{"Type":"","Host":"","Port":0,"Path":"","Protocol":"","Namespace":"","RootCaCertPath":"","ServerName":"","Authentication":{"AuthType":"","AuthToken":""},"AdditionalRetryAttempts":0,"RetryWaitPeriod":"","TokenFile":""}}` + "\n" + expected := `{"Writable":{"LogLevel":"","Pipeline":{"ExecutionOrder":"","UseTargetTypeOfByteArray":false,"Functions":null},"StoreAndForward":{"Enabled":false,"RetryInterval":"","MaxRetryCount":0},"InsecureSecrets":null},"Registry":{"Host":"","Port":0,"Type":""},"Service":{"BootTimeout":"","CheckInterval":"","Host":"","HTTPSCert":"","HTTPSKey":"","ServerBindAddr":"","Port":0,"Protocol":"","StartupMsg":"","ReadMaxLimit":0,"Timeout":""},"Trigger":{"Type":"","SubscribeTopics":"","PublishTopic":"","EdgexMessageBus":{"PublishHost":{"Host":"","Port":0,"Protocol":""},"SubscribeHost":{"Host":"","Port":0,"Protocol":""},"Type":"","Optional":null},"ExternalMqtt":{"Url":"","ClientId":"","ConnectTimeout":"","AutoReconnect":false,"KeepAlive":0,"QoS":0,"Retain":false,"SkipCertVerify":false,"SecretPath":"","AuthMode":""}},"ApplicationSettings":null,"Clients":null,"Database":{"Type":"","Host":"","Port":0,"Timeout":"","MaxIdle":0,"BatchSize":0},"SecretStore":{"Type":"","Host":"","Port":0,"Path":"","Protocol":"","Namespace":"","RootCaCertPath":"","ServerName":"","Authentication":{"AuthType":"","AuthToken":""},"AdditionalRetryAttempts":0,"RetryWaitPeriod":"","TokenFile":""}}` + "\n" body := rr.Body.String() assert.Equal(t, expected, body) diff --git a/openapi/v2/app-functions-sdk.yaml b/openapi/v2/app-functions-sdk.yaml index 4162ebdec..1aa94e7cf 100644 --- a/openapi/v2/app-functions-sdk.yaml +++ b/openapi/v2/app-functions-sdk.yaml @@ -278,7 +278,7 @@ paths: - $ref: '#/components/parameters/correlatedRequestHeader' post: summary: Trigger function pipeline from HTTP request. - description: Available when HTTPTrigger is specified as the binding in configuration. Provides a way to initiate and start processing the defined pipeline using the data submitted. + description: Available when 'http' is specified as the Trigger type in configuration. Provides a way to initiate and start processing the defined pipeline using the data submitted. requestBody: content: application/json: