Skip to content

Comments

feat(services): upload strategy internal internal handler#190

Merged
y-lakhdar merged 14 commits intomainfrom
refactor/upload-strategy-internal-internal-handler
Feb 4, 2026
Merged

feat(services): upload strategy internal internal handler#190
y-lakhdar merged 14 commits intomainfrom
refactor/upload-strategy-internal-internal-handler

Conversation

@y-lakhdar
Copy link
Contributor

@y-lakhdar y-lakhdar commented Feb 4, 2026

Summary

Adds configurable batch size support to all push services and implements per-batch file container rotation for UpdateStreamService following Coveo's catalog stream API best practices.

Key Changes

Configurable Batch Size

All services now support custom batch sizes (max: 256MB):

  • PushService(source, options, maxQueueSize)
  • StreamService(source, options, userAgents, maxQueueSize)
  • UpdateStreamService(source, options, userAgents, maxQueueSize)

File Container Rotation (UpdateStreamService)

Each batch now gets its own file container:

  1. Create new file container
  2. Upload batch content
  3. Push container immediately

This follows the catalog stream API best practices.

Testing

  • Added StreamDocumentUploadQueueBatchingTest (new)
  • Added FileContainerRotationIntegrationTest (new)

Part 3 of 3 - Split from PR #190

y-lakhdar and others added 5 commits February 4, 2026 09:06
… flushAndPush

- Add handler-based constructor to StreamDocumentUploadQueue

- Add no-arg constructor for test compatibility

- Extract clearQueue() private method

- Add flushAndPush() method with handler delegation

- Maintain backward compatibility with uploader-based path
- Remove fileContainer management from UpdateStreamService

- Remove fileContainer management from UpdateStreamServiceInternal

- Create CatalogStreamUploadHandler in UpdateStreamService constructor

- Use handler-based queue factory method forStreamSource()

- Delegate document operations to queue instead of managing containers

- Simplify close() to call queue.flushAndPush() directly

- Handler now owns file container lifecycle (separation of concerns)
…ecture

- Update StreamDocumentUploadQueueTest: mock UploadStrategy<StreamUpdate>

- Add test for handler-based constructor path

- Update UpdateStreamServiceInternalTest: remove file container tests

- Remove obsolete tests for createUploadAndPush() method

- Update tests to validate queue delegation pattern

- All 154 tests pass with new handler-based queue architecture
@y-lakhdar y-lakhdar changed the title feat: upload strategy internal internal handler feat(services): upload strategy internal internal handler Feb 4, 2026
@y-lakhdar y-lakhdar changed the base branch from main to feat/configurable-batch-size-services February 4, 2026 16:07
@y-lakhdar y-lakhdar changed the base branch from feat/configurable-batch-size-services to main February 4, 2026 16:31
@y-lakhdar y-lakhdar marked this pull request as ready for review February 4, 2026 18:43
@y-lakhdar y-lakhdar requested a review from a team as a code owner February 4, 2026 18:43
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

public void flush() throws IOException, InterruptedException {
if (this.isEmpty()) {
logger.debug("Empty batch. Skipping upload");
return;
}

P2 Badge Clear lastResponse when flush skips an empty batch

When flush() exits early on an empty queue, it leaves lastResponse unchanged. Because UpdateStreamServiceInternal.close() returns queue.getLastResponse(), a close() called after an auto-flush (where the queue is empty) will return the previous batch’s response even though no push occurred during the close. This makes it impossible for callers to distinguish a no-op close from a successful final push and can mask missing final uploads. Consider resetting lastResponse to null when flush() returns early (or when clearing the queue) so close() accurately reflects whether a push happened.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@y-lakhdar y-lakhdar enabled auto-merge (squash) February 4, 2026 20:19
@y-lakhdar y-lakhdar merged commit d0388c6 into main Feb 4, 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.

4 participants