Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Seal Read Write Adapter

Seal Read Write Adapter Laravel Package

cmsig/seal-read-write-adapter

SEAL Read Write Adapter lets you use separate search adapters for reads and writes, enabling reindexing without downtime. Combine any AdapterInterface implementations (e.g., Elasticsearch) and configure via DSN for your framework.

View on GitHub
Deep Wiki
Context7

The ReadWriteAdapter allows to use one adapter instance for reading and one for writing. Part of the https://github.com/php-cmsig/search project. READ-ONLY Repository

Frequently asked questions about Seal Read Write Adapter
How do I configure separate Elasticsearch clusters for reads and writes in Laravel using this adapter?
Bind two `ElasticsearchAdapter` instances to Laravel’s service container—one for reads, one for writes—then inject the `ReadWriteAdapter` into your `Engine`. Use `.env` variables like `SEAL_READ_DSN` and `SEAL_WRITE_DSN` to dynamically configure DSNs per environment. Example: `$app->bind(ReadWriteAdapter::class, fn($app) => new ReadWriteAdapter($app->make('readAdapter'), $app->make('writeAdapter')));`.
Can I use this adapter with Laravel Scout if I’m already using cmsig/seal as my Scout engine?
Yes, but you’ll need to manually wrap Scout’s engine with the `ReadWriteAdapter`. Replace Scout’s default engine binding with your custom `Engine` instance using the adapter. Note: Scout’s built-in features (e.g., `searchable()`) may require adjustments to work with dual adapters. Test thoroughly in staging.
What Laravel versions and PHP versions does this package support?
The package requires PHP 8.1+ and is designed for Laravel 9+. Check the [cmsig/seal](https://github.com/PHP-CMSIG/search) repo for version compatibility, as this adapter depends on it. Always verify against your Laravel version’s minimum PHP requirements (e.g., Laravel 10 needs PHP 8.2+).
How do I handle partial updates or race conditions when reads and writes are decoupled?
Avoid partial updates entirely—always rewrite documents fully to prevent stale reads. For race conditions, implement optimistic concurrency control (e.g., versioning fields like `_version` in Elasticsearch) or use transactions if your write adapter supports them. The adapter’s `MultiAdapter` can help sync writes to both clusters atomically.
Is there a performance impact if my read and write adapters are in different regions or data centers?
Yes, latency will increase for cross-region calls. Mitigate this by: 1) Using connection pooling (e.g., Elasticsearch’s bulk requests), 2) Caching read-heavy queries in Redis with short TTLs, or 3) Deploying a local read replica. Monitor round-trip times with Laravel’s `queue:work` logging or APM tools like New Relic.
Can I dynamically switch adapters based on tenant or environment (e.g., staging vs. production)?
Yes, leverage Laravel’s service container to bind context-specific adapters. For example, use a `TenantAwareReadWriteAdapter` that resolves adapters from config per tenant ID. Override the binding in `AppServiceProvider::boot()` with environment-aware logic, like `config('services.seal.adapters.'.app()->environment()).`
What alternatives exist for read-write separation in Laravel search without using this adapter?
Consider Elasticsearch’s native [read replicas](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node-roles.html) or OpenSearch’s [multi-cluster support](https://opensearch.org/docs/latest/clusters/multi-cluster/). If using Laravel Scout, enable `scout:import` in queues for async reindexing. For simpler setups, Scout’s built-in caching (e.g., `scout:flush`) may suffice without dual adapters.
How do I test this adapter in Laravel’s testing environment to ensure data consistency?
Mock both adapters in tests using Laravel’s `Mockery` or `createMock()`. Verify writes propagate to reads by asserting search results after updates. Test edge cases like concurrent writes with `pestphp/pest` or PHPUnit’s parallel tests. Example: `$this->partialMock(ReadWriteAdapter::class, ['search'])->shouldReceive('search')->andReturn([]);`
What’s the rollback plan if I encounter issues after deploying this adapter in production?
Start by reverting to a single adapter in config (e.g., set `SEAL_READ_ADAPTER` and `SEAL_WRITE_ADAPTER` to the same DSN). Monitor for errors in Laravel’s `failed_jobs` table or Elasticsearch logs. If using queues, pause workers (`php artisan queue:pause`) and manually reprocess failed jobs. Always back up your search index before migration.
How do I monitor for stale reads or failed writes in production?
Instrument the adapter with Laravel’s `events` or a logging library like Monolog. Track metrics like `read_write_latency_ms` and `stale_read_ratio` (e.g., compare document timestamps between adapters). Use Laravel Horizon or StatsD to alert on anomalies. For Elasticsearch, enable slow query logging and set up alerts for high latency in Kibana.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity