From 7c9e3fa2fa1d73415f54b937be0e16034a1d35ff Mon Sep 17 00:00:00 2001 From: Yevgeny Khessin Date: Wed, 1 May 2024 11:56:28 -0400 Subject: [PATCH 1/4] Removing update task --- cmd/devices-api/api.go | 3 - docs/docs.go | 33 ----- docs/swagger.json | 33 ----- docs/swagger.yaml | 21 ---- .../user_integrations_controller.go | 44 ------- internal/services/autopi_task_service.go | 118 ------------------ 6 files changed, 252 deletions(-) diff --git a/cmd/devices-api/api.go b/cmd/devices-api/api.go index 800ed7873..23bf1b6dd 100644 --- a/cmd/devices-api/api.go +++ b/cmd/devices-api/api.go @@ -232,9 +232,6 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, apOwner.Get("/", userDeviceController.GetAftermarketDeviceInfo) amdOwner.Get("/", userDeviceController.GetAftermarketDeviceInfo) - apOwner.Post("/update", userDeviceController.StartAutoPiUpdateTask) - amdOwner.Post("/update", userDeviceController.StartAutoPiUpdateTask) - // AftermarketDevice claiming, formerly AutoPi apOwner.Get("/commands/claim", userDeviceController.GetAftermarketDeviceClaimMessage) amdOwner.Get("/commands/claim", userDeviceController.GetAftermarketDeviceClaimMessage) diff --git a/docs/docs.go b/docs/docs.go index 4f39b82eb..1f0bf147f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -170,39 +170,6 @@ const docTemplate = `{ } } }, - "/aftermarket/device/by-serial/{serial}/update": { - "post": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "checks to see if aftermarket device needs to be updated, and starts update process if so.", - "produces": [ - "application/json" - ], - "tags": [ - "integrations" - ], - "parameters": [ - { - "type": "string", - "description": "autopi unit id", - "name": "serial", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask" - } - } - } - } - }, "/aftermarket/device/{tokenId}": { "get": { "description": "Retrieves NFT metadata for a given aftermarket device.", diff --git a/docs/swagger.json b/docs/swagger.json index bd1e2d9b7..2998e1f5e 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -162,39 +162,6 @@ } } }, - "/aftermarket/device/by-serial/{serial}/update": { - "post": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "checks to see if aftermarket device needs to be updated, and starts update process if so.", - "produces": [ - "application/json" - ], - "tags": [ - "integrations" - ], - "parameters": [ - { - "type": "string", - "description": "autopi unit id", - "name": "serial", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask" - } - } - } - } - }, "/aftermarket/device/{tokenId}": { "get": { "description": "Retrieves NFT metadata for a given aftermarket device.", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 6f2a6ecdd..927f28c29 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1071,27 +1071,6 @@ paths: description: No Content security: - BearerAuth: [] - /aftermarket/device/by-serial/{serial}/update: - post: - description: checks to see if aftermarket device needs to be updated, and starts - update process if so. - parameters: - - description: autopi unit id - in: path - name: serial - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask' - security: - - BearerAuth: [] - tags: - - integrations /countries: get: description: Returns all the supported countries diff --git a/internal/controllers/user_integrations_controller.go b/internal/controllers/user_integrations_controller.go index df72e60d2..c0c97f723 100644 --- a/internal/controllers/user_integrations_controller.go +++ b/internal/controllers/user_integrations_controller.go @@ -595,50 +595,6 @@ func (udc *UserDevicesController) GetAftermarketDeviceInfo(c *fiber.Ctx) error { return c.JSON(adi) } -// StartAutoPiUpdateTask godoc -// @Description checks to see if aftermarket device needs to be updated, and starts update process if so. -// @Tags integrations -// @Produce json -// @Param serial path string true "autopi unit id", ie. physical barcode -// @Success 200 {object} services.AutoPiTask -// @Security BearerAuth -// @Router /aftermarket/device/by-serial/{serial}/update [post] -func (udc *UserDevicesController) StartAutoPiUpdateTask(c *fiber.Ctx) error { - unitID := c.Locals("serial").(string) - userID := helpers.GetUserID(c) - - // check if device already updated - unit, err := udc.autoPiSvc.GetDeviceByUnitID(unitID) - if err != nil { - if errors.Is(err, services.ErrNotFound) { - return fiber.NewError(fiber.StatusNotFound, "Device not found.") - } - return err - } - - if unit.IsUpdated { - return c.JSON(services.AutoPiTask{ - TaskID: "0", - Status: string(services.Success), - Description: "autopi device is already up to date running version " + unit.Release.Version, - Code: 200, - }) - } - - // fire off task - taskID, err := udc.autoPiTaskService.StartAutoPiUpdate(unit.ID, userID, unitID) - if err != nil { - return err - } - - return c.JSON(services.AutoPiTask{ - TaskID: taskID, - Status: "Pending", - Description: "", - Code: 100, - }) -} - // GetAftermarketDeviceClaimMessage godoc // @Description Return the EIP-712 payload to be signed for Aftermarket device claiming. // @Produce json diff --git a/internal/services/autopi_task_service.go b/internal/services/autopi_task_service.go index 02c4f5153..5c63322a3 100644 --- a/internal/services/autopi_task_service.go +++ b/internal/services/autopi_task_service.go @@ -22,7 +22,6 @@ import ( //go:generate mockgen -source autopi_task_service.go -destination mocks/autopi_task_service_mock.go type AutoPiTaskService interface { - StartAutoPiUpdate(deviceID, userID, unitID string) (taskID string, err error) StartQueryAndUpdateVIN(deviceID, unitID, userDeviceID string) (taskID string, err error) GetTaskStatus(ctx context.Context, taskID string) (task *AutoPiTask, err error) StartConsumer(ctx context.Context) @@ -71,15 +70,6 @@ func NewAutoPiTaskService(settings *config.Settings, autoPiSvc AutoPiAPIService, dbs: dbs, log: logger.With().Str("worker queue", workerQueueName).Logger(), } - updateTask := taskq.RegisterTask(&taskq.TaskOptions{ - Name: updateAutoPiTask, - Handler: func(ctx context.Context, taskID, deviceID, userID, unitID string) error { - return ats.processUpdate(ctx, taskID, deviceID, userID, unitID) - }, - RetryLimit: 1, - MinBackoff: time.Minute * 2, - MaxBackoff: time.Minute * 2, - }) vinTask := taskq.RegisterTask(&taskq.TaskOptions{ Name: queryAndUpdateVINTask, Handler: func(ctx context.Context, taskID, deviceID, unitID, userDeviceID string) error { @@ -91,7 +81,6 @@ func NewAutoPiTaskService(settings *config.Settings, autoPiSvc AutoPiAPIService, }) ats.getAndSetVinTask = vinTask - ats.updateAutoPiTask = updateTask ats.redis = r return ats } @@ -99,7 +88,6 @@ func NewAutoPiTaskService(settings *config.Settings, autoPiSvc AutoPiAPIService, type autoPiTaskService struct { settings *config.Settings mainQueue taskq.Queue - updateAutoPiTask *taskq.Task getAndSetVinTask *taskq.Task redis StandardRedis autoPiSvc AutoPiAPIService @@ -124,23 +112,6 @@ func (ats *autoPiTaskService) StartQueryAndUpdateVIN(deviceID, userID, unitID st return taskID, nil } -// StartAutoPiUpdate produces a task -func (ats *autoPiTaskService) StartAutoPiUpdate(deviceID, unitID, userDeviceID string) (taskID string, err error) { - taskID = ksuid.New().String() - msg := ats.updateAutoPiTask.WithArgs(context.Background(), taskID, deviceID, unitID, userDeviceID) - msg.Name = taskID - err = ats.mainQueue.Add(msg) - if err != nil { - return "", err - } - err = ats.updateTaskState(taskID, "waiting for task to be processed", Pending, 100, nil) - if err != nil { - return taskID, err - } - - return taskID, nil -} - func (ats *autoPiTaskService) StartConsumer(ctx context.Context) { if err := ats.mainQueue.Consumer().Start(ctx); err != nil { ats.log.Err(err).Msg("consumer failed") @@ -167,95 +138,6 @@ func (ats *autoPiTaskService) GetTaskStatus(ctx context.Context, taskID string) return apTask, nil } -var disableAutoPiUpdate = true - -// processUpdate handles the autopi update task when consumed -func (ats *autoPiTaskService) processUpdate(ctx context.Context, taskID, deviceID, userID, unitID string) error { - if disableAutoPiUpdate { - _ = ats.updateTaskState(taskID, "autopi update skipped", Success, 200, nil) - ats.log.Warn().Str("unitId", unitID).Msg("Skipping update") - return nil - } - - // check for ctx.Done in channel etc but in non-blocking way? to then return err if so to retry on next app reboot - - log := ats.log.With().Str("handler", updateAutoPiTask+"_ProcessUpdate"). - Str("taskID", taskID). - Str("userID", userID). - Str("unitID", unitID). - Str("deviceID", deviceID).Logger() - // store the userID? - log.Info().Msg("Started processing autopi update") - - err := ats.updateTaskState(taskID, "Started", InProcess, 110, nil) - if err != nil { - log.Err(err).Msg("failed to persist state to redis") - return err - } - //send command to update device, retry after 1m if get an error - cmd, err := ats.autoPiSvc.CommandRaw(ctx, unitID, deviceID, "minionutil.update_release", "") - if err != nil { - log.Err(err).Msg("failed to call autopi api svc with update command") - _ = ats.updateTaskState(taskID, "autopi api call failed", Failure, 500, err) - return err - } - //check that command did not timeout - backoffSchedule := []time.Duration{ - 10 * time.Second, - 30 * time.Second, - 30 * time.Second, - 60 * time.Second, - } - for _, backoff := range backoffSchedule { - time.Sleep(backoff) - job, _, err := ats.autoPiSvc.GetCommandStatus(ctx, cmd.Jid) - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - _ = ats.updateTaskState(taskID, "autopi job was not found in db", Failure, 500, err) - log.Err(err).Msg("autopi job not found in db") - return err - } - continue // try again if error - } - if job.CommandState == "COMMAND_EXECUTED" { - _ = ats.updateTaskState(taskID, "autopi update job received by device", InProcess, 120, nil) - break - } - // this is what ended up hitting for me during update. - if job.CommandState == "TIMEOUT" { - _ = ats.updateTaskState(taskID, "autopi update job timed out, device may be offline or rebooting", Failure, 400, nil) - log.Warn().Msg("autopi update job timed out and did not reach device") - return errors.New("job timeout") - } - } - // note we could fire off a delayed sub-task for the next part, but right now this feels easier to follow and debug - //query device endpoint to check that update was applied. (5M timeout) - backoffSchedule = []time.Duration{ - 35 * time.Second, - 30 * time.Second, - 30 * time.Second, - 60 * time.Second, - 60 * time.Second, - 60 * time.Second, - } - for _, backoff := range backoffSchedule { - time.Sleep(backoff) - d, err := ats.autoPiSvc.GetDeviceByID(deviceID) - if err != nil { - continue // keep trying if error - } - if d.IsUpdated { - _ = ats.updateTaskState(taskID, "autopi update confirmed", Success, 200, nil) - log.Info().Msg("Succesfully applied autopi update") - return nil - } - _ = ats.updateTaskState(taskID, "waiting for autopi to update, query not showing as updated yet", InProcess, 130, nil) - } - // if we got here we could not validate update was applied - _ = ats.updateTaskState(taskID, "update command sent ok, but could not confirm update applied. retries exceeded", Failure, 504, nil) - return nil // by not returning error, task will not be processed again. -} - // queryAndUpdateVIN processes message that: sends autopi command to get vin, polls webhook db for result, and sets user_devices. retries if needed. starts drivly task if able to get vin. func (ats *autoPiTaskService) queryAndUpdateVIN(ctx context.Context, taskID, deviceID, unitID, userDeviceID string) error { log := ats.log.With().Str("handler", queryAndUpdateVINTask). From b05742eac1f4c1185192c5ac6603a42413f4a9f6 Mon Sep 17 00:00:00 2001 From: Dylan Moreland Date: Sat, 4 May 2024 07:04:30 -0400 Subject: [PATCH 2/4] Update Swagger --- docs/docs.go | 27 --------------------------- docs/swagger.json | 27 --------------------------- docs/swagger.yaml | 18 ------------------ 3 files changed, 72 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 27af7ea67..f6c310623 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2294,33 +2294,6 @@ const docTemplate = `{ } } }, - "github_com_DIMO-Network_devices-api_internal_services.AutoPiTask": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "error": { - "type": "string" - }, - "status": { - "type": "string" - }, - "taskId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "updates": { - "description": "Updates increments every time the job was updated.", - "type": "integer" - } - } - }, "github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 827fe7b26..4305ec041 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2286,33 +2286,6 @@ } } }, - "github_com_DIMO-Network_devices-api_internal_services.AutoPiTask": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "error": { - "type": "string" - }, - "status": { - "type": "string" - }, - "taskId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "updates": { - "description": "Updates increments every time the job was updated.", - "type": "integer" - } - } - }, "github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2f1230d7e..23d54cee9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -73,24 +73,6 @@ definitions: message: type: string type: object - github_com_DIMO-Network_devices-api_internal_services.AutoPiTask: - properties: - code: - type: integer - description: - type: string - error: - type: string - status: - type: string - taskId: - type: string - updatedAt: - type: string - updates: - description: Updates increments every time the job was updated. - type: integer - type: object github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute: properties: name: From 2f6bcf450d479c345448f2c7cf3cceb02374a66b Mon Sep 17 00:00:00 2001 From: Dylan Moreland Date: Sat, 4 May 2024 07:34:46 -0400 Subject: [PATCH 3/4] Delete AutoPiTaskService, which isn't used anywhere anymore once /update is gone --- cmd/devices-api/api.go | 6 +- go.mod | 8 - go.sum | 30 -- .../device_data_controller_test.go | 21 +- .../controllers/user_devices_controller.go | 3 - .../user_devices_controller_test.go | 3 +- .../user_integrations_controller_test.go | 20 +- internal/services/autopi_task_service.go | 281 ------------------ .../mocks/autopi_task_service_mock.go | 270 ----------------- 9 files changed, 20 insertions(+), 622 deletions(-) delete mode 100644 internal/services/autopi_task_service.go delete mode 100644 internal/services/mocks/autopi_task_service_mock.go diff --git a/cmd/devices-api/api.go b/cmd/devices-api/api.go index 5c33c25fe..f6d092477 100644 --- a/cmd/devices-api/api.go +++ b/cmd/devices-api/api.go @@ -101,7 +101,6 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, autoPiSvc := services.NewAutoPiAPIService(settings, pdb.DBS) autoPiIngest := services.NewIngestRegistrar(producer) deviceDefinitionRegistrar := services.NewDeviceDefinitionRegistrar(producer, settings) - autoPiTaskService := services.NewAutoPiTaskService(settings, autoPiSvc, pdb.DBS, logger) hardwareTemplateService := autopi.NewHardwareTemplateService(autoPiSvc, pdb.DBS, &logger) autoPi := autopi.NewIntegration(pdb.DBS, ddSvc, autoPiSvc, autoPiIngest, eventService, deviceDefinitionRegistrar, hardwareTemplateService, &logger) macaron := macaron.NewIntegration(pdb.DBS, ddSvc, autoPiIngest, eventService, deviceDefinitionRegistrar, &logger) @@ -129,7 +128,7 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, // controllers userDeviceController := controllers.NewUserDevicesController(settings, pdb.DBS, &logger, ddSvc, ddIntSvc, eventService, smartcarClient, scTaskSvc, teslaSvc, teslaTaskService, cipher, autoPiSvc, autoPiIngest, - deviceDefinitionRegistrar, autoPiTaskService, producer, s3NFTServiceClient, autoPi, redisCache, openAI, usersClient, + deviceDefinitionRegistrar, producer, s3NFTServiceClient, autoPi, redisCache, openAI, usersClient, ddaSvc, natsSvc, wallet, userDeviceSvc, teslaFleetAPISvc) geofenceController := controllers.NewGeofencesController(settings, pdb.DBS, &logger, producer, ddSvc) webhooksController := controllers.NewWebhooksController(settings, pdb.DBS, &logger, autoPiSvc, ddIntSvc) @@ -349,9 +348,6 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, go startGRPCServer(settings, pdb.DBS, hardwareTemplateService, &logger, ddSvc, eventService, iss, userDeviceSvc, teslaTaskService, scTaskSvc) - // start task consumer for autopi - autoPiTaskService.StartConsumer(ctx) - c := make(chan os.Signal, 1) // Create channel to signify a signal being sent with length of 1 signal.Notify(c, os.Interrupt, syscall.SIGTERM) // When an interrupt or termination signal is sent, notify the channel <-c // This blocks the main thread until an interrupt is received diff --git a/go.mod b/go.mod index 1427a507f..66831e827 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,6 @@ require ( github.com/swaggo/swag v1.16.3 github.com/testcontainers/testcontainers-go v0.27.0 github.com/tidwall/gjson v1.17.0 - github.com/vmihailenco/taskq/v3 v3.2.8 github.com/volatiletech/null/v8 v8.1.2 github.com/volatiletech/sqlboiler/v4 v4.16.2 github.com/volatiletech/strmangle v0.0.6 @@ -144,17 +143,12 @@ require ( github.com/aws/aws-sdk-go-v2/service/sso v1.19.0 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.27.0 // indirect github.com/aws/smithy-go v1.20.0 // indirect - github.com/bsm/redislock v0.7.2 // indirect - github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/containerd/containerd v1.7.13 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/docker/docker v25.0.3+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 - github.com/go-redis/redis_rate/v9 v9.1.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -162,8 +156,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e91fcccc7..1ef6f0ab1 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,6 @@ github.com/DIMO-Network/shared v0.10.10 h1:h9b0oj0hSvR2CRp6PzqPhsSjf03XUyTGFsAlP github.com/DIMO-Network/shared v0.10.10/go.mod h1:sfeTTaAf4Y5aU15yGTksdZejJP+X6M2n2M70Qm5+Rqk= github.com/DIMO-Network/synthetic-wallet-instance v0.0.0-20230601233541-6a4c8afb27d3 h1:XMU6rRN57hoh7IYyuVytsIKzDymrbAnnKECFeVf88Hg= github.com/DIMO-Network/synthetic-wallet-instance v0.0.0-20230601233541-6a4c8afb27d3/go.mod h1:+8E6RVHd04ewjrSOohmLf82Grt0kfSaVTQlCnHCTLZU= -github.com/DIMO-Network/taskq/v3 v3.2.9-0.20220518233332-179b5552605f h1:pHPu50/uAiENAiUTQkdThxr7GxzVFwO9STl/jzSaKXg= -github.com/DIMO-Network/taskq/v3 v3.2.9-0.20220518233332-179b5552605f/go.mod h1:ZoRbkYMZWEUKtKvYlLGKiaRQKUjdvwWAIs/WiW1Nwtg= github.com/DIMO-Network/zflogger v1.0.0-beta h1:SlXZmahk4tZqprjHzp14mbLQFMrOcyJ9jpLJLQk8bhw= github.com/DIMO-Network/zflogger v1.0.0-beta/go.mod h1:JZX9lQhjzPs9auqY+oNruiWsvhBufEopRRLWraSi148= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -145,8 +143,6 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o= github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc= -github.com/aws/aws-sdk-go v1.43.45 h1:2708Bj4uV+ym62MOtBnErm/CDX61C4mFe9V2gXy1caE= -github.com/aws/aws-sdk-go v1.43.45/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aws/aws-sdk-go-v2 v1.25.0 h1:sv7+1JVJxOu/dD/sz/csHX7jFqmP001TIY7aytBWDSQ= github.com/aws/aws-sdk-go-v2 v1.25.0/go.mod h1:G104G1Aho5WqF+SR3mDIobTABQzpYV0WxMsKxlMggOA= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.0 h1:2UO6/nT1lCZq1LqM67Oa4tdgP1CvL1sLSxvuD+VrOeE= @@ -193,8 +189,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/bsm/redislock v0.7.2 h1:jggqOio8JyX9FJBKIfjF3fTxAu/v7zC5mAID9LveqG4= -github.com/bsm/redislock v0.7.2/go.mod h1:kS2g0Yvlymc9Dz8V3iVYAtLAaSVruYbAFdYBDrmC5WU= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= @@ -222,8 +216,6 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/burdiyan/kafkautil v0.0.0-20190131162249-eaf83ed22d5b h1:gRFujk0F/KYFDEalhpaAbLIwmeiDH53ZgdllJ7UHxyQ= github.com/burdiyan/kafkautil v0.0.0-20190131162249-eaf83ed22d5b/go.mod h1:5hrpM9I1h0fZlTk8JhqaaBaCs76EbCGvFcPtm5SxcCU= -github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 h1:IHZ1Le1ejzkmS7Si7dIzJvYDWe+BIoNmqMnfWHBZSVw= -github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3/go.mod h1:M5XHQLu90v2JNm/bW2tdsYar+5vhV0gEcBcmDBNAN1Y= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -232,7 +224,6 @@ github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -300,8 +291,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= -github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= @@ -409,18 +398,14 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es= github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= -github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-redis/redis_rate/v9 v9.1.2 h1:H0l5VzoAtOE6ydd38j8MCq3ABlGLnvvbA1xDSVVCHgQ= -github.com/go-redis/redis_rate/v9 v9.1.2/go.mod h1:oam2de2apSgRG8aJzwJddXbNu91Iyz1m8IKJE2vpvlQ= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -597,8 +582,6 @@ github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= @@ -624,8 +607,6 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac h1:w5wltlINIIqRTqQ64dASrCo0fM7k9nosPbKCZnkL0W0= -github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac/go.mod h1:gyMTRVO+ZkEy7wQDyD++okPsBN2q127EpuShhHMWG54= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= @@ -654,8 +635,6 @@ github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= @@ -806,14 +785,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -1010,10 +987,6 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vertica/vertica-sql-go v1.3.3 h1:fL+FKEAEy5ONmsvya2WH5T8bhkvY27y/Ik3ReR2T+Qw= github.com/vertica/vertica-sql-go v1.3.3/go.mod h1:jnn2GFuv+O2Jcjktb7zyc4Utlbu9YVqpHH/lx63+1M4= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/volatiletech/inflect v0.0.1 h1:2a6FcMQyhmPZcLa+uet3VJ8gLn/9svWhJxJYwvE8KsU= github.com/volatiletech/inflect v0.0.1/go.mod h1:IBti31tG6phkHitLlr5j7shC5SOo//x0AjDzaJU1PLA= github.com/volatiletech/null/v8 v8.1.2 h1:kiTiX1PpwvuugKwfvUNX/SU/5A2KGZMXfGD0DUHdKEI= @@ -1191,7 +1164,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1296,7 +1268,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1419,7 +1390,6 @@ golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= diff --git a/internal/controllers/device_data_controller_test.go b/internal/controllers/device_data_controller_test.go index 3ff83621a..8d563c273 100644 --- a/internal/controllers/device_data_controller_test.go +++ b/internal/controllers/device_data_controller_test.go @@ -59,7 +59,7 @@ func TestUserDevicesController_calculateRange(t *testing.T) { DeviceAttributes: attrs, }, nil) - _ = NewUserDevicesController(&config.Settings{Port: "3000"}, nil, &logger, deviceDefSvc, nil, &fakeEventService{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + _ = NewUserDevicesController(&config.Settings{Port: "3000"}, nil, &logger, deviceDefSvc, nil, &fakeEventService{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) rge, err := calculateRange(ctx, deviceDefSvc, ddID, styleID, .7) require.NoError(t, err) require.NotNil(t, rge) @@ -75,7 +75,6 @@ type deps struct { teslaTaskService *mock_services.MockTeslaTaskService autoPiIngest *mock_services.MockIngestRegistrar deviceDefinitionIngest *mock_services.MockDeviceDefinitionRegistrar - autoPiTaskSvc *mock_services.MockAutoPiTaskService openAISvc *mock_services.MockOpenAI logger zerolog.Logger mockCtrl *gomock.Controller @@ -96,7 +95,6 @@ func createMockDependencies(t *testing.T) deps { teslaTaskService := mock_services.NewMockTeslaTaskService(mockCtrl) autoPiIngest := mock_services.NewMockIngestRegistrar(mockCtrl) deviceDefinitionIngest := mock_services.NewMockDeviceDefinitionRegistrar(mockCtrl) - autoPiTaskSvc := mock_services.NewMockAutoPiTaskService(mockCtrl) openAISvc := mock_services.NewMockOpenAI(mockCtrl) credentialSvc := mock_services.NewMockVCService(mockCtrl) @@ -114,7 +112,6 @@ func createMockDependencies(t *testing.T) deps { teslaTaskService: teslaTaskService, autoPiIngest: autoPiIngest, deviceDefinitionIngest: deviceDefinitionIngest, - autoPiTaskSvc: autoPiTaskSvc, openAISvc: openAISvc, logger: logger, mockCtrl: mockCtrl, @@ -139,7 +136,7 @@ func TestUserDevicesController_QueryDeviceErrorCodes(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.QueryDeviceErrorCodes) @@ -213,7 +210,7 @@ func TestUserDevicesController_ShouldErrorOnTooManyErrorCodes(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.QueryDeviceErrorCodes) @@ -286,7 +283,7 @@ func TestUserDevicesController_ShouldErrorInvalidErrorCodes(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.QueryDeviceErrorCodes) @@ -355,7 +352,7 @@ func TestUserDevicesController_ShouldErrorOnEmptyErrorCodes(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.QueryDeviceErrorCodes) @@ -424,7 +421,7 @@ func TestUserDevicesController_ShouldStoreErrorCodeResponse(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.QueryDeviceErrorCodes) @@ -509,7 +506,7 @@ func TestUserDevicesController_GetUserDevicesErrorCodeQueries(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Get("/user/devices/:userDeviceID/error-codes", test.AuthInjectorTestHandler(testUserID), c.GetUserDeviceErrorCodeQueries) @@ -585,7 +582,7 @@ func TestUserDevicesController_ClearUserDeviceErrorCodeQuery(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes/clear", test.AuthInjectorTestHandler(testUserID), c.ClearUserDeviceErrorCodeQuery) @@ -672,7 +669,7 @@ func TestUserDevicesController_ErrorOnAllErrorCodesCleared(t *testing.T) { }() testUserID := "123123" - c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, mockDeps.autoPiTaskSvc, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, pdb.DBS, &mockDeps.logger, mockDeps.deviceDefSvc, mockDeps.deviceDefIntSvc, &fakeEventService{}, mockDeps.scClient, mockDeps.scTaskSvc, mockDeps.teslaSvc, mockDeps.teslaTaskService, nil, nil, mockDeps.autoPiIngest, mockDeps.deviceDefinitionIngest, nil, nil, nil, nil, mockDeps.openAISvc, nil, nil, nil, nil, nil, nil) app := fiber.New() app.Post("/user/devices/:userDeviceID/error-codes/clear", test.AuthInjectorTestHandler(testUserID), c.ClearUserDeviceErrorCodeQuery) diff --git a/internal/controllers/user_devices_controller.go b/internal/controllers/user_devices_controller.go index 62c5f21c5..33fd4f5e7 100644 --- a/internal/controllers/user_devices_controller.go +++ b/internal/controllers/user_devices_controller.go @@ -63,7 +63,6 @@ type UserDevicesController struct { cipher shared.Cipher autoPiSvc services.AutoPiAPIService autoPiIngestRegistrar services.IngestRegistrar - autoPiTaskService services.AutoPiTaskService s3 *s3.Client producer sarama.SyncProducer deviceDefinitionRegistrar services.DeviceDefinitionRegistrar @@ -120,7 +119,6 @@ func NewUserDevicesController(settings *config.Settings, autoPiSvc services.AutoPiAPIService, autoPiIngestRegistrar services.IngestRegistrar, deviceDefinitionRegistrar services.DeviceDefinitionRegistrar, - autoPiTaskService services.AutoPiTaskService, producer sarama.SyncProducer, s3NFTClient *s3.Client, autoPi *autopi.Integration, @@ -147,7 +145,6 @@ func NewUserDevicesController(settings *config.Settings, cipher: cipher, autoPiSvc: autoPiSvc, autoPiIngestRegistrar: autoPiIngestRegistrar, - autoPiTaskService: autoPiTaskService, s3: s3NFTClient, producer: producer, deviceDefinitionRegistrar: deviceDefinitionRegistrar, diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index a7ff5c887..4917c82dd 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -91,7 +91,6 @@ func (s *UserDevicesControllerTestSuite) SetupSuite() { teslaTaskService := mock_services.NewMockTeslaTaskService(mockCtrl) autoPiIngest := mock_services.NewMockIngestRegistrar(mockCtrl) deviceDefinitionIngest := mock_services.NewMockDeviceDefinitionRegistrar(mockCtrl) - autoPiTaskSvc := mock_services.NewMockAutoPiTaskService(mockCtrl) s.redisClient = mocks.NewMockCacheService(mockCtrl) s.autoPiSvc = mock_services.NewMockAutoPiAPIService(mockCtrl) s.usersClient = mock_services.NewMockUserServiceClient(mockCtrl) @@ -105,7 +104,7 @@ func (s *UserDevicesControllerTestSuite) SetupSuite() { s.testUserID = "123123" testUserID2 := "3232451" c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: "prod"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, teslaSvc, teslaTaskService, new(shared.ROT13Cipher), s.autoPiSvc, - autoPiIngest, deviceDefinitionIngest, autoPiTaskSvc, nil, nil, nil, s.redisClient, nil, s.usersClient, s.deviceDataSvc, s.natsService, nil, s.userDeviceSvc, nil) + autoPiIngest, deviceDefinitionIngest, nil, nil, nil, s.redisClient, nil, s.usersClient, s.deviceDataSvc, s.natsService, nil, s.userDeviceSvc, nil) app := test.SetupAppFiber(*logger) app.Post("/user/devices", test.AuthInjectorTestHandler(s.testUserID), c.RegisterDeviceForUser) app.Post("/user/devices/fromvin", test.AuthInjectorTestHandler(s.testUserID), c.RegisterDeviceForUserFromVIN) diff --git a/internal/controllers/user_integrations_controller_test.go b/internal/controllers/user_integrations_controller_test.go index 3a4ae187d..2b5e35e59 100644 --- a/internal/controllers/user_integrations_controller_test.go +++ b/internal/controllers/user_integrations_controller_test.go @@ -65,7 +65,6 @@ type UserIntegrationsControllerTestSuite struct { teslaTaskService *mock_services.MockTeslaTaskService autopiAPISvc *mock_services.MockAutoPiAPIService autoPiIngest *mock_services.MockIngestRegistrar - autoPiTaskService *mock_services.MockAutoPiTaskService eventSvc *mock_services.MockEventService deviceDefinitionRegistrar *mock_services.MockDeviceDefinitionRegistrar deviceDefSvc *mock_services.MockDeviceDefinitionService @@ -100,7 +99,6 @@ func (s *UserIntegrationsControllerTestSuite) SetupSuite() { s.autoPiIngest = mock_services.NewMockIngestRegistrar(s.mockCtrl) s.deviceDefinitionRegistrar = mock_services.NewMockDeviceDefinitionRegistrar(s.mockCtrl) s.eventSvc = mock_services.NewMockEventService(s.mockCtrl) - s.autoPiTaskService = mock_services.NewMockAutoPiTaskService(s.mockCtrl) s.redisClient = mocks.NewMockCacheService(s.mockCtrl) s.userClient = mock_services.NewMockUserServiceClient(s.mockCtrl) s.natsSvc, s.natsServer, err = mock_services.NewMockNATSService(natsStreamName) @@ -114,7 +112,7 @@ func (s *UserIntegrationsControllerTestSuite) SetupSuite() { logger := test.Logger() c := NewUserDevicesController(&config.Settings{Port: "3000"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, s.eventSvc, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, s.cipher, s.autopiAPISvc, - s.autoPiIngest, s.deviceDefinitionRegistrar, s.autoPiTaskService, nil, nil, nil, s.redisClient, nil, s.userClient, nil, s.natsSvc, nil, s.userDeviceSvc, + s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, s.redisClient, nil, s.userClient, nil, s.natsSvc, nil, s.userDeviceSvc, s.teslaFleetAPISvc) app := test.SetupAppFiber(*logger) @@ -324,7 +322,7 @@ func (s *UserIntegrationsControllerTestSuite) TestPostSmartCar_FailureTestVIN() logger := test.Logger() c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: "prod"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, s.eventSvc, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), s.autopiAPISvc, - s.autoPiIngest, s.deviceDefinitionRegistrar, s.autoPiTaskService, nil, nil, nil, s.redisClient, nil, nil, nil, s.natsSvc, nil, s.userDeviceSvc, nil) + s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, s.redisClient, nil, nil, nil, s.natsSvc, nil, s.userDeviceSvc, nil) app := test.SetupAppFiber(*logger) @@ -555,7 +553,7 @@ func (s *UserIntegrationsControllerTestSuite) TestPostAutoPiBlockedForDuplicateD // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) logger := test.Logger() - c := NewUserDevicesController(&config.Settings{Port: "3000"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, s.autoPiTaskService, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := test.SetupAppFiber(*logger) app.Post("/user/devices/:userDeviceID/integrations/:integrationID", test.AuthInjectorTestHandler(testUserID), c.RegisterDeviceIntegration) // arrange @@ -591,7 +589,7 @@ func (s *UserIntegrationsControllerTestSuite) TestPostAutoPiBlockedForDuplicateD // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) logger := test.Logger() - c := NewUserDevicesController(&config.Settings{Port: "3000"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, s.autoPiTaskService, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000"}, s.pdb.DBS, logger, s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := test.SetupAppFiber(*logger) app.Post("/user/devices/:userDeviceID/integrations/:integrationID", test.AuthInjectorTestHandler(testUser2), c.RegisterDeviceIntegration) // arrange @@ -627,7 +625,7 @@ func (s *UserIntegrationsControllerTestSuite) TestGetAutoPiInfoNoUDAI_ShouldUpda const environment = "prod" // shouldUpdate only applies in prod // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) - c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := fiber.New() logger := zerolog.Nop() app.Get("/aftermarket/device/by-serial/:serial", test.AuthInjectorTestHandler(testUserID), owner.AftermarketDevice(s.pdb, s.userClient, &logger), c.GetAftermarketDeviceInfo) @@ -667,7 +665,7 @@ func (s *UserIntegrationsControllerTestSuite) TestGetAutoPiInfoNoUDAI_UpToDate() const environment = "prod" // shouldUpdate only applies in prod // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) - c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := fiber.New() logger := zerolog.Nop() app.Get("/aftermarket/device/by-serial/:serial", test.AuthInjectorTestHandler(testUserID), owner.AftermarketDevice(s.pdb, s.userClient, &logger), c.GetAftermarketDeviceInfo) @@ -704,7 +702,7 @@ func (s *UserIntegrationsControllerTestSuite) TestGetAutoPiInfoNoUDAI_FutureUpda const environment = "prod" // shouldUpdate only applies in prod // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) - c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := fiber.New() logger := zerolog.Nop() app.Get("/aftermarket/device/by-serial/:serial", test.AuthInjectorTestHandler(testUserID), owner.AftermarketDevice(s.pdb, s.userClient, &logger), c.GetAftermarketDeviceInfo) @@ -743,7 +741,7 @@ func (s *UserIntegrationsControllerTestSuite) TestGetAutoPiInfoNoUDAI_ShouldUpda const environment = "prod" // shouldUpdate only applies in prod // specific dependency and controller autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) - c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000", Environment: environment}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) app := fiber.New() logger := zerolog.Nop() app.Get("/aftermarket/device/by-serial/:serial", test.AuthInjectorTestHandler(testUserID), owner.AftermarketDevice(s.pdb, s.userClient, &logger), c.GetAftermarketDeviceInfo) @@ -793,7 +791,7 @@ func (s *UserIntegrationsControllerTestSuite) TestPairAftermarketNoLegacy() { userAddr := crypto.PubkeyToAddress(privateKey.PublicKey) autopiAPISvc := mock_services.NewMockAutoPiAPIService(s.mockCtrl) - c := NewUserDevicesController(&config.Settings{Port: "3000", DIMORegistryChainID: 1337, DIMORegistryAddr: common.BigToAddress(big.NewInt(7)).Hex()}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, nil, kprod, nil, nil, nil, nil, s.userClient, nil, nil, nil, nil, nil) + c := NewUserDevicesController(&config.Settings{Port: "3000", DIMORegistryChainID: 1337, DIMORegistryAddr: common.BigToAddress(big.NewInt(7)).Hex()}, s.pdb.DBS, test.Logger(), s.deviceDefSvc, s.deviceDefIntSvc, &fakeEventService{}, s.scClient, s.scTaskSvc, s.teslaSvc, s.teslaTaskService, new(shared.ROT13Cipher), autopiAPISvc, s.autoPiIngest, s.deviceDefinitionRegistrar, kprod, nil, nil, nil, nil, s.userClient, nil, nil, nil, nil, nil) s.deviceDefIntSvc.EXPECT().GetAutoPiIntegration(gomock.Any()).Return(&ddgrpc.Integration{Id: ksuid.New().String()}, nil).AnyTimes() userID := "louxUser" diff --git a/internal/services/autopi_task_service.go b/internal/services/autopi_task_service.go deleted file mode 100644 index 5c63322a3..000000000 --- a/internal/services/autopi_task_service.go +++ /dev/null @@ -1,281 +0,0 @@ -package services - -import ( - "context" - "crypto/tls" - "database/sql" - "encoding/json" - "time" - - "github.com/DIMO-Network/devices-api/internal/config" - "github.com/DIMO-Network/devices-api/models" - "github.com/DIMO-Network/shared/db" - "github.com/go-redis/redis/v8" - "github.com/pkg/errors" - "github.com/rs/zerolog" - "github.com/segmentio/ksuid" - "github.com/vmihailenco/taskq/v3" - "github.com/vmihailenco/taskq/v3/redisq" - "github.com/volatiletech/null/v8" - "github.com/volatiletech/sqlboiler/v4/boil" -) - -//go:generate mockgen -source autopi_task_service.go -destination mocks/autopi_task_service_mock.go -type AutoPiTaskService interface { - StartQueryAndUpdateVIN(deviceID, unitID, userDeviceID string) (taskID string, err error) - GetTaskStatus(ctx context.Context, taskID string) (task *AutoPiTask, err error) - StartConsumer(ctx context.Context) -} - -// task names -const ( - updateAutoPiTask = "updateTask" - queryAndUpdateVINTask = "queryAndUpdateVINTask" -) - -func NewAutoPiTaskService(settings *config.Settings, autoPiSvc AutoPiAPIService, dbs func() *db.ReaderWriter, logger zerolog.Logger) AutoPiTaskService { - // setup redis connection - var tlsConfig *tls.Config - if settings.RedisTLS { - tlsConfig = new(tls.Config) - } - var r StandardRedis - // handle redis cluster in prod - if settings.Environment == "prod" { - r = redis.NewClusterClient(&redis.ClusterOptions{ - Addrs: []string{settings.RedisURL}, - Password: settings.RedisPassword, - TLSConfig: tlsConfig, - }) - } else { - r = redis.NewClient(&redis.Options{ - Addr: settings.RedisURL, - Password: settings.RedisPassword, - TLSConfig: tlsConfig, - }) - } - - var QueueFactory = redisq.NewFactory() - const workerQueueName = "autopi-worker" - // Create a queue. - mainQueue := QueueFactory.RegisterQueue(&taskq.QueueOptions{ - Name: workerQueueName, - Redis: r, // go-redis client - }) - // register task, handler would be below as - ats := &autoPiTaskService{ - settings: settings, - mainQueue: mainQueue, - autoPiSvc: autoPiSvc, - dbs: dbs, - log: logger.With().Str("worker queue", workerQueueName).Logger(), - } - vinTask := taskq.RegisterTask(&taskq.TaskOptions{ - Name: queryAndUpdateVINTask, - Handler: func(ctx context.Context, taskID, deviceID, unitID, userDeviceID string) error { - return ats.queryAndUpdateVIN(ctx, taskID, deviceID, unitID, userDeviceID) - }, - RetryLimit: 1, - MinBackoff: time.Second * 5, - MaxBackoff: time.Second * 30, - }) - - ats.getAndSetVinTask = vinTask - ats.redis = r - return ats -} - -type autoPiTaskService struct { - settings *config.Settings - mainQueue taskq.Queue - getAndSetVinTask *taskq.Task - redis StandardRedis - autoPiSvc AutoPiAPIService - dbs func() *db.ReaderWriter - log zerolog.Logger -} - -func (ats *autoPiTaskService) StartQueryAndUpdateVIN(deviceID, userID, unitID string) (taskID string, err error) { - taskID = ksuid.New().String() - msg := ats.getAndSetVinTask.WithArgs(context.Background(), deviceID, userID, unitID) - msg.Name = taskID - err = ats.mainQueue.Add(msg) - - if err != nil { - return "", err - } - err = ats.updateTaskState(taskID, "waiting for task to be processed", Pending, 100, nil) - if err != nil { - return taskID, err - } - - return taskID, nil -} - -func (ats *autoPiTaskService) StartConsumer(ctx context.Context) { - if err := ats.mainQueue.Consumer().Start(ctx); err != nil { - ats.log.Err(err).Msg("consumer failed") - } - ats.log.Info().Msg("started autopi tasks consumer") -} - -// GetTaskStatus gets the status from the redis backend - is there a way to do this? multistep -func (ats *autoPiTaskService) GetTaskStatus(ctx context.Context, taskID string) (task *AutoPiTask, err error) { - // problem is taskq does not have a way to retrieve a task, and we want to persist state as we move along the task - taskRaw := ats.redis.Get(ctx, buildAutoPiTaskRedisKey(taskID)) - if taskRaw == nil { - return nil, errors.New("task not found") - } - taskBytes, err := taskRaw.Bytes() - if err != nil { - return nil, err - } - apTask := new(AutoPiTask) - err = json.Unmarshal(taskBytes, apTask) - if err != nil { - return nil, err - } - return apTask, nil -} - -// queryAndUpdateVIN processes message that: sends autopi command to get vin, polls webhook db for result, and sets user_devices. retries if needed. starts drivly task if able to get vin. -func (ats *autoPiTaskService) queryAndUpdateVIN(ctx context.Context, taskID, deviceID, unitID, userDeviceID string) error { - log := ats.log.With().Str("handler", queryAndUpdateVINTask). - Str("taskID", taskID). - Str("userDeviceID", userDeviceID). - Str("unitID", unitID). - Str("deviceID", deviceID).Logger() - // store the userID? - log.Info().Msg("Started processing autopi update") - - err := ats.updateTaskState(taskID, "Started", InProcess, 110, nil) - if err != nil { - log.Err(err).Msg("failed to persist state to redis") - return err - } - //send command to update device, retry after 1m if get an error - cmd, err := ats.autoPiSvc.CommandQueryVIN(ctx, unitID, deviceID, userDeviceID) - if err != nil { - log.Err(err).Msg("failed to call autopi api query vin command") - _ = ats.updateTaskState(taskID, "autopi api call failed", Failure, 500, err) - return err - } - //check that command did not timeout - backoffSchedule := []time.Duration{ - 10 * time.Second, - 30 * time.Second, - 30 * time.Second, - } - for _, backoff := range backoffSchedule { - time.Sleep(backoff) - job, _, err := ats.autoPiSvc.GetCommandStatus(ctx, cmd.Jid) - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - _ = ats.updateTaskState(taskID, "autopi job was not found in db", Failure, 500, err) - log.Err(err).Msg("autopi job not found in db") - return err - } - continue // try again if error - } - if job.CommandState == "COMMAND_EXECUTED" { - if job.Result != nil { - if len(job.Result.Value) == 17 { - // update user_devices - userDevice, err := models.FindUserDevice(ctx, ats.dbs().Reader, userDeviceID) - if err != nil { - _ = ats.updateTaskState(taskID, "failed to get user_device by id "+userDeviceID, Failure, 500, err) - log.Err(err).Msg("failed to get user_device by id") - return nil // we return nil b/c do not want to retry task in this situation, failure could be something bigger DB related - } - userDevice.VinIdentifier = null.StringFrom(job.Result.Value) - userDevice.VinConfirmed = true - - _, err = userDevice.Update(ctx, ats.dbs().Writer, boil.Infer()) - if err != nil { - _ = ats.updateTaskState(taskID, "failed to update user_device with VIN", Failure, 500, err) - log.Err(err).Msg("failed to update user_device with VIN") - return nil // we return nil b/c do not want to retry task in this situation, failure could be something bigger DB related - } - log = log.With().Str("vin", job.Result.Value).Logger() - } - } - // the job was completed, but we still may have not found a valid VIN - _ = ats.updateTaskState(taskID, "autopi query vin returned by device", Success, 200, nil) - break - } - if job.CommandState == "TIMEOUT" { - _ = ats.updateTaskState(taskID, "autopi query vin job timed out, device may be offline or rebooting", Failure, 400, nil) - log.Warn().Msg("autopi query vin job timed out") - return errors.New("job timeout") - } - } - log.Info().Msg("Succesfully queried device for vin. if no vin field in log, no fin was returned.") - return nil // by not returning error, task will not be retried. -} - -// updateTaskState updates the status of the task in redis -func (ats *autoPiTaskService) updateTaskState(taskID, description string, status TaskStatusEnum, code int, err error) error { - updateCnt := 0 - existing, _ := ats.GetTaskStatus(context.Background(), taskID) - if existing != nil { - updateCnt = existing.Updates + 1 - } - t := AutoPiTask{ - TaskID: taskID, - Status: string(status), - Description: description, - Code: code, // need enum with codes - UpdatedAt: time.Now().UTC(), - Updates: updateCnt, - } - if err != nil { - errstr := err.Error() - t.Error = &errstr - } - jb, errM := json.Marshal(t) - if errM != nil { - return errM - } - set := ats.redis.Set(context.Background(), buildAutoPiTaskRedisKey(taskID), jb, time.Hour*72) - return set.Err() -} - -func buildAutoPiTaskRedisKey(taskID string) string { - return updateAutoPiTask + "_" + taskID -} - -// AutoPiTask describes a task that is being worked on asynchronously for autopi -type AutoPiTask struct { - TaskID string `json:"taskId"` - Status string `json:"status"` - Description string `json:"description"` - Code int `json:"code"` - Error *string `json:"error,omitempty"` - UpdatedAt time.Time `json:"updatedAt"` - // Updates increments every time the job was updated. - Updates int `json:"updates"` -} - -type TaskStatusEnum string - -const ( - Pending TaskStatusEnum = "Pending" - InProcess TaskStatusEnum = "InProcess" - Success TaskStatusEnum = "Success" - Failure TaskStatusEnum = "Failure" -) - -// StandardRedis combines methods of redis client and what taskq expects so can use it for both clustered redis client and regular client -type StandardRedis interface { - Del(ctx context.Context, keys ...string) *redis.IntCmd - SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd - Pipelined(ctx context.Context, fn func(pipe redis.Pipeliner) error) ([]redis.Cmder, error) - - // Eval Required by redislock - Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd - EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd - ScriptExists(ctx context.Context, scripts ...string) *redis.BoolSliceCmd - ScriptLoad(ctx context.Context, script string) *redis.StringCmd - Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd - Get(ctx context.Context, key string) *redis.StringCmd -} diff --git a/internal/services/mocks/autopi_task_service_mock.go b/internal/services/mocks/autopi_task_service_mock.go deleted file mode 100644 index ee64074da..000000000 --- a/internal/services/mocks/autopi_task_service_mock.go +++ /dev/null @@ -1,270 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: autopi_task_service.go -// -// Generated by this command: -// -// mockgen -source autopi_task_service.go -destination mocks/autopi_task_service_mock.go -// - -// Package mock_services is a generated GoMock package. -package mock_services - -import ( - context "context" - reflect "reflect" - time "time" - - services "github.com/DIMO-Network/devices-api/internal/services" - redis "github.com/go-redis/redis/v8" - gomock "go.uber.org/mock/gomock" -) - -// MockAutoPiTaskService is a mock of AutoPiTaskService interface. -type MockAutoPiTaskService struct { - ctrl *gomock.Controller - recorder *MockAutoPiTaskServiceMockRecorder -} - -// MockAutoPiTaskServiceMockRecorder is the mock recorder for MockAutoPiTaskService. -type MockAutoPiTaskServiceMockRecorder struct { - mock *MockAutoPiTaskService -} - -// NewMockAutoPiTaskService creates a new mock instance. -func NewMockAutoPiTaskService(ctrl *gomock.Controller) *MockAutoPiTaskService { - mock := &MockAutoPiTaskService{ctrl: ctrl} - mock.recorder = &MockAutoPiTaskServiceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockAutoPiTaskService) EXPECT() *MockAutoPiTaskServiceMockRecorder { - return m.recorder -} - -// GetTaskStatus mocks base method. -func (m *MockAutoPiTaskService) GetTaskStatus(ctx context.Context, taskID string) (*services.AutoPiTask, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTaskStatus", ctx, taskID) - ret0, _ := ret[0].(*services.AutoPiTask) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTaskStatus indicates an expected call of GetTaskStatus. -func (mr *MockAutoPiTaskServiceMockRecorder) GetTaskStatus(ctx, taskID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTaskStatus", reflect.TypeOf((*MockAutoPiTaskService)(nil).GetTaskStatus), ctx, taskID) -} - -// StartAutoPiUpdate mocks base method. -func (m *MockAutoPiTaskService) StartAutoPiUpdate(deviceID, userID, unitID string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartAutoPiUpdate", deviceID, userID, unitID) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartAutoPiUpdate indicates an expected call of StartAutoPiUpdate. -func (mr *MockAutoPiTaskServiceMockRecorder) StartAutoPiUpdate(deviceID, userID, unitID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartAutoPiUpdate", reflect.TypeOf((*MockAutoPiTaskService)(nil).StartAutoPiUpdate), deviceID, userID, unitID) -} - -// StartConsumer mocks base method. -func (m *MockAutoPiTaskService) StartConsumer(ctx context.Context) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "StartConsumer", ctx) -} - -// StartConsumer indicates an expected call of StartConsumer. -func (mr *MockAutoPiTaskServiceMockRecorder) StartConsumer(ctx any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartConsumer", reflect.TypeOf((*MockAutoPiTaskService)(nil).StartConsumer), ctx) -} - -// StartQueryAndUpdateVIN mocks base method. -func (m *MockAutoPiTaskService) StartQueryAndUpdateVIN(deviceID, unitID, userDeviceID string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartQueryAndUpdateVIN", deviceID, unitID, userDeviceID) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartQueryAndUpdateVIN indicates an expected call of StartQueryAndUpdateVIN. -func (mr *MockAutoPiTaskServiceMockRecorder) StartQueryAndUpdateVIN(deviceID, unitID, userDeviceID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartQueryAndUpdateVIN", reflect.TypeOf((*MockAutoPiTaskService)(nil).StartQueryAndUpdateVIN), deviceID, unitID, userDeviceID) -} - -// MockStandardRedis is a mock of StandardRedis interface. -type MockStandardRedis struct { - ctrl *gomock.Controller - recorder *MockStandardRedisMockRecorder -} - -// MockStandardRedisMockRecorder is the mock recorder for MockStandardRedis. -type MockStandardRedisMockRecorder struct { - mock *MockStandardRedis -} - -// NewMockStandardRedis creates a new mock instance. -func NewMockStandardRedis(ctrl *gomock.Controller) *MockStandardRedis { - mock := &MockStandardRedis{ctrl: ctrl} - mock.recorder = &MockStandardRedisMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockStandardRedis) EXPECT() *MockStandardRedisMockRecorder { - return m.recorder -} - -// Del mocks base method. -func (m *MockStandardRedis) Del(ctx context.Context, keys ...string) *redis.IntCmd { - m.ctrl.T.Helper() - varargs := []any{ctx} - for _, a := range keys { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Del", varargs...) - ret0, _ := ret[0].(*redis.IntCmd) - return ret0 -} - -// Del indicates an expected call of Del. -func (mr *MockStandardRedisMockRecorder) Del(ctx any, keys ...any) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]any{ctx}, keys...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Del", reflect.TypeOf((*MockStandardRedis)(nil).Del), varargs...) -} - -// Eval mocks base method. -func (m *MockStandardRedis) Eval(ctx context.Context, script string, keys []string, args ...any) *redis.Cmd { - m.ctrl.T.Helper() - varargs := []any{ctx, script, keys} - for _, a := range args { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Eval", varargs...) - ret0, _ := ret[0].(*redis.Cmd) - return ret0 -} - -// Eval indicates an expected call of Eval. -func (mr *MockStandardRedisMockRecorder) Eval(ctx, script, keys any, args ...any) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]any{ctx, script, keys}, args...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eval", reflect.TypeOf((*MockStandardRedis)(nil).Eval), varargs...) -} - -// EvalSha mocks base method. -func (m *MockStandardRedis) EvalSha(ctx context.Context, sha1 string, keys []string, args ...any) *redis.Cmd { - m.ctrl.T.Helper() - varargs := []any{ctx, sha1, keys} - for _, a := range args { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "EvalSha", varargs...) - ret0, _ := ret[0].(*redis.Cmd) - return ret0 -} - -// EvalSha indicates an expected call of EvalSha. -func (mr *MockStandardRedisMockRecorder) EvalSha(ctx, sha1, keys any, args ...any) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]any{ctx, sha1, keys}, args...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvalSha", reflect.TypeOf((*MockStandardRedis)(nil).EvalSha), varargs...) -} - -// Get mocks base method. -func (m *MockStandardRedis) Get(ctx context.Context, key string) *redis.StringCmd { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, key) - ret0, _ := ret[0].(*redis.StringCmd) - return ret0 -} - -// Get indicates an expected call of Get. -func (mr *MockStandardRedisMockRecorder) Get(ctx, key any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockStandardRedis)(nil).Get), ctx, key) -} - -// Pipelined mocks base method. -func (m *MockStandardRedis) Pipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Pipelined", ctx, fn) - ret0, _ := ret[0].([]redis.Cmder) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Pipelined indicates an expected call of Pipelined. -func (mr *MockStandardRedisMockRecorder) Pipelined(ctx, fn any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Pipelined", reflect.TypeOf((*MockStandardRedis)(nil).Pipelined), ctx, fn) -} - -// ScriptExists mocks base method. -func (m *MockStandardRedis) ScriptExists(ctx context.Context, scripts ...string) *redis.BoolSliceCmd { - m.ctrl.T.Helper() - varargs := []any{ctx} - for _, a := range scripts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "ScriptExists", varargs...) - ret0, _ := ret[0].(*redis.BoolSliceCmd) - return ret0 -} - -// ScriptExists indicates an expected call of ScriptExists. -func (mr *MockStandardRedisMockRecorder) ScriptExists(ctx any, scripts ...any) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]any{ctx}, scripts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScriptExists", reflect.TypeOf((*MockStandardRedis)(nil).ScriptExists), varargs...) -} - -// ScriptLoad mocks base method. -func (m *MockStandardRedis) ScriptLoad(ctx context.Context, script string) *redis.StringCmd { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ScriptLoad", ctx, script) - ret0, _ := ret[0].(*redis.StringCmd) - return ret0 -} - -// ScriptLoad indicates an expected call of ScriptLoad. -func (mr *MockStandardRedisMockRecorder) ScriptLoad(ctx, script any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScriptLoad", reflect.TypeOf((*MockStandardRedis)(nil).ScriptLoad), ctx, script) -} - -// Set mocks base method. -func (m *MockStandardRedis) Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Set", ctx, key, value, expiration) - ret0, _ := ret[0].(*redis.StatusCmd) - return ret0 -} - -// Set indicates an expected call of Set. -func (mr *MockStandardRedisMockRecorder) Set(ctx, key, value, expiration any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockStandardRedis)(nil).Set), ctx, key, value, expiration) -} - -// SetNX mocks base method. -func (m *MockStandardRedis) SetNX(ctx context.Context, key string, value any, expiration time.Duration) *redis.BoolCmd { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetNX", ctx, key, value, expiration) - ret0, _ := ret[0].(*redis.BoolCmd) - return ret0 -} - -// SetNX indicates an expected call of SetNX. -func (mr *MockStandardRedisMockRecorder) SetNX(ctx, key, value, expiration any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNX", reflect.TypeOf((*MockStandardRedis)(nil).SetNX), ctx, key, value, expiration) -} From 317a3f15e583d24c0824dd2d114960482f802104 Mon Sep 17 00:00:00 2001 From: Dylan Moreland Date: Sat, 4 May 2024 07:36:15 -0400 Subject: [PATCH 4/4] Update AutoPiTaskService mock --- .../services/mocks/autopi_task_service_mock.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/internal/services/mocks/autopi_task_service_mock.go b/internal/services/mocks/autopi_task_service_mock.go index ee64074da..aa61382f8 100644 --- a/internal/services/mocks/autopi_task_service_mock.go +++ b/internal/services/mocks/autopi_task_service_mock.go @@ -57,21 +57,6 @@ func (mr *MockAutoPiTaskServiceMockRecorder) GetTaskStatus(ctx, taskID any) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTaskStatus", reflect.TypeOf((*MockAutoPiTaskService)(nil).GetTaskStatus), ctx, taskID) } -// StartAutoPiUpdate mocks base method. -func (m *MockAutoPiTaskService) StartAutoPiUpdate(deviceID, userID, unitID string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartAutoPiUpdate", deviceID, userID, unitID) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartAutoPiUpdate indicates an expected call of StartAutoPiUpdate. -func (mr *MockAutoPiTaskServiceMockRecorder) StartAutoPiUpdate(deviceID, userID, unitID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartAutoPiUpdate", reflect.TypeOf((*MockAutoPiTaskService)(nil).StartAutoPiUpdate), deviceID, userID, unitID) -} - // StartConsumer mocks base method. func (m *MockAutoPiTaskService) StartConsumer(ctx context.Context) { m.ctrl.T.Helper()