Skip to content

feat: polling loop (MAPCO-9805)#21

Open
almog8k wants to merge 13 commits intomasterfrom
feat/polling-loop-MAPCO-9805
Open

feat: polling loop (MAPCO-9805)#21
almog8k wants to merge 13 commits intomasterfrom
feat/polling-loop-MAPCO-9805

Conversation

@almog8k
Copy link
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

github-actions bot commented Feb 23, 2026

🎫 Related Jira Issue: MAPCO-9805

@CL-SHLOMIKONCHA CL-SHLOMIKONCHA changed the title feat: polling loop(MAPCO-9805) feat: polling loop (MAPCO-9805) Feb 25, 2026
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