Skip to content

feat: polling loop (MAPCO-9805)#21

Merged
almog8k merged 14 commits into
masterfrom
feat/polling-loop-MAPCO-9805
Apr 26, 2026
Merged

feat: polling loop (MAPCO-9805)#21
almog8k merged 14 commits into
masterfrom
feat/polling-loop-MAPCO-9805

Conversation

@almog8k
Copy link
Copy Markdown
Collaborator

@almog8k almog8k commented Feb 23, 2026

Question Answer
New feature
Tests added

Related issues: #XXX , #XXX ...
Closes #XXX ...

Further information:

  • Implement TaskPoller - a bridge class that implements IWorker (new jobnik-sdk interface) using the old mc-priority-queue SDK under the hood. It runs a polling loop over configurable (jobType, taskType) pairs, dispatches each dequeued task to a registered ITaskStrategy via StrategyFactory, and handles ack/reject lifecycle with retry decisions from ErrorHandler.

  • Wire up DI container - register QueueClient, StrategyFactory, ErrorHandler, and TilesDeletionStrategy in containerConfig.ts. The strategy DI token is now read from config (jobDefinitions.tasks.tilesDeletion.type) instead of being hardcoded, keeping it in sync with whatever the queue delivers.

  • Add test infrastructure - introduce tests/helpers/mocks.ts with typed mock factories (createMockQueueClient, createMockStrategyFactory, createMockErrorHandler, createTaskPoller, buildMockStrategy) and tests/helpers/fakes/ with faker-based data builders (buildTask, buildPair). All as unknown as RealType casting is confined to createTaskPoller(); test files use real SDK types and vi.mocked() for type-safe mock setup.

  • Add TaskPoller unit tests - 11 tests covering: stop/start lifecycle, idle loop exit, full success path (resolveWithContext → validate → execute → ack), pair error skipping, mid-loop stop on shutdown signal, max-attempts rejection, error handler decision forwarding, non-Error wrapping, reject-throws resilience, and IWorker event stub contract.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

🎫 Related Jira Issue: MAPCO-9805

Comment thread src/worker/taskPoller.ts
Comment thread src/worker/taskPoller.ts
Comment thread src/worker/taskPoller.ts
Comment thread src/worker/taskPoller.ts
Comment thread src/worker/taskPoller.ts
Comment thread src/worker/taskPoller.ts Outdated
Comment thread src/worker/taskPoller.ts Outdated
Comment thread src/worker/taskPoller.ts Outdated
Comment thread src/worker/workerBuilder.ts Outdated
Comment thread src/worker/workerBuilder.ts
@CL-SHLOMIKONCHA CL-SHLOMIKONCHA changed the title feat: polling loop(MAPCO-9805) feat: polling loop (MAPCO-9805) Feb 25, 2026
@almog8k almog8k merged commit 318aea0 into master Apr 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants