oilstone / api-typesense-integration
Integration service classes to connect garethhudson07/api resources with a Typesense index
Package info
github.com/oilstone/api-typesense-integration
pkg:composer/oilstone/api-typesense-integration
Requires
- php: ^8.5
- garethhudson07/api: ^9.6
- illuminate/bus: >=12.0
- illuminate/contracts: >=12.0
- illuminate/database: >=12.0
- illuminate/pagination: >=12.0
- illuminate/queue: >=12.0
- illuminate/support: >=12.0
- laravel/scout: ^11.2
- typesense/typesense-php: ^6.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v3.0.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- v0.0.33
- v0.0.32
- v0.0.31
- v0.0.30
- v0.0.29
- v0.0.28
- v0.0.27
- v0.0.26
- v0.0.25
- v0.0.24
- v0.0.23
- v0.0.22
- v0.0.21
- v0.0.20
- v0.0.19
- v0.0.18
- v0.0.17
- v0.0.16
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-feature/system-status-monitor
- dev-develop
This package is auto-updated.
Last update: 2026-10-30 11:00:21 UTC
README
Integration service classes to connect garethhudson07/api resources with a Typesense index.
Forked from the typesense/laravel-scout-typesense-driver repository.
Configuration
The Typesense client is built from scout.typesense in config/scout.php, which is passed to typesense-php as its configuration:
'typesense' => [ 'api_key' => env('TYPESENSE_API_KEY'), 'nodes' => [ [ 'host' => env('TYPESENSE_HOST'), 'port' => env('TYPESENSE_PORT', '443'), 'path' => env('TYPESENSE_PATH', ''), 'protocol' => env('TYPESENSE_PROTOCOL', 'https'), ], ], 'num_retries' => 3, 'retry_interval_seconds' => 1, 'connection_timeout_seconds' => 1, 'request_timeout_seconds' => null, ],
Timeouts
typesense-php no longer applies any timeouts itself, so a hung node could hold a request indefinitely. When guzzlehttp/guzzle is installed and no client is configured, the client is given a Guzzle client with:
| Setting | Purpose |
|---|---|
connection_timeout_seconds |
Seconds to connect to a node (default 1) |
request_timeout_seconds |
Seconds for the whole request (default no limit, so imports of large batches aren't cut off) |
Without Guzzle, or when you set your own client, these settings are ignored and the client is used as configured, or found through php-http discovery.
Each failed request is retried on the next node, so the worst case for a request to an unreachable cluster is roughly (num_retries + 1) × (connection_timeout_seconds + retry_interval_seconds): about 8 seconds with the settings above.
Change of behaviour: apps that set
connection_timeout_secondsand have Guzzle installed now get that connect timeout applied, where it was previously ignored by typesense-php v6. Apps that don't set it get a 1 second connect timeout.
System status monitor
With oilstone/system-status and guzzlehttp/guzzle installed, the typesense monitor type checks the health of the Typesense cluster in scout.typesense:
| Option | Purpose |
|---|---|
collections |
Collection or alias names that must exist (optional). The Scout prefix (scout.prefix) is added, as it is for searchableAs(), so use the same names as your models |
timeout |
Seconds for each request (default 5) |
connect_timeout |
Seconds to connect to each node (default 3) |
options |
Guzzle client options such as proxy or verify |
Every distinct node in nodes and nearest_node is checked separately and without retries, so a down node is reported even while the client would fail over to another. A down node degrades the check while another node is healthy, and the check fails when none are. Each collection is then retrieved from a healthy node: a missing collection fails the check, and an empty one degrades it. The healthy_nodes and documents metadata show the node count and each collection's document count.
The monitor uses its own timeouts, not connection_timeout_seconds or request_timeout_seconds. It is rated optimal under 500ms and acceptable under 2 seconds; override that with the thresholds option.
Add it to system-status.monitors:
'monitors' => [ 'connections' => [ ['type' => 'typesense', 'collections' => ['products']], ], ],
Or use it as a watch's monitor:
'watches' => [ 'definitions' => [ 'search' => [ 'monitor' => ['type' => 'typesense', 'collections' => ['products']], 'failures' => 3, 'handler' => App\Watches\DisableSearch::class, ], ], ],