From 505c688739c6baeb7936588b5c612c7d4ee74cdd Mon Sep 17 00:00:00 2001 From: bruce Date: Mon, 11 Nov 2024 22:15:25 +0800 Subject: [PATCH] refactor: Replace old Scheduler service with cron Scheduler service BREAKING CHANGE: the cron scheduler name and key changed Replace the old Scheduler service with the new cron Scheduler service Signed-off-by: bruce --- .gitignore | 3 +- Makefile | 21 +- README.md | 2 +- .../res/token-config.json | 2 +- cmd/security-proxy-setup/entrypoint.sh | 8 +- .../res/configuration.yaml | 10 +- .../seed_builtin_entries.sh | 2 +- .../Dockerfile | 10 +- .../main.go | 4 +- .../res/configuration.yaml | 4 +- .../res/db/sql/00-utils.sql | 2 +- .../res/db/sql/01-tables.sql | 4 +- fuzz_test/Dockerfile.fuzz | 2 +- fuzz_test/fuzzing_docker.sh | 2 +- go.mod | 10 +- go.sum | 20 +- .../infrastructure/postgres/client_test.go | 4 +- .../pkg/infrastructure/postgres/consts.go | 2 +- internal/pkg/infrastructure/redis/client.go | 174 ---------------- internal/pkg/infrastructure/redis/interval.go | 183 ----------------- .../infrastructure/redis/intervalaction.go | 193 ------------------ .../application/action/devicecontrol.go | 0 .../application/action/edgexmessagebus.go | 0 .../application/action/gocron.go | 0 .../application/action/rest.go | 0 .../application/scheduleactionrecord.go | 2 +- .../application/scheduleactionrecord_test.go | 6 +- .../application/schedulejob.go | 4 +- .../config/config.go | 2 +- .../container/config.go | 2 +- .../container/database.go | 2 +- .../container/scheduler.go | 2 +- .../controller/http/scheduleactionrecord.go | 4 +- .../http/scheduleactionrecord_test.go | 4 +- .../controller/http/schedulejob.go | 4 +- .../controller/http/schedulejob_test.go | 6 +- .../controller/http/utils_test.go | 0 .../interfaces/SchedulerManager.go | 0 .../infrastructure/interfaces/db.go | 0 .../interfaces/mocks/DBClient.go | 0 .../interfaces/mocks/SchedulerManager.go | 0 .../infrastructure/manager.go | 8 +- .../infrastructure/manager_test.go | 4 +- .../{cronscheduler => scheduler}/init.go | 10 +- .../{cronscheduler => scheduler}/main.go | 18 +- .../{cronscheduler => scheduler}/router.go | 4 +- ...-scheduler.yaml => support-scheduler.yaml} | 10 +- 47 files changed, 101 insertions(+), 653 deletions(-) rename cmd/{support-cron-scheduler => support-scheduler}/Dockerfile (84%) rename cmd/{support-cron-scheduler => support-scheduler}/main.go (88%) rename cmd/{support-cron-scheduler => support-scheduler}/res/configuration.yaml (89%) rename cmd/{support-cron-scheduler => support-scheduler}/res/db/sql/00-utils.sql (70%) rename cmd/{support-cron-scheduler => support-scheduler}/res/db/sql/01-tables.sql (81%) delete mode 100644 internal/pkg/infrastructure/redis/interval.go delete mode 100644 internal/pkg/infrastructure/redis/intervalaction.go rename internal/support/{cronscheduler => scheduler}/application/action/devicecontrol.go (100%) rename internal/support/{cronscheduler => scheduler}/application/action/edgexmessagebus.go (100%) rename internal/support/{cronscheduler => scheduler}/application/action/gocron.go (100%) rename internal/support/{cronscheduler => scheduler}/application/action/rest.go (100%) rename internal/support/{cronscheduler => scheduler}/application/scheduleactionrecord.go (99%) rename internal/support/{cronscheduler => scheduler}/application/scheduleactionrecord_test.go (94%) rename internal/support/{cronscheduler => scheduler}/application/schedulejob.go (98%) rename internal/support/{cronscheduler => scheduler}/config/config.go (99%) rename internal/support/{cronscheduler => scheduler}/container/config.go (88%) rename internal/support/{cronscheduler => scheduler}/container/database.go (85%) rename internal/support/{cronscheduler => scheduler}/container/scheduler.go (86%) rename internal/support/{cronscheduler => scheduler}/controller/http/scheduleactionrecord.go (98%) rename internal/support/{cronscheduler => scheduler}/controller/http/scheduleactionrecord_test.go (99%) rename internal/support/{cronscheduler => scheduler}/controller/http/schedulejob.go (98%) rename internal/support/{cronscheduler => scheduler}/controller/http/schedulejob_test.go (98%) rename internal/support/{cronscheduler => scheduler}/controller/http/utils_test.go (100%) rename internal/support/{cronscheduler => scheduler}/infrastructure/interfaces/SchedulerManager.go (100%) rename internal/support/{cronscheduler => scheduler}/infrastructure/interfaces/db.go (100%) rename internal/support/{cronscheduler => scheduler}/infrastructure/interfaces/mocks/DBClient.go (100%) rename internal/support/{cronscheduler => scheduler}/infrastructure/interfaces/mocks/SchedulerManager.go (100%) rename internal/support/{cronscheduler => scheduler}/infrastructure/manager.go (97%) rename internal/support/{cronscheduler => scheduler}/infrastructure/manager_test.go (97%) rename internal/support/{cronscheduler => scheduler}/init.go (88%) rename internal/support/{cronscheduler => scheduler}/main.go (80%) rename internal/support/{cronscheduler => scheduler}/router.go (97%) rename openapi/{support-cron-scheduler.yaml => support-scheduler.yaml} (99%) diff --git a/.gitignore b/.gitignore index febfffebbf..df30493d42 100644 --- a/.gitignore +++ b/.gitignore @@ -25,10 +25,9 @@ cmd/security-file-token-provider/security-file-token-provider cmd/security-secretstore-setup/security-secretstore-setup cmd/support-logging/support-logging cmd/support-notifications/support-notifications -cmd/support-cron-scheduler/support-cron-scheduler +cmd/support-scheduler/support-scheduler cmd/secrets-config/secrets-config cmd/security-bootstrapper/security-bootstrapper -cmd/security-proxy-auth/security-proxy-auth cmd/security-spiffe-token-provider/security-spiffe-token-provider docs/_build/ diff --git a/Makefile b/Makefile index e9496a96ce..1253836c00 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,6 @@ DOCKERS= \ docker_core_keeper \ docker_support_notifications \ docker_support_scheduler \ - docker_support_cron_scheduler \ docker_security_proxy_auth \ docker_security_proxy_setup \ docker_security_secretstore_setup \ @@ -47,7 +46,7 @@ MICROSERVICES= \ cmd/core-common-config-bootstrapper/core-common-config-bootstrapper \ cmd/core-keeper/core-keeper \ cmd/support-notifications/support-notifications \ - cmd/support-cron-scheduler/support-cron-scheduler \ + cmd/support-scheduler/support-scheduler \ cmd/security-proxy-auth/security-proxy-auth \ cmd/security-secretstore-setup/security-secretstore-setup \ cmd/security-file-token-provider/security-file-token-provider \ @@ -130,9 +129,9 @@ notifications: cmd/support-notifications/support-notifications cmd/support-notifications/support-notifications: $(GO) build -tags "$(ADD_BUILD_TAGS) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-notifications -cron-scheduler: cmd/support-cron-scheduler/support-cron-scheduler -cmd/support-cron-scheduler/support-cron-scheduler: - $(GO) build -tags "$(ADD_BUILD_TAGS) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-cron-scheduler +scheduler: cmd/support-scheduler/support-scheduler +cmd/support-scheduler/support-scheduler: + $(GO) build -tags "$(ADD_BUILD_TAGS) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-scheduler proxy: cmd/security-proxy-setup/security-proxy-setup cmd/security-proxy-setup/security-proxy-setup: @@ -271,7 +270,7 @@ docker_core_keeper: docker_base -t edgexfoundry/core-keeper:$(DOCKER_TAG) \ . -dsupport: dnotifications dscheduler dcronscheduler +dsupport: dnotifications dscheduler dscheduler dnotifications: docker_support_notifications docker_support_notifications: docker_base @@ -286,17 +285,17 @@ docker_support_notifications: docker_base -t edgexfoundry/support-notifications:$(DOCKER_TAG) \ . -dcronscheduler: docker_support_cron_scheduler -docker_support_cron_scheduler: docker_base +dscheduler: docker_support_scheduler +docker_support_scheduler: docker_base docker build \ --build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \ --build-arg http_proxy \ --build-arg https_proxy \ --build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \ - -f cmd/support-cron-scheduler/Dockerfile \ + -f cmd/support-scheduler/Dockerfile \ --label "git_sha=$(GIT_SHA)" \ - -t edgexfoundry/support-cron-scheduler:$(GIT_SHA) \ - -t edgexfoundry/support-cron-scheduler:$(DOCKER_TAG) \ + -t edgexfoundry/support-scheduler:$(GIT_SHA) \ + -t edgexfoundry/support-scheduler:$(DOCKER_TAG) \ . dproxya: docker_security_proxy_auth diff --git a/README.md b/README.md index e662297975..c40fe629c3 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ make docker #### Delayed Start Go Builds For Developers -Currently for EdgeX core services except support services (support-notification and support-cron-scheduler services), the delayed start feature from the dependency go-mod-bootstrap / go-mod-secrets modules are excluded in go builds by default. +Currently for EdgeX core services except support services (support-notification and support-scheduler services), the delayed start feature from the dependency go-mod-bootstrap / go-mod-secrets modules are excluded in go builds by default. If you want to **include** the delayed start feature in the builds for these services, please change the [Makefile in this directory](Makefile). In particular, change the following boolean flag from `false` to `true` before the whole docker builds. ```text diff --git a/cmd/security-file-token-provider/res/token-config.json b/cmd/security-file-token-provider/res/token-config.json index 6e780d6bb3..22633f7d49 100644 --- a/cmd/security-file-token-provider/res/token-config.json +++ b/cmd/security-file-token-provider/res/token-config.json @@ -35,7 +35,7 @@ "device-rest": { "edgex_use_defaults": true }, - "support-cron-scheduler": { + "support-scheduler": { "edgex_use_defaults": true }, "security-proxy-auth": { diff --git a/cmd/security-proxy-setup/entrypoint.sh b/cmd/security-proxy-setup/entrypoint.sh index da255798a5..bafcb0e459 100644 --- a/cmd/security-proxy-setup/entrypoint.sh +++ b/cmd/security-proxy-setup/entrypoint.sh @@ -246,12 +246,12 @@ server { auth_request_set \$auth_status \$upstream_status; } - set \$upstream_support_cron_scheduler edgex-support-cron-scheduler; - location /support-cron-scheduler { + set \$upstream_support_scheduler edgex-support-scheduler; + location /support-scheduler { `cat "${corssnippet}"` - rewrite /support-cron-scheduler/(.*) /\$1 break; + rewrite /support-scheduler/(.*) /\$1 break; resolver 127.0.0.11 valid=30s; - proxy_pass http://\$upstream_support_cron_scheduler:59863; + proxy_pass http://\$upstream_support_scheduler:59863; proxy_redirect off; proxy_set_header Host \$host; auth_request /auth; diff --git a/cmd/security-secretstore-setup/res/configuration.yaml b/cmd/security-secretstore-setup/res/configuration.yaml index 09997cfa49..96c8dd3eea 100644 --- a/cmd/security-secretstore-setup/res/configuration.yaml +++ b/cmd/security-secretstore-setup/res/configuration.yaml @@ -69,9 +69,9 @@ Databases: notifications: Service: support-notifications Username: support_notifications - cronscheduler: - Service: support-cron-scheduler - Username: support_cron_scheduler + scheduler: + Service: support-scheduler + Username: support_scheduler SecureMessageBus: Type: none KuiperConfigPath: /tmp/kuiper/edgex.yaml @@ -89,5 +89,5 @@ SecureMessageBus: Service: app-rules-engine notifications: Service: support-notifications - cronscheduler: - Service: support-cron-scheduler + scheduler: + Service: support-scheduler diff --git a/cmd/security-spire-config/seed_builtin_entries.sh b/cmd/security-spire-config/seed_builtin_entries.sh index 36d4c836e8..f75ad744ce 100755 --- a/cmd/security-spire-config/seed_builtin_entries.sh +++ b/cmd/security-spire-config/seed_builtin_entries.sh @@ -27,7 +27,7 @@ echo "SPIFFE_EDGEX_SVID_BASE=${SPIFFE_EDGEX_SVID_BASE}" echo "EDGEX_SPIFFE_CUSTOM_SERVICES=${EDGEX_SPIFFE_CUSTOM_SERVICES}" -SPIFFE_SERVICES="security-spiffe-token-provider support-notifications support-cron-scheduler \ +SPIFFE_SERVICES="security-spiffe-token-provider support-notifications support-scheduler \ device-bacnet device-camera device-grove device-modbus device-mqtt device-rest device-snmp \ device-virtual device-rfid-llrp device-coap device-gpio \ app-http-export app-mqtt-export app-sample app-rfid-llrp-inventory \ diff --git a/cmd/support-cron-scheduler/Dockerfile b/cmd/support-scheduler/Dockerfile similarity index 84% rename from cmd/support-cron-scheduler/Dockerfile rename to cmd/support-scheduler/Dockerfile index 6c44a1cdb3..f01945fea8 100644 --- a/cmd/support-cron-scheduler/Dockerfile +++ b/cmd/support-scheduler/Dockerfile @@ -28,7 +28,7 @@ COPY go.mod vendor* ./ RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..." COPY . . -RUN make cmd/support-cron-scheduler/support-cron-scheduler +RUN make cmd/support-scheduler/support-scheduler FROM alpine:3.20 @@ -40,13 +40,13 @@ LABEL license='SPDX-License-Identifier: Apache-2.0' \ copyright='Copyright (c) 2024: IOTech' ENV APP_PORT=59863 -#expose support cron scheduler port +#expose support scheduler port EXPOSE $APP_PORT COPY --from=builder /edgex-go/Attribution.txt / COPY --from=builder /edgex-go/security.txt / -COPY --from=builder /edgex-go/cmd/support-cron-scheduler/support-cron-scheduler / -COPY --from=builder /edgex-go/cmd/support-cron-scheduler/res /res +COPY --from=builder /edgex-go/cmd/support-scheduler/support-scheduler / +COPY --from=builder /edgex-go/cmd/support-scheduler/res /res -ENTRYPOINT ["/support-cron-scheduler"] +ENTRYPOINT ["/support-scheduler"] CMD ["-cp=keeper.http://edgex-core-keeper:59890", "--registry"] diff --git a/cmd/support-cron-scheduler/main.go b/cmd/support-scheduler/main.go similarity index 88% rename from cmd/support-cron-scheduler/main.go rename to cmd/support-scheduler/main.go index 80514db915..f1403db071 100644 --- a/cmd/support-cron-scheduler/main.go +++ b/cmd/support-scheduler/main.go @@ -17,12 +17,12 @@ package main import ( "context" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler" "github.com/labstack/echo/v4" ) func main() { ctx, cancel := context.WithCancel(context.Background()) - cronscheduler.Main(ctx, cancel, echo.New()) + scheduler.Main(ctx, cancel, echo.New()) } diff --git a/cmd/support-cron-scheduler/res/configuration.yaml b/cmd/support-scheduler/res/configuration.yaml similarity index 89% rename from cmd/support-cron-scheduler/res/configuration.yaml rename to cmd/support-scheduler/res/configuration.yaml index a9dbf4e5a4..4b54c061b2 100644 --- a/cmd/support-cron-scheduler/res/configuration.yaml +++ b/cmd/support-scheduler/res/configuration.yaml @@ -10,7 +10,7 @@ Writable: Service: Host: localhost Port: 59863 - StartupMsg: This is the Support Cron Scheduler Microservice + StartupMsg: This is the Support Scheduler Microservice Clients: core-command: @@ -23,7 +23,7 @@ Clients: MessageBus: Optional: - ClientId: support-cron-scheduler + ClientId: support-scheduler Retention: Enabled: true diff --git a/cmd/support-cron-scheduler/res/db/sql/00-utils.sql b/cmd/support-scheduler/res/db/sql/00-utils.sql similarity index 70% rename from cmd/support-cron-scheduler/res/db/sql/00-utils.sql rename to cmd/support-scheduler/res/db/sql/00-utils.sql index a76243fe1f..0d9b673a99 100644 --- a/cmd/support-cron-scheduler/res/db/sql/00-utils.sql +++ b/cmd/support-scheduler/res/db/sql/00-utils.sql @@ -4,4 +4,4 @@ -- SPDX-License-Identifier: Apache-2.0 -- schema for support_scheduler related tables -CREATE SCHEMA IF NOT EXISTS support_cron_scheduler; +CREATE SCHEMA IF NOT EXISTS support_scheduler; diff --git a/cmd/support-cron-scheduler/res/db/sql/01-tables.sql b/cmd/support-scheduler/res/db/sql/01-tables.sql similarity index 81% rename from cmd/support-cron-scheduler/res/db/sql/01-tables.sql rename to cmd/support-scheduler/res/db/sql/01-tables.sql index a7c0939f40..68ebeca582 100644 --- a/cmd/support-cron-scheduler/res/db/sql/01-tables.sql +++ b/cmd/support-scheduler/res/db/sql/01-tables.sql @@ -4,13 +4,13 @@ -- SPDX-License-Identifier: Apache-2.0 -- support_scheduler.job is used to store the schedule job information -CREATE TABLE IF NOT EXISTS support_cron_scheduler.job ( +CREATE TABLE IF NOT EXISTS support_scheduler.job ( id UUID PRIMARY KEY, content JSONB NOT NULL ); -- support_scheduler.record is used to store the schedule action record -CREATE TABLE IF NOT EXISTS support_cron_scheduler.record ( +CREATE TABLE IF NOT EXISTS support_scheduler.record ( id UUID PRIMARY KEY, action_id UUID NOT NULL, job_name TEXT NOT NULL, diff --git a/fuzz_test/Dockerfile.fuzz b/fuzz_test/Dockerfile.fuzz index bb0ca4e416..3d8997e498 100644 --- a/fuzz_test/Dockerfile.fuzz +++ b/fuzz_test/Dockerfile.fuzz @@ -39,7 +39,7 @@ ENTRYPOINT ["/restler-fuzzer/fuzzing.sh"] # This can take about 2 minutes to finish # You may swap out core-data to other server to perform fuzz-lean # docker run --net host --rm -v "$$PWD/fuzz_results:/fuzz_results" fuzz-edgex-go:latest core-data /restler-fuzzer/openapi/core-data.yaml" -# Example: CMD of "all" will do fuzz-lean test for core-commmand, core-data, core-metadata, support-notifications, and support-cron-scheduler, +# Example: CMD of "all" will do fuzz-lean test for core-commmand, core-data, core-metadata, support-notifications, and support-scheduler, # basically all services under openapi/v3/ directory # This can take more than 20 minutes to finish # docker run --net host --rm -v "$$PWD/fuzz_results:/fuzz_results" fuzz-edgex-go:latest all diff --git a/fuzz_test/fuzzing_docker.sh b/fuzz_test/fuzzing_docker.sh index 4d994107a6..fcd4c0bedd 100755 --- a/fuzz_test/fuzzing_docker.sh +++ b/fuzz_test/fuzzing_docker.sh @@ -26,7 +26,7 @@ usage() echo "Usage:" echo "./fuzzing_docker.sh " echo - echo " is required, options: all|core-data|core-command|core-metadata|support-notifications|support-cron-scheduler" + echo " is required, options: all|core-data|core-command|core-metadata|support-notifications|support-scheduler" echo " is required for NOT \"all\" EDGEX_PROJECT_NAME, it is the path and filename of a project swagger file" exit 1 } diff --git a/go.mod b/go.mod index 8e3f2912e4..e57a976b24 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,11 @@ go 1.23 require ( github.com/eclipse/paho.mqtt.golang v1.5.0 - github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.5 + github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.8 github.com/edgexfoundry/go-mod-configuration/v4 v4.0.0-dev.4 - github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.4 + github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.5 github.com/edgexfoundry/go-mod-messaging/v4 v4.0.0-dev.5 - github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.3 + github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.4 github.com/fxamacker/cbor/v2 v2.7.0 github.com/go-co-op/gocron/v2 v2.12.3 github.com/gomodule/redigo v1.9.2 @@ -90,11 +90,11 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openziti/channel/v3 v3.0.4 // indirect - github.com/openziti/edge-api v0.26.32 // indirect + github.com/openziti/edge-api v0.26.34 // indirect github.com/openziti/foundation/v2 v2.0.49 // indirect github.com/openziti/identity v1.0.85 // indirect github.com/openziti/metrics v1.2.58 // indirect - github.com/openziti/sdk-golang v0.23.43 // indirect + github.com/openziti/sdk-golang v0.23.44 // indirect github.com/openziti/secretstream v0.1.25 // indirect github.com/openziti/transport/v2 v2.0.146 // indirect github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect diff --git a/go.sum b/go.sum index 0e52c44327..757a07db5e 100644 --- a/go.sum +++ b/go.sum @@ -68,18 +68,18 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/eclipse/paho.mqtt.golang v1.5.0 h1:EH+bUVJNgttidWFkLLVKaQPGmkTUfQQqjOsyvMGvD6o= github.com/eclipse/paho.mqtt.golang v1.5.0/go.mod h1:du/2qNQVqJf/Sqs4MEL77kR8QTqANF7XU7Fk0aOTAgk= -github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.5 h1:PRVpZco9lmvyE8bhatgkygi1EeTSgQx84CuXmEEIp3A= -github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.5/go.mod h1:KuxKgNdhxsuReOv8xYXReCWxrwtmAJZjjVGPRTzsG6Y= +github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.8 h1:uFy9gOVPCLIyYcHcyP8dWBiGPKBvLS+PfaHK9ab/Z9s= +github.com/edgexfoundry/go-mod-bootstrap/v4 v4.0.0-dev.8/go.mod h1:IvrZ7zaD/0kvN+aAtqdudAPGOa4DprO4SDU3JQhVBUY= github.com/edgexfoundry/go-mod-configuration/v4 v4.0.0-dev.4 h1:Bw8Bxoc2LjAfkgWvAQtbeqnAaGPmKiCoAHlHGalhnv4= github.com/edgexfoundry/go-mod-configuration/v4 v4.0.0-dev.4/go.mod h1:Jc8kjQTAUYzuHbQzRuVzfPZy3QfJGMQ0rGHOhRit7to= -github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.4 h1:MrGBXxpgpL0TGMjXXh2E85pUwrUiqB/vgDq8SKztFrk= -github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.4/go.mod h1:I3EG+Tg/gcVSUJ+IJDuvVKFISnRu8oQtMXqltE1rzT8= +github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.5 h1:PHcgm730GAjl8hR5y25OE+YEe6urZhYIcIYGY7TeCWM= +github.com/edgexfoundry/go-mod-core-contracts/v4 v4.0.0-dev.5/go.mod h1:I3EG+Tg/gcVSUJ+IJDuvVKFISnRu8oQtMXqltE1rzT8= github.com/edgexfoundry/go-mod-messaging/v4 v4.0.0-dev.5 h1:DSk5kr4NZx+0Tbdb6vrnD2YNRX70nllgKceYCOTeSDo= github.com/edgexfoundry/go-mod-messaging/v4 v4.0.0-dev.5/go.mod h1:5RZ2zfycHLKjMDGD+uvGf+bazEs75EG/FM1RTvFG23M= github.com/edgexfoundry/go-mod-registry/v4 v4.0.0-dev.2 h1:iHu8JPpmrEOrIZdv0iYW69FlMmkyal/FpbXtC3pHt2c= github.com/edgexfoundry/go-mod-registry/v4 v4.0.0-dev.2/go.mod h1:0qsKMZkTP3jE0GisaNcMjn6euhAIVEFPy4WXbjgzgD0= -github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.3 h1:iMo7uwjAkFpYyLL9PXNbiGrtDunpXqE/mBalGlzECaY= -github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.3/go.mod h1:Xy9fwi+q7KkYsKehcDuxU2gvIVU4ZYljtqJVgq5/5Ho= +github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.4 h1:3YPeukLHkgDEG7dCWYosTNuqOoQHrVFVt65/LlG4LlQ= +github.com/edgexfoundry/go-mod-secrets/v4 v4.0.0-dev.4/go.mod h1:6P6KEOfPuzy8lXBkYCWTg7ZCHCJXL3ijYnkJQMEGvvc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -379,16 +379,16 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openziti/channel/v3 v3.0.4 h1:1A2HH9fVT5xq3G2Fy20L/5ZbpmFzbXfY7CEq6vQnbI0= github.com/openziti/channel/v3 v3.0.4/go.mod h1:MiVIlcPpcErv8E/TLDpxWNV1fGh8lb0g7qMlQGFYTec= -github.com/openziti/edge-api v0.26.32 h1:32oJI97cuM/kRJPEOwH2pe9dqwj56IYdQgTjTJaaHaU= -github.com/openziti/edge-api v0.26.32/go.mod h1:sYHVpm26Jr1u7VooNJzTb2b2nGSlmCHMnbGC8XfWSng= +github.com/openziti/edge-api v0.26.34 h1:73OcSpEeE2pdLKxPH2cGwDi8YcROWRGJfR+BAFRPGIE= +github.com/openziti/edge-api v0.26.34/go.mod h1:sYHVpm26Jr1u7VooNJzTb2b2nGSlmCHMnbGC8XfWSng= github.com/openziti/foundation/v2 v2.0.49 h1:aQ5I/lMhkHQ6urhRpLwrWP+7YtoeUitCfY/wub+nOqo= github.com/openziti/foundation/v2 v2.0.49/go.mod h1:tFk7wg5WE/nDDur5jSVQTROugKDXQkFvmqRSV4pvWp0= github.com/openziti/identity v1.0.85 h1:jphDHrUCXCJGdbVTMBqsdtS0Ei/vhDH337DMNMYzLro= github.com/openziti/identity v1.0.85/go.mod h1:beIXWNDImEjZn93XPOorJzyuQCQUYOvKFQ0fWhLN2qM= github.com/openziti/metrics v1.2.58 h1:AbHSTMKHP/o6r6fh7a08c486Y/5f5xjkZQbcyn3w1tM= github.com/openziti/metrics v1.2.58/go.mod h1:zGLMrLvVFOxo9tXUf8svcUsASxsPjhW9foW92FUzmDs= -github.com/openziti/sdk-golang v0.23.43 h1:n/Xaif9canea+T+VgNmfNhF2nNveXe4gdS35uUQgUIY= -github.com/openziti/sdk-golang v0.23.43/go.mod h1:6QsDMxGxX3Qsgpp4zVVHgBfr5XkXjIwRONS7onnaGvU= +github.com/openziti/sdk-golang v0.23.44 h1:TzRO8dz6aAO2g0IXsKC6PvmT+cYyJpw2oJRUqhnPeCA= +github.com/openziti/sdk-golang v0.23.44/go.mod h1:tJ8KXdqWRfAEekvbo/vJsN2PYydbPK/Gh2rAcc65+qE= github.com/openziti/secretstream v0.1.25 h1:40gHKcAcoXqKs0J7Tz1jTAmPoMXmMn4HP3Mg6scgJ5c= github.com/openziti/secretstream v0.1.25/go.mod h1:zgBcyN7h/zLBIWeqSrWwlOGOMQW51oQGYYlkiArR6Ec= github.com/openziti/transport/v2 v2.0.146 h1:Wdr4udri/fFpdj9GR9DR7/FKqt/2cMTgBdt3gfrqFaQ= diff --git a/internal/pkg/infrastructure/postgres/client_test.go b/internal/pkg/infrastructure/postgres/client_test.go index bc22df78d9..f001ac2e87 100644 --- a/internal/pkg/infrastructure/postgres/client_test.go +++ b/internal/pkg/infrastructure/postgres/client_test.go @@ -6,8 +6,8 @@ package postgres import ( - cronSchedulerInterfaces "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces" + schedulerInterfaces "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces" ) // Check the implementation of Postgres satisfies the DB client -var _ cronSchedulerInterfaces.DBClient = &Client{} +var _ schedulerInterfaces.DBClient = &Client{} diff --git a/internal/pkg/infrastructure/postgres/consts.go b/internal/pkg/infrastructure/postgres/consts.go index d930ee95f2..507793a53a 100644 --- a/internal/pkg/infrastructure/postgres/consts.go +++ b/internal/pkg/infrastructure/postgres/consts.go @@ -11,7 +11,7 @@ const ( coreKeeperSchema = "core_keeper" coreMetaDataSchema = "core_metadata" supportNotificationsSchema = "support_notifications" - supportSchedulerSchema = "support_cron_scheduler" + supportSchedulerSchema = "support_scheduler" ) // constants relate to the postgres db table names diff --git a/internal/pkg/infrastructure/redis/client.go b/internal/pkg/infrastructure/redis/client.go index b54ac0c232..d0ef28a7b9 100644 --- a/internal/pkg/infrastructure/redis/client.go +++ b/internal/pkg/infrastructure/redis/client.go @@ -988,180 +988,6 @@ func (c *Client) ProvisionWatcherCountByProfileName(name string) (uint32, errors return count, nil } -// AddInterval adds a new interval -func (c *Client) AddInterval(interval model.Interval) (model.Interval, errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - if len(interval.Id) == 0 { - interval.Id = uuid.New().String() - } - - return addInterval(conn, interval) -} - -// IntervalByName gets a interval by name -func (c *Client) IntervalByName(name string) (interval model.Interval, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - interval, edgeXerr = intervalByName(conn, name) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return -} - -// IntervalById gets a interval by id -func (c *Client) IntervalById(id string) (interval model.Interval, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - interval, edgeXerr = intervalById(conn, id) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return -} - -// AllIntervals query intervals with offset and limit -func (c *Client) AllIntervals(offset int, limit int) (intervals []model.Interval, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - intervals, edgeXerr = allIntervals(conn, offset, limit) - if edgeXerr != nil { - return intervals, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return intervals, nil -} - -// UpdateInterval updates a interval -func (c *Client) UpdateInterval(interval model.Interval) errors.EdgeX { - conn := c.Pool.Get() - defer conn.Close() - return updateInterval(conn, interval) -} - -// DeleteIntervalByName deletes the interval by name -func (c *Client) DeleteIntervalByName(name string) errors.EdgeX { - conn := c.Pool.Get() - defer conn.Close() - - edgeXerr := deleteIntervalByName(conn, name) - if edgeXerr != nil { - return errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to delete the interval with name %s", name), edgeXerr) - } - - return nil -} - -// IntervalTotalCount returns the total count of Interval from the database -func (c *Client) IntervalTotalCount() (uint32, errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - count, edgeXerr := getMemberNumber(conn, ZCARD, IntervalCollection) - if edgeXerr != nil { - return 0, errors.NewCommonEdgeXWrapper(edgeXerr) - } - - return count, nil -} - -// IntervalActionTotalCount returns the total count of IntervalAction from the database -func (c *Client) IntervalActionTotalCount() (uint32, errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - count, edgeXerr := getMemberNumber(conn, ZCARD, IntervalActionCollection) - if edgeXerr != nil { - return 0, errors.NewCommonEdgeXWrapper(edgeXerr) - } - - return count, nil -} - -// AddIntervalAction adds a new intervalAction -func (c *Client) AddIntervalAction(action model.IntervalAction) (model.IntervalAction, errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - if len(action.Id) == 0 { - action.Id = uuid.New().String() - } - return addIntervalAction(conn, action) -} - -// AllIntervalActions query intervalActions with offset and limit -func (c *Client) AllIntervalActions(offset int, limit int) (intervalActions []model.IntervalAction, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - intervalActions, edgeXerr = allIntervalActions(conn, offset, limit) - if edgeXerr != nil { - return intervalActions, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return intervalActions, nil -} - -// IntervalActionByName gets a intervalAction by name -func (c *Client) IntervalActionByName(name string) (action model.IntervalAction, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - action, edgeXerr = intervalActionByName(conn, name) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return -} - -// IntervalActionsByIntervalName query intervalActions by offset, limit and intervalName -func (c *Client) IntervalActionsByIntervalName(offset int, limit int, intervalName string) (actions []model.IntervalAction, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - actions, edgeXerr = intervalActionsByIntervalName(conn, offset, limit, intervalName) - if edgeXerr != nil { - return actions, errors.NewCommonEdgeX(errors.Kind(edgeXerr), - fmt.Sprintf("fail to query actions by offset %d, limit %d and intervalName %s", offset, limit, intervalName), edgeXerr) - } - return actions, nil -} - -// DeleteIntervalActionByName deletes the intervalAction by name -func (c *Client) DeleteIntervalActionByName(name string) errors.EdgeX { - conn := c.Pool.Get() - defer conn.Close() - - edgeXerr := deleteIntervalActionByName(conn, name) - if edgeXerr != nil { - return errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to delete the intervalAction with name %s", name), edgeXerr) - } - - return nil -} - -// IntervalActionById gets a intervalAction by id -func (c *Client) IntervalActionById(id string) (action model.IntervalAction, edgeXerr errors.EdgeX) { - conn := c.Pool.Get() - defer conn.Close() - - action, edgeXerr = intervalActionById(conn, id) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } - return -} - -// UpdateIntervalAction updates a intervalAction -func (c *Client) UpdateIntervalAction(action model.IntervalAction) errors.EdgeX { - conn := c.Pool.Get() - defer conn.Close() - return updateIntervalAction(conn, action) -} - // AddSubscription adds a new subscription func (c *Client) AddSubscription(subscription model.Subscription) (model.Subscription, errors.EdgeX) { conn := c.Pool.Get() diff --git a/internal/pkg/infrastructure/redis/interval.go b/internal/pkg/infrastructure/redis/interval.go deleted file mode 100644 index abfe6b3fd3..0000000000 --- a/internal/pkg/infrastructure/redis/interval.go +++ /dev/null @@ -1,183 +0,0 @@ -// -// Copyright (C) 2021 IOTech Ltd -// -// SPDX-License-Identifier: Apache-2.0 - -package redis - -import ( - "encoding/json" - "fmt" - - pkgCommon "github.com/edgexfoundry/edgex-go/internal/pkg/common" - - "github.com/edgexfoundry/go-mod-core-contracts/v4/common" - "github.com/edgexfoundry/go-mod-core-contracts/v4/errors" - "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - - "github.com/gomodule/redigo/redis" -) - -const ( - IntervalCollection = "ss|iv" - IntervalCollectionName = IntervalCollection + DBKeySeparator + common.Name -) - -// intervalStoredKey return the interval's stored key which combines the collection name and object id -func intervalStoredKey(id string) string { - return CreateKey(IntervalCollection, id) -} - -// sendAddIntervalCmd sends redis command for adding interval -func sendAddIntervalCmd(conn redis.Conn, storedKey string, interval models.Interval) errors.EdgeX { - m, err := json.Marshal(interval) - if err != nil { - return errors.NewCommonEdgeX(errors.KindContractInvalid, "unable to JSON marshal interval for Redis persistence", err) - } - _ = conn.Send(SET, storedKey, m) - _ = conn.Send(ZADD, IntervalCollection, interval.Modified, storedKey) - _ = conn.Send(HSET, IntervalCollectionName, interval.Name, storedKey) - return nil -} - -// addInterval adds a new interval into DB -func addInterval(conn redis.Conn, interval models.Interval) (models.Interval, errors.EdgeX) { - exists, edgeXerr := objectIdExists(conn, intervalStoredKey(interval.Id)) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeXWrapper(edgeXerr) - } else if exists { - return interval, errors.NewCommonEdgeX(errors.KindDuplicateName, fmt.Sprintf("interval id %s already exists", interval.Id), edgeXerr) - } - - exists, edgeXerr = intervalNameExists(conn, interval.Name) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeXWrapper(edgeXerr) - } else if exists { - return interval, errors.NewCommonEdgeX(errors.KindDuplicateName, fmt.Sprintf("interval name %s already exists", interval.Name), edgeXerr) - } - - ts := pkgCommon.MakeTimestamp() - if interval.Created == 0 { - interval.Created = ts - } - interval.Modified = ts - - storedKey := intervalStoredKey(interval.Id) - _ = conn.Send(MULTI) - edgeXerr = sendAddIntervalCmd(conn, storedKey, interval) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeXWrapper(edgeXerr) - } - _, err := conn.Do(EXEC) - if err != nil { - edgeXerr = errors.NewCommonEdgeX(errors.KindDatabaseError, "interval creation failed", err) - } - - return interval, edgeXerr -} - -// intervalByName query interval by name from DB -func intervalByName(conn redis.Conn, name string) (interval models.Interval, edgeXerr errors.EdgeX) { - edgeXerr = getObjectByHash(conn, IntervalCollectionName, name, &interval) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to query interval by name %s", name), edgeXerr) - } - return -} - -// intervalById query interval by id from DB -func intervalById(conn redis.Conn, id string) (interval models.Interval, edgeXerr errors.EdgeX) { - edgeXerr = getObjectById(conn, intervalStoredKey(id), &interval) - if edgeXerr != nil { - return interval, errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to query interval by id %s", id), edgeXerr) - } - return -} - -// allIntervals queries intervals by offset and limit -func allIntervals(conn redis.Conn, offset, limit int) (intervals []models.Interval, edgeXerr errors.EdgeX) { - objects, edgeXerr := getObjectsByRevRange(conn, IntervalCollection, offset, limit) - if edgeXerr != nil { - return intervals, errors.NewCommonEdgeXWrapper(edgeXerr) - } - - intervals = make([]models.Interval, len(objects)) - for i, o := range objects { - s := models.Interval{} - err := json.Unmarshal(o, &s) - if err != nil { - return []models.Interval{}, errors.NewCommonEdgeX(errors.KindDatabaseError, "interval format parsing failed from the database", err) - } - intervals[i] = s - } - return intervals, nil -} - -// sendDeleteIntervalCmd sends redis command for deleting interval -func sendDeleteIntervalCmd(conn redis.Conn, storedKey string, interval models.Interval) { - _ = conn.Send(DEL, storedKey) - _ = conn.Send(ZREM, IntervalCollection, storedKey) - _ = conn.Send(HDEL, IntervalCollectionName, interval.Name) -} - -// deleteIntervalByName deletes the interval by name -func deleteIntervalByName(conn redis.Conn, name string) errors.EdgeX { - interval, edgeXerr := intervalByName(conn, name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - actions, edgeXerr := intervalActionsByIntervalName(conn, 0, 1, name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - if len(actions) > 0 { - return errors.NewCommonEdgeX(errors.KindStatusConflict, "fail to delete the interval when associated intervalAction exists", nil) - } - storedKey := intervalStoredKey(interval.Id) - _ = conn.Send(MULTI) - sendDeleteIntervalCmd(conn, storedKey, interval) - _, err := conn.Do(EXEC) - if err != nil { - return errors.NewCommonEdgeX(errors.KindDatabaseError, "interval deletion failed", err) - } - return nil -} - -// updateInterval updates a interval -func updateInterval(conn redis.Conn, interval models.Interval) errors.EdgeX { - oldInterval, edgeXerr := intervalByName(conn, interval.Name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - actions, edgeXerr := intervalActionsByIntervalName(conn, 0, 1, interval.Name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - if len(actions) > 0 { - return errors.NewCommonEdgeX(errors.KindStatusConflict, "fail to patch the interval when associated intervalAction exists", nil) - } - - interval.Modified = pkgCommon.MakeTimestamp() - storedKey := intervalStoredKey(interval.Id) - _ = conn.Send(MULTI) - sendDeleteIntervalCmd(conn, storedKey, oldInterval) - edgeXerr = sendAddIntervalCmd(conn, storedKey, interval) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - _, err := conn.Do(EXEC) - if err != nil { - return errors.NewCommonEdgeX(errors.KindDatabaseError, "interval update failed", err) - } - - return nil -} - -// intervalNameExists whether the interval exists by name -func intervalNameExists(conn redis.Conn, name string) (bool, errors.EdgeX) { - exists, err := objectNameExists(conn, IntervalCollectionName, name) - if err != nil { - return false, errors.NewCommonEdgeXWrapper(err) - } - return exists, nil -} diff --git a/internal/pkg/infrastructure/redis/intervalaction.go b/internal/pkg/infrastructure/redis/intervalaction.go deleted file mode 100644 index 1f294f3969..0000000000 --- a/internal/pkg/infrastructure/redis/intervalaction.go +++ /dev/null @@ -1,193 +0,0 @@ -// -// Copyright (C) 2021 IOTech Ltd -// -// SPDX-License-Identifier: Apache-2.0 - -package redis - -import ( - "encoding/json" - "fmt" - - pkgCommon "github.com/edgexfoundry/edgex-go/internal/pkg/common" - "github.com/edgexfoundry/go-mod-core-contracts/v4/common" - "github.com/edgexfoundry/go-mod-core-contracts/v4/errors" - "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - - "github.com/gomodule/redigo/redis" -) - -const ( - IntervalActionCollection = "ss|ia" - IntervalActionCollectionName = IntervalActionCollection + DBKeySeparator + common.Name - IntervalActionCollectionIntervalName = IntervalActionCollection + DBKeySeparator + common.Interval + DBKeySeparator + common.Name -) - -// intervalActionStoredKey return the intervalAction's stored key which combines the collection name and object id -func intervalActionStoredKey(id string) string { - return CreateKey(IntervalActionCollection, id) -} - -// sendAddIntervalActionCmd sends redis command for adding intervalAction -func sendAddIntervalActionCmd(conn redis.Conn, storedKey string, action models.IntervalAction) errors.EdgeX { - m, err := json.Marshal(action) - if err != nil { - return errors.NewCommonEdgeX(errors.KindContractInvalid, "unable to JSON marshal intervalAction for Redis persistence", err) - } - _ = conn.Send(SET, storedKey, m) - _ = conn.Send(ZADD, IntervalActionCollection, action.Modified, storedKey) - _ = conn.Send(HSET, IntervalActionCollectionName, action.Name, storedKey) - _ = conn.Send(ZADD, CreateKey(IntervalActionCollectionIntervalName, action.IntervalName), action.Modified, storedKey) - return nil -} - -// addIntervalAction adds a new intervalAction into DB -func addIntervalAction(conn redis.Conn, action models.IntervalAction) (models.IntervalAction, errors.EdgeX) { - exists, edgeXerr := intervalNameExists(conn, action.IntervalName) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } else if !exists { - return action, errors.NewCommonEdgeX(errors.KindEntityDoesNotExist, fmt.Sprintf("interval '%s' does not exists", action.IntervalName), nil) - } - - exists, edgeXerr = objectIdExists(conn, intervalActionStoredKey(action.Id)) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } else if exists { - return action, errors.NewCommonEdgeX(errors.KindDuplicateName, fmt.Sprintf("intervalAction id %s already exists", action.Id), edgeXerr) - } - - exists, edgeXerr = objectNameExists(conn, IntervalActionCollectionName, action.Name) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } else if exists { - return action, errors.NewCommonEdgeX(errors.KindDuplicateName, fmt.Sprintf("intervalAction name %s already exists", action.Name), edgeXerr) - } - - ts := pkgCommon.MakeTimestamp() - if action.Created == 0 { - action.Created = ts - } - action.Modified = ts - - storedKey := intervalActionStoredKey(action.Id) - _ = conn.Send(MULTI) - edgeXerr = sendAddIntervalActionCmd(conn, storedKey, action) - if edgeXerr != nil { - return action, errors.NewCommonEdgeXWrapper(edgeXerr) - } - _, err := conn.Do(EXEC) - if err != nil { - edgeXerr = errors.NewCommonEdgeX(errors.KindDatabaseError, "intervalAction creation failed", err) - } - - return action, edgeXerr -} - -// allIntervalActions queries intervalActions by offset and limit -func allIntervalActions(conn redis.Conn, offset, limit int) (intervalActions []models.IntervalAction, edgeXerr errors.EdgeX) { - objects, edgeXerr := getObjectsByRevRange(conn, IntervalActionCollection, offset, limit) - if edgeXerr != nil { - return intervalActions, errors.NewCommonEdgeXWrapper(edgeXerr) - } - - intervalActions = make([]models.IntervalAction, len(objects)) - for i, o := range objects { - action := models.IntervalAction{} - err := json.Unmarshal(o, &action) - if err != nil { - return []models.IntervalAction{}, errors.NewCommonEdgeX(errors.KindDatabaseError, "intervalAction format parsing failed from the database", err) - } - intervalActions[i] = action - } - return intervalActions, nil -} - -// intervalActionByName query intervalAction by name from DB -func intervalActionByName(conn redis.Conn, name string) (action models.IntervalAction, edgeXerr errors.EdgeX) { - edgeXerr = getObjectByHash(conn, IntervalActionCollectionName, name, &action) - if edgeXerr != nil { - return action, errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to query intervalAction by name %s", name), edgeXerr) - } - return -} - -// sendDeleteIntervalActionCmd sends redis command for deleting intervalAction -func sendDeleteIntervalActionCmd(conn redis.Conn, storedKey string, action models.IntervalAction) { - _ = conn.Send(DEL, storedKey) - _ = conn.Send(ZREM, IntervalActionCollection, storedKey) - _ = conn.Send(HDEL, IntervalActionCollectionName, action.Name) - _ = conn.Send(ZREM, CreateKey(IntervalActionCollectionIntervalName, action.IntervalName), storedKey) -} - -// deleteIntervalActionByName deletes the intervalAction by name -func deleteIntervalActionByName(conn redis.Conn, name string) errors.EdgeX { - action, edgeXerr := intervalActionByName(conn, name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - storedKey := intervalActionStoredKey(action.Id) - _ = conn.Send(MULTI) - sendDeleteIntervalActionCmd(conn, storedKey, action) - _, err := conn.Do(EXEC) - if err != nil { - return errors.NewCommonEdgeX(errors.KindDatabaseError, "intervalAction deletion failed", err) - } - return nil -} - -// intervalActionById query intervalAction by id from DB -func intervalActionById(conn redis.Conn, id string) (action models.IntervalAction, edgeXerr errors.EdgeX) { - edgeXerr = getObjectById(conn, intervalActionStoredKey(id), &action) - if edgeXerr != nil { - return action, errors.NewCommonEdgeX(errors.Kind(edgeXerr), fmt.Sprintf("fail to query intervalAction by id %s", id), edgeXerr) - } - return -} - -// updateIntervalAction updates an intervalAction -func updateIntervalAction(conn redis.Conn, action models.IntervalAction) errors.EdgeX { - exists, edgeXerr := intervalNameExists(conn, action.IntervalName) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } else if !exists { - return errors.NewCommonEdgeX(errors.KindEntityDoesNotExist, fmt.Sprintf("interval '%s' does not exists", action.IntervalName), nil) - } - oldAction, edgeXerr := intervalActionByName(conn, action.Name) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - action.Modified = pkgCommon.MakeTimestamp() - storedKey := intervalActionStoredKey(action.Id) - - _ = conn.Send(MULTI) - sendDeleteIntervalActionCmd(conn, storedKey, oldAction) - edgeXerr = sendAddIntervalActionCmd(conn, storedKey, action) - if edgeXerr != nil { - return errors.NewCommonEdgeXWrapper(edgeXerr) - } - _, err := conn.Do(EXEC) - if err != nil { - return errors.NewCommonEdgeX(errors.KindDatabaseError, "intervalAction update failed", err) - } - return nil -} - -// intervalActionsByIntervalName query actions by offset, limit and intervalName -func intervalActionsByIntervalName(conn redis.Conn, offset int, limit int, intervalName string) (actions []models.IntervalAction, edgeXerr errors.EdgeX) { - objects, err := getObjectsByRevRange(conn, CreateKey(IntervalActionCollectionIntervalName, intervalName), offset, limit) - if err != nil { - return actions, errors.NewCommonEdgeXWrapper(err) - } - - actions = make([]models.IntervalAction, len(objects)) - for i, in := range objects { - action := models.IntervalAction{} - err := json.Unmarshal(in, &action) - if err != nil { - return actions, errors.NewCommonEdgeX(errors.KindDatabaseError, "intervalAction format parsing failed from the database", err) - } - actions[i] = action - } - return actions, nil -} diff --git a/internal/support/cronscheduler/application/action/devicecontrol.go b/internal/support/scheduler/application/action/devicecontrol.go similarity index 100% rename from internal/support/cronscheduler/application/action/devicecontrol.go rename to internal/support/scheduler/application/action/devicecontrol.go diff --git a/internal/support/cronscheduler/application/action/edgexmessagebus.go b/internal/support/scheduler/application/action/edgexmessagebus.go similarity index 100% rename from internal/support/cronscheduler/application/action/edgexmessagebus.go rename to internal/support/scheduler/application/action/edgexmessagebus.go diff --git a/internal/support/cronscheduler/application/action/gocron.go b/internal/support/scheduler/application/action/gocron.go similarity index 100% rename from internal/support/cronscheduler/application/action/gocron.go rename to internal/support/scheduler/application/action/gocron.go diff --git a/internal/support/cronscheduler/application/action/rest.go b/internal/support/scheduler/application/action/rest.go similarity index 100% rename from internal/support/cronscheduler/application/action/rest.go rename to internal/support/scheduler/application/action/rest.go diff --git a/internal/support/cronscheduler/application/scheduleactionrecord.go b/internal/support/scheduler/application/scheduleactionrecord.go similarity index 99% rename from internal/support/cronscheduler/application/scheduleactionrecord.go rename to internal/support/scheduler/application/scheduleactionrecord.go index 89f4ca5653..96ddb5d140 100644 --- a/internal/support/cronscheduler/application/scheduleactionrecord.go +++ b/internal/support/scheduler/application/scheduleactionrecord.go @@ -23,7 +23,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/pkg/correlation" "github.com/edgexfoundry/edgex-go/internal/pkg/utils" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) var asyncPurgeRecordOnce sync.Once diff --git a/internal/support/cronscheduler/application/scheduleactionrecord_test.go b/internal/support/scheduler/application/scheduleactionrecord_test.go similarity index 94% rename from internal/support/cronscheduler/application/scheduleactionrecord_test.go rename to internal/support/scheduler/application/scheduleactionrecord_test.go index 896b2a3f63..ddc6ec4f80 100644 --- a/internal/support/cronscheduler/application/scheduleactionrecord_test.go +++ b/internal/support/scheduler/application/scheduleactionrecord_test.go @@ -20,9 +20,9 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/clients/logger" "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - dbMock "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces/mocks" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + dbMock "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces/mocks" ) var ( diff --git a/internal/support/cronscheduler/application/schedulejob.go b/internal/support/scheduler/application/schedulejob.go similarity index 98% rename from internal/support/cronscheduler/application/schedulejob.go rename to internal/support/scheduler/application/schedulejob.go index a90eb2927c..9d1c3948e2 100644 --- a/internal/support/cronscheduler/application/schedulejob.go +++ b/internal/support/scheduler/application/schedulejob.go @@ -19,8 +19,8 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/models" "github.com/edgexfoundry/edgex-go/internal/pkg/correlation" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces" ) // AddScheduleJob adds a new schedule job diff --git a/internal/support/cronscheduler/config/config.go b/internal/support/scheduler/config/config.go similarity index 99% rename from internal/support/cronscheduler/config/config.go rename to internal/support/scheduler/config/config.go index 27c4dae0bc..7b0cd06774 100644 --- a/internal/support/cronscheduler/config/config.go +++ b/internal/support/scheduler/config/config.go @@ -9,7 +9,7 @@ import ( bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/v4/config" ) -// ConfigurationStruct contains the configuration properties for the Support Cron Scheduler Service +// ConfigurationStruct contains the configuration properties for the Support Scheduler Service type ConfigurationStruct struct { Writable WritableInfo Database bootstrapConfig.Database diff --git a/internal/support/cronscheduler/container/config.go b/internal/support/scheduler/container/config.go similarity index 88% rename from internal/support/cronscheduler/container/config.go rename to internal/support/scheduler/container/config.go index c8062cc7b3..527d80faeb 100644 --- a/internal/support/cronscheduler/container/config.go +++ b/internal/support/scheduler/container/config.go @@ -8,7 +8,7 @@ package container import ( "github.com/edgexfoundry/go-mod-bootstrap/v4/di" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" ) // ConfigurationName contains the name of scheduler's config.ConfigurationStruct implementation in the DIC. diff --git a/internal/support/cronscheduler/container/database.go b/internal/support/scheduler/container/database.go similarity index 85% rename from internal/support/cronscheduler/container/database.go rename to internal/support/scheduler/container/database.go index 21eb8eb333..884caeb07a 100644 --- a/internal/support/cronscheduler/container/database.go +++ b/internal/support/scheduler/container/database.go @@ -6,7 +6,7 @@ package container import ( - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces" "github.com/edgexfoundry/go-mod-bootstrap/v4/di" ) diff --git a/internal/support/cronscheduler/container/scheduler.go b/internal/support/scheduler/container/scheduler.go similarity index 86% rename from internal/support/cronscheduler/container/scheduler.go rename to internal/support/scheduler/container/scheduler.go index 3f6ecfb370..3f790d66f4 100644 --- a/internal/support/cronscheduler/container/scheduler.go +++ b/internal/support/scheduler/container/scheduler.go @@ -8,7 +8,7 @@ package container import ( "github.com/edgexfoundry/go-mod-bootstrap/v4/di" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces" ) // SchedulerManagerName contains the name of the interfaces.SchedulerManager implementation in the DIC. diff --git a/internal/support/cronscheduler/controller/http/scheduleactionrecord.go b/internal/support/scheduler/controller/http/scheduleactionrecord.go similarity index 98% rename from internal/support/cronscheduler/controller/http/scheduleactionrecord.go rename to internal/support/scheduler/controller/http/scheduleactionrecord.go index c85743e60a..baea935109 100644 --- a/internal/support/cronscheduler/controller/http/scheduleactionrecord.go +++ b/internal/support/scheduler/controller/http/scheduleactionrecord.go @@ -19,8 +19,8 @@ import ( "github.com/edgexfoundry/edgex-go/internal/io" "github.com/edgexfoundry/edgex-go/internal/pkg" "github.com/edgexfoundry/edgex-go/internal/pkg/utils" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/application" - schedulerContainer "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/application" + schedulerContainer "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) type ScheduleActionRecordController struct { diff --git a/internal/support/cronscheduler/controller/http/scheduleactionrecord_test.go b/internal/support/scheduler/controller/http/scheduleactionrecord_test.go similarity index 99% rename from internal/support/cronscheduler/controller/http/scheduleactionrecord_test.go rename to internal/support/scheduler/controller/http/scheduleactionrecord_test.go index 657ab53438..9c99b49be0 100644 --- a/internal/support/cronscheduler/controller/http/scheduleactionrecord_test.go +++ b/internal/support/scheduler/controller/http/scheduleactionrecord_test.go @@ -26,8 +26,8 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/errors" "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - csMock "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces/mocks" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + csMock "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces/mocks" ) func scheduleActionRecordsData() []dtos.ScheduleActionRecord { diff --git a/internal/support/cronscheduler/controller/http/schedulejob.go b/internal/support/scheduler/controller/http/schedulejob.go similarity index 98% rename from internal/support/cronscheduler/controller/http/schedulejob.go rename to internal/support/scheduler/controller/http/schedulejob.go index bc9e280533..84ebcb19ee 100644 --- a/internal/support/cronscheduler/controller/http/schedulejob.go +++ b/internal/support/scheduler/controller/http/schedulejob.go @@ -24,8 +24,8 @@ import ( "github.com/edgexfoundry/edgex-go/internal/pkg" "github.com/edgexfoundry/edgex-go/internal/pkg/correlation" "github.com/edgexfoundry/edgex-go/internal/pkg/utils" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/application" - schedulerContainer "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/application" + schedulerContainer "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) type ScheduleJobController struct { diff --git a/internal/support/cronscheduler/controller/http/schedulejob_test.go b/internal/support/scheduler/controller/http/schedulejob_test.go similarity index 98% rename from internal/support/cronscheduler/controller/http/schedulejob_test.go rename to internal/support/scheduler/controller/http/schedulejob_test.go index 8270f0c9b0..f0cb9378a0 100644 --- a/internal/support/cronscheduler/controller/http/schedulejob_test.go +++ b/internal/support/scheduler/controller/http/schedulejob_test.go @@ -31,9 +31,9 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/errors" "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - csMock "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces/mocks" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + csMock "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces/mocks" ) func mockDic() *di.Container { diff --git a/internal/support/cronscheduler/controller/http/utils_test.go b/internal/support/scheduler/controller/http/utils_test.go similarity index 100% rename from internal/support/cronscheduler/controller/http/utils_test.go rename to internal/support/scheduler/controller/http/utils_test.go diff --git a/internal/support/cronscheduler/infrastructure/interfaces/SchedulerManager.go b/internal/support/scheduler/infrastructure/interfaces/SchedulerManager.go similarity index 100% rename from internal/support/cronscheduler/infrastructure/interfaces/SchedulerManager.go rename to internal/support/scheduler/infrastructure/interfaces/SchedulerManager.go diff --git a/internal/support/cronscheduler/infrastructure/interfaces/db.go b/internal/support/scheduler/infrastructure/interfaces/db.go similarity index 100% rename from internal/support/cronscheduler/infrastructure/interfaces/db.go rename to internal/support/scheduler/infrastructure/interfaces/db.go diff --git a/internal/support/cronscheduler/infrastructure/interfaces/mocks/DBClient.go b/internal/support/scheduler/infrastructure/interfaces/mocks/DBClient.go similarity index 100% rename from internal/support/cronscheduler/infrastructure/interfaces/mocks/DBClient.go rename to internal/support/scheduler/infrastructure/interfaces/mocks/DBClient.go diff --git a/internal/support/cronscheduler/infrastructure/interfaces/mocks/SchedulerManager.go b/internal/support/scheduler/infrastructure/interfaces/mocks/SchedulerManager.go similarity index 100% rename from internal/support/cronscheduler/infrastructure/interfaces/mocks/SchedulerManager.go rename to internal/support/scheduler/infrastructure/interfaces/mocks/SchedulerManager.go diff --git a/internal/support/cronscheduler/infrastructure/manager.go b/internal/support/scheduler/infrastructure/manager.go similarity index 97% rename from internal/support/cronscheduler/infrastructure/manager.go rename to internal/support/scheduler/infrastructure/manager.go index c40cfce1ec..0081666e3e 100644 --- a/internal/support/cronscheduler/infrastructure/manager.go +++ b/internal/support/scheduler/infrastructure/manager.go @@ -22,10 +22,10 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/models" "github.com/edgexfoundry/edgex-go/internal/pkg/correlation" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/application/action" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure/interfaces" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/application/action" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure/interfaces" ) const ( diff --git a/internal/support/cronscheduler/infrastructure/manager_test.go b/internal/support/scheduler/infrastructure/manager_test.go similarity index 97% rename from internal/support/cronscheduler/infrastructure/manager_test.go rename to internal/support/scheduler/infrastructure/manager_test.go index 1f725f037c..2a161a5ef5 100644 --- a/internal/support/cronscheduler/infrastructure/manager_test.go +++ b/internal/support/scheduler/infrastructure/manager_test.go @@ -16,8 +16,8 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/common" "github.com/edgexfoundry/go-mod-core-contracts/v4/models" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) const ( diff --git a/internal/support/cronscheduler/init.go b/internal/support/scheduler/init.go similarity index 88% rename from internal/support/cronscheduler/init.go rename to internal/support/scheduler/init.go index b700e01ee3..1840a50725 100644 --- a/internal/support/cronscheduler/init.go +++ b/internal/support/scheduler/init.go @@ -12,7 +12,7 @@ * the License. *******************************************************************************/ -package cronscheduler +package scheduler import ( "context" @@ -25,9 +25,9 @@ import ( "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/startup" "github.com/edgexfoundry/go-mod-bootstrap/v4/di" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/application" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/infrastructure" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/application" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/infrastructure" ) // Bootstrap contains references to dependencies required by the BootstrapHandler. @@ -44,7 +44,7 @@ func NewBootstrap(router *echo.Echo, serviceName string) *Bootstrap { } } -// BootstrapHandler fulfills the BootstrapHandler contract and performs initialization needed by the cronscheduler service. +// BootstrapHandler fulfills the BootstrapHandler contract and performs initialization needed by the scheduler service. func (b *Bootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, _ startup.Timer, dic *di.Container) bool { LoadRestRoutes(b.router, dic, b.serviceName) diff --git a/internal/support/cronscheduler/main.go b/internal/support/scheduler/main.go similarity index 80% rename from internal/support/cronscheduler/main.go rename to internal/support/scheduler/main.go index b41f96c384..21200bbb1e 100644 --- a/internal/support/cronscheduler/main.go +++ b/internal/support/scheduler/main.go @@ -12,7 +12,7 @@ * the License. *******************************************************************************/ -package cronscheduler +package scheduler import ( "context" @@ -31,12 +31,12 @@ import ( "github.com/edgexfoundry/edgex-go" pkgHandlers "github.com/edgexfoundry/edgex-go/internal/pkg/bootstrap/handlers" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/config" - "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/container" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/config" + "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { - startupTimer := startup.NewStartUpTimer(common.SupportCronSchedulerServiceKey) + startupTimer := startup.NewStartUpTimer(common.SupportSchedulerServiceKey) // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, // by inserting service specific flag prior to call to commonFlags.Parse(). @@ -55,13 +55,13 @@ func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { }, }) - httpServer := handlers.NewHttpServer(router, true, common.SupportCronSchedulerServiceKey) + httpServer := handlers.NewHttpServer(router, true, common.SupportSchedulerServiceKey) bootstrap.Run( ctx, cancel, f, - common.SupportCronSchedulerServiceKey, + common.SupportSchedulerServiceKey, common.ConfigStemCore, configuration, startupTimer, @@ -72,9 +72,9 @@ func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { pkgHandlers.NewDatabase(httpServer, configuration, container.DBClientInterfaceName).BootstrapHandler, // add db client bootstrap handler handlers.NewClientsBootstrap().BootstrapHandler, handlers.MessagingBootstrapHandler, - handlers.NewServiceMetrics(common.SupportCronSchedulerServiceKey).BootstrapHandler, // Must be after Messaging - NewBootstrap(router, common.SupportCronSchedulerServiceKey).BootstrapHandler, + handlers.NewServiceMetrics(common.SupportSchedulerServiceKey).BootstrapHandler, // Must be after Messaging + NewBootstrap(router, common.SupportSchedulerServiceKey).BootstrapHandler, httpServer.BootstrapHandler, - handlers.NewStartMessage(common.SupportCronSchedulerServiceKey, edgex.Version).BootstrapHandler, + handlers.NewStartMessage(common.SupportSchedulerServiceKey, edgex.Version).BootstrapHandler, }) } diff --git a/internal/support/cronscheduler/router.go b/internal/support/scheduler/router.go similarity index 97% rename from internal/support/cronscheduler/router.go rename to internal/support/scheduler/router.go index 0e315d4a5b..e5eefe0bea 100644 --- a/internal/support/cronscheduler/router.go +++ b/internal/support/scheduler/router.go @@ -3,7 +3,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package cronscheduler +package scheduler import ( "github.com/labstack/echo/v4" @@ -15,7 +15,7 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/common" "github.com/edgexfoundry/edgex-go" - schedulerController "github.com/edgexfoundry/edgex-go/internal/support/cronscheduler/controller/http" + schedulerController "github.com/edgexfoundry/edgex-go/internal/support/scheduler/controller/http" ) func LoadRestRoutes(r *echo.Echo, dic *di.Container, serviceName string) { diff --git a/openapi/support-cron-scheduler.yaml b/openapi/support-scheduler.yaml similarity index 99% rename from openapi/support-cron-scheduler.yaml rename to openapi/support-scheduler.yaml index b87b151617..0941552fde 100644 --- a/openapi/support-cron-scheduler.yaml +++ b/openapi/support-scheduler.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: - title: Edgex Foundry - Support Cron Scheduler API - description: This is the definition of the API for the Support Cron Scheduler service in the EdgeX Foundry IOT microservice platform. Support Cron Scheduler provides functionality for scheduling different actions in the EdgeX Foundry platform. + title: Edgex Foundry - Support Scheduler API + description: This is the definition of the API for the Support Scheduler service in the EdgeX Foundry IOT microservice platform. Support Scheduler provides functionality for scheduling different actions in the EdgeX Foundry platform. version: 4.0.0 servers: @@ -77,7 +77,7 @@ components: serviceName: description: "Outputs the name of the service the response is from" type: string - example: "support-cron-scheduler" + example: "support-scheduler" config: description: "A string-ified representation of the service's configuration. For purposes of this specification, a string has been used since configuration structure differs from service to service." type: object @@ -1315,7 +1315,7 @@ paths: example: apiVersion: "v3" timestamp: "Mon, 02 Jan 2006 15:04:05 MST" - serviceName: "support-cron-scheduler" + serviceName: "support-scheduler" '500': description: "Internal Server Error" headers: @@ -1344,7 +1344,7 @@ paths: example: apiVersion: "v3" version: 4.0.0 - serviceName: "support-cron-scheduler" + serviceName: "support-scheduler" '500': description: "Internal Server Error" headers: