ClientManager
class ClientManager
Traits
Constants
| protected CLIENTS_CONTEXT_KEY_PREFIX |
|
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected Client> | $factories | ||
| protected Client> | $clients | Keep the protected property while its clients belong to the current owner. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Build a client from its named configuration.
Build an HTTP client from its named configuration.
Disconnect every client owned by the current invocation.
Details
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 53
void
registerClient(string $name, Closure $factory)
Register a named client factory.
On the shared manager, factories persist across requests. Re-registration disconnects only the current owner's client; other owners retain theirs until cleanup.
at line 68
Client
client(string $name)
Get a named client for the current owner.
at line 76
Client
build(string $name)
Build a fresh named client from its factory or configuration.
at line 90
protected Client
fromConfig(string $name)
Build a client from its named configuration.
at line 129
protected WebClient
webClientFromConfig(string $key)
Build an HTTP client from its named configuration.
at line 155
void
disconnectAll()
Disconnect every client owned by the current invocation.
at line 183
protected void
disconnect(Client $client)
Disconnect a client while tolerating protocol teardown errors.