BroadcastManager
class BroadcastManager implements Factory mixin Broadcaster
Traits
Hosts must declare a protected array $poolableDrivers containing their default poolable drivers.
Properties
| protected Closure> | $releaseCallbacks | from HasPoolProxy | |
| protected array | $drivers | The array of resolved broadcast drivers. |
|
| protected array | $customCreators | The registered custom driver creators. |
|
| protected array | $poolableDrivers | The array of drivers which will be wrapped as pool proxies. |
Methods
Create a pool proxy for an immutable definition.
Build a namespaced pool definition for a pooled resource.
Get the shared object-pool factory.
Get the release callback for a pooled driver.
Add a driver to the poolable-driver list.
Remove a driver from the poolable-driver list.
Set the poolable-driver list.
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
Resolve the default connection name for a given queueable instance.
Resolve the default queue name for a given queueable instance.
Get the container that owns the queue routes.
Register the routes for handling broadcast channel authentication and sockets.
Register the routes for handling broadcast user authentication.
Register the routes for handling broadcast authentication and sockets.
Begin sending an anonymous broadcast to the given private channels.
Begin sending an anonymous broadcast to the given presence channels.
Begin broadcasting an event.
Queue the given event for broadcast.
Determine if the broadcastable event must be unique and determine if we can acquire the necessary lock.
Get a broadcaster instance by name.
Get a driver instance.
Attempt to get the connection from the local cache.
Resolve the given broadcaster with a pool proxy if needed.
Resolve the given broadcaster.
Call a custom driver creator.
Create an instance of the driver.
Create an instance of the driver.
Get a Pusher instance for the given configuration.
Create an instance of the driver.
Get an Ably instance for the given configuration.
Create an instance of the driver.
Create an instance of the driver.
Create an instance of the driver.
Get the connection configuration.
Get the default driver name.
Set the default broadcast driver name.
Disconnect the given driver and remove it from the local cache.
Get the application instance used by the manager.
Forget all of the resolved driver instances.
Dynamically call the default driver instance.
Details
in
HasPoolProxy at line 27
protected mixed
createPoolProxy(string $driver, Closure $createCallback, PoolDefinition $definition, string $proxyClass)
Create a pool proxy for an immutable definition.
in
HasPoolProxy at line 48
protected PoolDefinition
poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)
Build a namespaced pool definition for a pooled resource.
at line 485
protected Factory
poolFactory()
Get the shared object-pool factory.
in
HasPoolProxy at line 74
HasPoolProxy
setReleaseCallback(string $driver, Closure $callback)
Set the release callback for a pooled driver.
Boot-only. The callback persists on the manager for the worker lifetime and is captured by every subsequently created proxy for the driver.
in
HasPoolProxy at line 84
Closure|null
getReleaseCallback(string $driver)
Get the release callback for a pooled driver.
in
HasPoolProxy at line 96
HasPoolProxy
addPoolableDriver(string $driver)
Add a driver to the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 112
HasPoolProxy
removePoolableDriver(string $driver)
Remove a driver from the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 129
array
getPoolableDrivers()
Get the poolable-driver list.
in
HasPoolProxy at line 141
HasPoolProxy
setPoolableDrivers(array $poolableDrivers)
Set the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
ReadsClassAttributes at line 17
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
in
ReadsClassAttributes at line 46
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 58
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
in
ReadsClassAttributes at line 74
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
in
RebindsCallbacksToSelf at line 18
protected Closure|null
bindCallbackToSelf(Closure $callback)
Bind the provided callback to the class instance.
in
ResolvesQueueRoutes at line 19
string|null
resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)
Resolve the default connection name for a given queueable instance.
in
ResolvesQueueRoutes at line 27
string|null
resolveQueueFromQueueRoute(object $queueable)
Resolve the default queue name for a given queueable instance.
in
ResolvesQueueRoutes at line 35
protected QueueRoutes
queueRoutes()
Get the queue routes manager instance.
at line 256
protected Container
queueRoutesContainer()
Get the container that owns the queue routes.
at line 79
__construct(Container $app)
Create a new manager instance.
at line 87
void
routes(array|null $attributes = null)
Register the routes for handling broadcast channel authentication and sockets.
at line 110
void
userRoutes(array|null $attributes = null)
Register the routes for handling broadcast user authentication.
at line 135
void
channelRoutes(array|null $attributes = null)
Register the routes for handling broadcast authentication and sockets.
Alias of "routes" method.
at line 143
string|null
socket(Request|null $request = null)
Get the socket ID for the given request.
at line 158
AnonymousEvent
on(array|Channel|string $channels)
Begin sending an anonymous broadcast to the given channels.
at line 166
AnonymousEvent
private(string $channel)
Begin sending an anonymous broadcast to the given private channels.
at line 174
AnonymousEvent
presence(string $channel)
Begin sending an anonymous broadcast to the given presence channels.
at line 182
PendingBroadcast
event(mixed $event = null)
Begin broadcasting an event.
at line 193
void
queue(mixed $event)
Queue the given event for broadcast.
at line 264
protected bool
mustBeUniqueAndCannotAcquireLock(object $event)
Determine if the broadcastable event must be unique and determine if we can acquire the necessary lock.
at line 273
Broadcaster
connection(UnitEnum|string|null $name = null)
Get a broadcaster instance by name.
at line 281
Broadcaster
driver(UnitEnum|string|null $name = null)
Get a driver instance.
at line 297
protected Broadcaster
get(string $name)
Attempt to get the connection from the local cache.
at line 308
protected Broadcaster
resolve(string $name)
Resolve the given broadcaster with a pool proxy if needed.
at line 334
protected Broadcaster
doResolve(string|null $name, array $config)
Resolve the given broadcaster.
at line 364
protected Broadcaster
callCustomCreator(array $config)
Call a custom driver creator.
at line 372
protected Broadcaster
createReverbDriver(array $config)
Create an instance of the driver.
at line 380
protected Broadcaster
createPusherDriver(array $config)
Create an instance of the driver.
at line 392
Pusher
pusher(array $config)
Get a Pusher instance for the given configuration.
at line 423
protected Broadcaster
createAblyDriver(array $config)
Create an instance of the driver.
at line 431
AblyRest
ably(array $config)
Get an Ably instance for the given configuration.
at line 439
protected Broadcaster
createRedisDriver(array $config)
Create an instance of the driver.
at line 457
protected Broadcaster
createLogDriver(array $config)
Create an instance of the driver.
at line 465
protected Broadcaster
createNullDriver(array $config)
Create an instance of the driver.
at line 473
protected array|null
getConfig(string $name)
Get the connection configuration.
at line 493
string
getDefaultDriver()
Get the default driver name.
at line 503
void
setDefaultDriver(UnitEnum|string $name)
Set the default broadcast driver name.
Boot-only. Mutates process-global config; per-request use races across coroutines.
at line 517
void
purge(UnitEnum|string|null $name = null)
Disconnect the given driver and remove it from the local cache.
Boot or tests only, plus operational recovery for explicitly pooled drivers. Direct drivers are only removed from the manager cache; an explicitly pooled driver also invalidates its shared pool.
at line 564
BroadcastManager
extend(string $driver, Closure $callback)
Register a custom driver creator Closure.
Anonymous closures run in this manager's class scope; non-static closures also receive the manager as $this.
Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent broadcaster resolution.
at line 581
protected mixed
rescue(Closure $callback)
Execute the given callback using "rescue" if possible.
at line 589
Container
getApplication()
Get the application instance used by the manager.
at line 601
BroadcastManager
setApplication(Container $app)
Set the application instance used by the manager.
Tests only. Swaps the singleton's container reference; per-request use races across coroutines and breaks every concurrent request resolving broadcasters through this manager.
at line 614
BroadcastManager
forgetDrivers()
Forget all of the resolved driver instances.
Boot or tests only. This is cache-only: pooled broadcasters remain shared resources until purged or reclaimed by their idle TTL.
at line 624
mixed
__call(string $method, array $parameters)
Dynamically call the default driver instance.