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 an instance of the driver.
Get a Mercure hub instance for the given configuration.
Determine if the given event only targets Mercure connections publishing synchronously.
Identify the shared HTTP-client pool for construction and invalidation.
Get the subscriber token (and cookie) lifetime in whole seconds.
Get the subscriber token factory for the given Mercure configuration.
Add configured claims and resolve the default audience when a token is minted.
Get the end-to-end channel encrypter for the given Mercure configuration.
Get the additional JWT claims for the publisher side of the given Mercure configuration.
Get the JWT secret for the given side ("subscribe" or "publish") of the given Mercure configuration.
Get the additional JWT claims for the given Mercure configuration.
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.
Publish synchronously while honoring commit timing and dispatch locks.
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
CreatesMercureDrivers at line 30
protected Broadcaster
createMercureDriver(array $config)
Create an instance of the driver.
in
CreatesMercureDrivers at line 64
HubInterface
mercure(array $config)
Get a Mercure hub instance for the given configuration.
in
CreatesMercureDrivers at line 113
protected bool
broadcastsToSynchronousMercureConnections(mixed $event)
Determine if the given event only targets Mercure connections publishing synchronously.
in
CreatesMercureDrivers at line 136
protected PoolDefinition
mercurePoolDefinition(array $config)
Identify the shared HTTP-client pool for construction and invalidation.
in
CreatesMercureDrivers at line 144
protected int
mercureSubscribeExpiration(array $config)
Get the subscriber token (and cookie) lifetime in whole seconds.
in
CreatesMercureDrivers at line 152
protected TokenFactoryInterface|null
mercureSubscribeFactory(array $config)
Get the subscriber token factory for the given Mercure configuration.
in
CreatesMercureDrivers at line 177
protected TokenFactoryInterface
mercureTokenFactory(TokenFactoryInterface $factory, array $claims, array $config)
Add configured claims and resolve the default audience when a token is minted.
in
CreatesMercureDrivers at line 196
protected ChannelEncrypter|null
mercureChannelEncrypter(array $config)
Get the end-to-end channel encrypter for the given Mercure configuration.
in
CreatesMercureDrivers at line 220
protected array
mercurePublishClaims(array $config)
Get the additional JWT claims for the publisher side of the given Mercure configuration.
in
CreatesMercureDrivers at line 232
protected string
mercureSecret(array $config, string $side)
Get the JWT secret for the given side ("subscribe" or "publish") of the given Mercure configuration.
in
CreatesMercureDrivers at line 263
protected array
mercureClaims(array $config)
Get the additional JWT claims for the given Mercure configuration.
in
HasPoolProxy at line 28
protected mixed
createPoolProxy(string $driver, Closure $createCallback, PoolDefinition $definition, string $proxyClass)
Create a pool proxy for an immutable definition.
in
HasPoolProxy at line 49
protected PoolDefinition
poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)
Build a namespaced pool definition for a pooled resource.
at line 566
protected Factory
poolFactory()
Get the shared object-pool factory.
in
HasPoolProxy at line 75
HasPoolProxy
setReleaseCallback(string $driver, Closure $callback)
Set the release callback for a pooled driver.
The callback persists on the shared manager for the worker lifetime and is captured by every subsequently created proxy for the driver.
in
HasPoolProxy at line 86
Closure|null
getReleaseCallback(string $driver)
Get the release callback for a pooled driver.
in
HasPoolProxy at line 98
HasPoolProxy
addPoolableDriver(string $driver)
Add a driver to the poolable-driver list.
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 115
HasPoolProxy
removePoolableDriver(string $driver)
Remove a driver from the poolable-driver list.
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 133
array
getPoolableDrivers()
Get the poolable-driver list.
in
HasPoolProxy at line 145
HasPoolProxy
setPoolableDrivers(array $poolableDrivers)
Set the poolable-driver list.
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 326
protected Container
queueRoutesContainer()
Get the container that owns the queue routes.
at line 93
__construct(Container $app)
Create a new manager instance.
at line 101
void
routes(array|null $attributes = null)
Register the routes for handling broadcast channel authentication and sockets.
at line 124
void
userRoutes(array|null $attributes = null)
Register the routes for handling broadcast user authentication.
at line 149
void
channelRoutes(array|null $attributes = null)
Register the routes for handling broadcast authentication and sockets.
Alias of "routes" method.
at line 157
string|null
socket(Request|null $request = null)
Get the socket ID for the given request.
at line 172
AnonymousEvent
on(array|Channel|string $channels)
Begin sending an anonymous broadcast to the given channels.
at line 180
AnonymousEvent
private(string $channel)
Begin sending an anonymous broadcast to the given private channels.
at line 188
AnonymousEvent
presence(string $channel)
Begin sending an anonymous broadcast to the given presence channels.
at line 196
PendingBroadcast
event(mixed $event = null)
Begin broadcasting an event.
at line 207
void
queue(mixed $event)
Queue the given event for broadcast.
at line 284
protected void
dispatchSynchronousBroadcast(BroadcastEvent $event)
Publish synchronously while honoring commit timing and dispatch locks.
at line 334
protected bool
mustBeUniqueAndCannotAcquireLock(object $event)
Determine if the broadcastable event must be unique and determine if we can acquire the necessary lock.
at line 343
Broadcaster
connection(UnitEnum|string|null $name = null)
Get a broadcaster instance by name.
at line 351
Broadcaster
driver(UnitEnum|string|null $name = null)
Get a driver instance.
at line 367
protected Broadcaster
get(string $name)
Attempt to get the connection from the local cache.
at line 378
protected Broadcaster
resolve(string $name)
Resolve the given broadcaster with a pool proxy if needed.
at line 404
protected Broadcaster
doResolve(string|null $name, array $config)
Resolve the given broadcaster.
at line 434
protected Broadcaster
callCustomCreator(array $config)
Call a custom driver creator.
at line 442
protected Broadcaster
createReverbDriver(array $config)
Create an instance of the driver.
at line 450
protected Broadcaster
createPusherDriver(array $config)
Create an instance of the driver.
at line 462
Pusher
pusher(array $config)
Get a Pusher instance for the given configuration.
at line 504
protected Broadcaster
createAblyDriver(array $config)
Create an instance of the driver.
at line 512
AblyRest
ably(array $config)
Get an Ably instance for the given configuration.
at line 520
protected Broadcaster
createRedisDriver(array $config)
Create an instance of the driver.
at line 538
protected Broadcaster
createLogDriver(array $config)
Create an instance of the driver.
at line 546
protected Broadcaster
createNullDriver(array $config)
Create an instance of the driver.
at line 554
protected array|null
getConfig(string $name)
Get the connection configuration.
at line 574
string
getDefaultDriver()
Get the default driver name.
at line 584
void
setDefaultDriver(UnitEnum|string $name)
Set the default broadcast driver name.
Mutates process-global config; per-request use races across coroutines.
at line 599
void
purge(UnitEnum|string|null $name = null)
Disconnect the given driver and remove it from the local cache.
Use this to recover broken pooled resources. Mercure and explicitly pooled drivers also close their shared pools. Other connections sharing a pool acquire a fresh one on their next operation.
at line 652
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.
The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent broadcaster resolution.
at line 670
protected mixed
rescue(Closure $callback)
Execute the given callback using "rescue" if possible.
at line 678
Container
getApplication()
Get the application instance used by the manager.
at line 692
BroadcastManager
setApplication(Container $app)
Set the application instance used by the manager.
Swaps the singleton's container reference; per-request use races across coroutines and breaks every concurrent request resolving broadcasters through this manager.
at line 708
BroadcastManager
forgetDrivers()
Forget all of the resolved driver instances.
This is cache-only: pooled broadcasters remain shared resources until purged or reclaimed by their idle TTL.
at line 719
mixed
__call(string $method, array $parameters)
Dynamically call the default driver instance.