-
Notifications
You must be signed in to change notification settings - Fork 36
Buffered writes #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tharropoulos
wants to merge
31
commits into
typesense:master
Choose a base branch
from
tharropoulos:buffered-writes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Buffered writes #122
Conversation
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
- 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
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. |
@jasonbosco Ready for review! 😄 |
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_BUFFER
New 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.js
andindexOnWriteSubcollectionWithBuffer.spec.js
Code Changes:
In
indexOnWrite.js
:realTimeWrites
andbufferedWrites
In
processBuffer.js
:In
config.js
:Test Environment Updates:
Fix: Double URL Encoding:
encodeURIComponent
calls when accessing Typesense collections after updatingtypesense-js
Dependencies:
PR Checklist