Buffered writes#122
Open
tharropoulos wants to merge 31 commits into
Open
Conversation
- Add `typesenseBufferCollectionInFirestore` to specify Firestore collection for buffering - Add `typesenseBufferBatchSize` to control batch size for buffer processing - Add `typesenseBufferFlushInterval` with default of 3 minutes for buffer flushing
- add scheduled function to process pending operations in buffer - handle batch upserts and deletes to typesense collection - implement retry mechanism for failed operations - track operation status with firestore updates
- move the function logic into a separate function for invoking on test files
- Typesense will not return the ids if none are deleted
- Add `typesenseFields` parameter to `TestEnvironment` constructor - Store custom fields in class instance variable - Use custom fields when creating typesense collection - Default to wildcard field config when no custom fields provided
- Create test suite to verify typesense buffer processing functionality - Test successful upsert operations from buffer to typesense - Test successful delete operations from buffer to typesense - Implement retry logic tests for failed operations - Verify proper status transitions (pending → completed/retrying → failed)
- split monolithic function into smaller, focused helper functions - rename main function from `based` to descriptive `processTypesenseBuffer` - add jsdoc comments to document function purposes and parameters - extract common patterns into reusable functions like `markDocumentsAsCompleted` - improve error handling with consistent status update pattern - rename filter function from `filterByDelete` to `createDeleteFilter`
- after upgrading to 2.1.0, encoding is happening on typesense's side
Collaborator
Author
|
The tests are going to be failing because the buffered deletion feature relies on this PR. After a new tag is released on Dockerhub, I'll update the Typesense version running on CI. |
Collaborator
Author
|
@jasonbosco Ready for review! 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Add buffer-based operations for Typesense to improve reliability and performance.
Change Summary
Added Features:
Buffer functionality for Typesense operations:
TYPESENSE_USE_BUFFERNew Configuration Parameters in
extension.yaml:TYPESENSE_USE_BUFFER: Toggle buffering on/offTYPESENSE_BUFFER_COLLECTION_IN_FIRESTORE: Collection name for buffer storageTYPESENSE_BUFFER_BATCH_SIZE: Number of documents to process in a batchTYPESENSE_BUFFER_MAX_RETRIES: Maximum retry attempts for failed operationsTYPESENSE_BUFFER_FLUSH_INTERVAL: Cron-style interval for buffer processingNew files:
processBuffer.js: Scheduled function to process buffered operationsindexOnWriteWithBuffer.spec.jsandindexOnWriteSubcollectionWithBuffer.spec.jsCode Changes:
In
indexOnWrite.js:realTimeWritesandbufferedWritesIn
processBuffer.js:In
config.js:Test Environment Updates:
Fix: Double URL Encoding:
encodeURIComponentcalls when accessing Typesense collections after updatingtypesense-jsDependencies:
PR Checklist