From 4f13490f719f802194f8eb94c2976c151bd3d83f Mon Sep 17 00:00:00 2001 From: lenny Date: Thu, 30 Jul 2020 12:47:55 -0700 Subject: [PATCH] fix: Allow startup duration/interval to be overridden via environement vars Startup configuration has been removed since it was not used Env vars are inspected when timer is created so they have impact Signed-off-by: lenny --- appsdk/configupdates.go | 3 +-- appsdk/sdk.go | 2 +- go.mod | 2 +- internal/bootstrap/handlers/clients_test.go | 3 +-- internal/bootstrap/handlers/version_test.go | 3 +-- internal/common/config.go | 8 ++------ 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/appsdk/configupdates.go b/appsdk/configupdates.go index 66777eb2e..c83859a83 100644 --- a/appsdk/configupdates.go +++ b/appsdk/configupdates.go @@ -25,7 +25,6 @@ import ( "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/config" "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/startup" - "github.com/edgexfoundry/app-functions-sdk-go/internal" "github.com/edgexfoundry/app-functions-sdk-go/internal/bootstrap/handlers" ) @@ -137,7 +136,7 @@ func (processor *ConfigUpdateProcessor) processConfigChangedStoreForwardEnabled( // StoreClient must be set up for StoreAndForward if sdk.storeClient == nil { var err error - startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault) + startupTimer := startup.NewStartUpTimer(sdk.ServiceKey) sdk.storeClient, err = handlers.InitializeStoreClient(sdk.secretProvider, sdk.config, startupTimer, sdk.LoggingClient) if err != nil { // Error already logged diff --git a/appsdk/sdk.go b/appsdk/sdk.go index b0d499272..30331d6d5 100644 --- a/appsdk/sdk.go +++ b/appsdk/sdk.go @@ -306,7 +306,7 @@ func (sdk *AppFunctionsSDK) GetAppSettingStrings(setting string) ([]string, erro // Initialize will parse command line flags, register for interrupts, // initialize the logging system, and ingest configuration. func (sdk *AppFunctionsSDK) Initialize() error { - startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault) + startupTimer := startup.NewStartUpTimer(sdk.ServiceKey) additionalUsage := " -s/--skipVersionCheck Indicates the service should skip the Core Service's version compatibility check.\n" + diff --git a/go.mod b/go.mod index 1b4872f72..b0603d77a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690 github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9 github.com/eclipse/paho.mqtt.golang v1.2.0 - github.com/edgexfoundry/go-mod-bootstrap v0.0.35 + github.com/edgexfoundry/go-mod-bootstrap v0.0.37 github.com/edgexfoundry/go-mod-core-contracts v0.1.65 github.com/edgexfoundry/go-mod-messaging v0.1.19 github.com/edgexfoundry/go-mod-registry v0.1.20 diff --git a/internal/bootstrap/handlers/clients_test.go b/internal/bootstrap/handlers/clients_test.go index a9ee6cb91..eaec38a84 100644 --- a/internal/bootstrap/handlers/clients_test.go +++ b/internal/bootstrap/handlers/clients_test.go @@ -30,7 +30,6 @@ import ( "github.com/edgexfoundry/go-mod-bootstrap/config" "github.com/edgexfoundry/go-mod-bootstrap/di" - "github.com/edgexfoundry/app-functions-sdk-go/internal" "github.com/edgexfoundry/app-functions-sdk-go/internal/bootstrap/container" "github.com/edgexfoundry/app-functions-sdk-go/internal/common" ) @@ -70,7 +69,7 @@ func TestClientsBootstrapHandler(t *testing.T) { Protocol: "http", } - startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault) + startupTimer := startup.NewStartUpTimer("unit-test") tests := []struct { Name string diff --git a/internal/bootstrap/handlers/version_test.go b/internal/bootstrap/handlers/version_test.go index 8493fc330..d8427ec20 100644 --- a/internal/bootstrap/handlers/version_test.go +++ b/internal/bootstrap/handlers/version_test.go @@ -33,13 +33,12 @@ import ( "github.com/edgexfoundry/go-mod-registry/registry" "github.com/stretchr/testify/assert" - "github.com/edgexfoundry/app-functions-sdk-go/internal" "github.com/edgexfoundry/app-functions-sdk-go/internal/bootstrap/container" "github.com/edgexfoundry/app-functions-sdk-go/internal/common" ) func TestValidateVersionMatch(t *testing.T) { - startupTimer := startup.NewStartUpTimer(internal.BootRetrySecondsDefault, internal.BootTimeoutSecondsDefault) + startupTimer := startup.NewStartUpTimer("unit-test") clients := make(map[string]config.ClientInfo) clients[common.CoreDataClientName] = config.ClientInfo{ diff --git a/internal/common/config.go b/internal/common/config.go index 96facb5ad..1bc7c3ff8 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -19,7 +19,6 @@ package common import ( "time" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces" bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config" "github.com/edgexfoundry/go-mod-core-contracts/models" @@ -66,8 +65,6 @@ type ConfigurationStruct struct { SecretStore bootstrapConfig.SecretStoreInfo // SecretStoreExclusive SecretStoreExclusive bootstrapConfig.SecretStoreInfo - // Startup - Startup bootstrapConfig.StartupInfo } // ServiceInfo is used to hold and configure various settings related to the hosting of this service @@ -160,14 +157,13 @@ func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) boo } // GetBootstrap returns the configuration elements required by the bootstrap. -func (c *ConfigurationStruct) GetBootstrap() interfaces.BootstrapConfiguration { - return interfaces.BootstrapConfiguration{ +func (c *ConfigurationStruct) GetBootstrap() bootstrapConfig.BootstrapConfiguration { + return bootstrapConfig.BootstrapConfiguration{ Clients: c.Clients, Service: c.transformToBootstrapServiceInfo(), Registry: c.Registry, Logging: c.Logging, SecretStore: c.SecretStore, - Startup: c.Startup, } }