Scout
class Scout
Scout utility class for job customization and engine access.
Provides static configuration for customizing the job classes used when indexing models via the queue. Set these in a service provider boot method to use custom job implementations.
Note: These static properties are set at boot time and read during request handling. This is safe in Swoole/coroutine environments because they store class names (strings), not stateful objects.
Constants
| IMPORTING_CONTEXT_KEY |
Coroutine-local context key indicating that scout:import is currently running. Coroutine-local rather than process-global so concurrent coroutines in the same process don't leak the import flag into each other. |
| IMPORT_PROGRESS_CONTEXT_KEY |
Coroutine-local context key for the active scout:import progress reporter. |
Properties
| static MakeSearchable> | $makeSearchableJob | The job class that makes models searchable. |
|
| static RemoveFromSearch> | $removeFromSearchJob | The job class that removes models from the search index. |
Methods
Specify the job class that should make models searchable.
Specify the job class that should remove models from the search index.
Run the given callback with the "importing" flag set in the current coroutine.
Determine whether scout:import is currently running in this coroutine.
Run the given callback with an import progress reporter in the current coroutine.
Report imported models to the current coroutine's scout:import progress reporter.
Flush all static state.
Details
at line 58
static Engine
engine(string|null $name = null)
Get a Scout engine instance by name.
at line 71
static void
makeSearchableUsing(string $class)
Specify the job class that should make models searchable.
Boot-only. The job class persists in a static property for the worker lifetime and is used by every subsequent searchable import.
at line 84
static void
removeFromSearchUsing(string $class)
Specify the job class that should remove models from the search index.
Boot-only. The job class persists in a static property for the worker lifetime and is used by every subsequent searchable removal.
at line 96
static mixed
whileImporting(callable $callback)
Run the given callback with the "importing" flag set in the current coroutine.
The previous context state is captured before the call and restored in finally. This makes the helper nesting-safe: an inner whileImporting() call won't clear an outer call's flag when it returns.
at line 117
static bool
isImporting()
Determine whether scout:import is currently running in this coroutine.
at line 127
static mixed
whileReportingImportProgress(callable $reporter, callable $callback)
Run the given callback with an import progress reporter in the current coroutine.
at line 150
static void
reportImportProgress(Collection $models)
Report imported models to the current coroutine's scout:import progress reporter.
at line 162
static void
flushState()
Flush all static state.