firestore-typesense-search
firestore-typesense-search copied to clipboard
Buffered writes
TLDR
Add buffer-based operations for Typesense to improve reliability and performance.
Change Summary
- This change adds a buffering layer to improve reliability of Typesense operations
- Buffer stores operations in Firestore before processing them in batches
- Provides retry capabilities for failed requests and better error handling
- Configurable via extension parameters for flexibility
Added Features:
-
Buffer functionality for Typesense operations:
- Added option to use buffering for Typesense operations with a new config parameter:
TYPESENSE_USE_BUFFER - Buffer stores operations in Firestore before processing them in batches
- Implemented automatic retry mechanism for failed operations
- Added option to use buffering for Typesense operations with a new config parameter:
-
New Configuration Parameters in
extension.yaml:-
TYPESENSE_USE_BUFFER: Toggle buffering on/off -
TYPESENSE_BUFFER_COLLECTION_IN_FIRESTORE: Collection name for buffer storage -
TYPESENSE_BUFFER_BATCH_SIZE: Number of documents to process in a batch -
TYPESENSE_BUFFER_MAX_RETRIES: Maximum retry attempts for failed operations -
TYPESENSE_BUFFER_FLUSH_INTERVAL: Cron-style interval for buffer processing
-
-
New files:
-
processBuffer.js: Scheduled function to process buffered operations - Added test files:
indexOnWriteWithBuffer.spec.jsandindexOnWriteSubcollectionWithBuffer.spec.js
-
Code Changes:
-
In
indexOnWrite.js:- Modified to check for buffer setting and route operations accordingly
- Split functionality into
realTimeWritesandbufferedWrites - Added handling for path parameters in buffered operations
-
In
processBuffer.js:- Implemented scheduled function to process buffer in batches
- Added retry logic for failed operations
- Added status tracking (pending → processing → completed/retrying → failed)
-
In
config.js:- Added new configuration parameters with defaults
-
Test Environment Updates:
- Added support for custom Typesense fields in test environment
- Created comprehensive test suites for buffered operations
- Added test environment configurations for buffer testing
-
Fix: Double URL Encoding:
- Removed redundant
encodeURIComponentcalls when accessing Typesense collections after updatingtypesense-js - Updated all test files to match this change
- Removed redundant
Dependencies:
-
Updated Typesense client:
- Bumped from v1.8.2 to v2.1.0-3 for improved functionality
PR Checklist
- [x] I have read and signed the Contributor License Agreement.