Added
-
This version provides features to simplify using arbitrary services from your PSR-11 container, particularly services that might compose other dependencies. We recommend using these new features in almost every case, as they allow re-using services within your task workers regardless of the ability to serialize them. They include:
-
#4 adds the
DeferredServiceListener
. It has a constructor that accepts a Swoole HTTP server, a listener for handling a task, and a service name by which that listener is pulled from a PSR-11 container. It also defines agetListener()
method for retrieving the composed listener later. When invoked, it creates aServiceBasedTask
instance with the service name and payload arguments. -
#4 adds the
ServiceBasedTask
class, which implementsTaskInterface
. When invoked, it pulls the composed service from the container instance passed to its invocation method; if that instance is aDeferredServiceListener
, it re-assigns the instance to the results of calling thegetListener()
method on that class. The service is then called to process the payload arguments. -
#4 adds the
DeferredServiceListenerDelegator
. It creates aDeferredServiceListener
instance composing the Swoole HTTP server instance, the listener produced by the$factory
argument, and the$serviceName
passed to it. The class should be used as a delegator factory for any listener that is not directly serializable, including most services that compose other dependencies.
-
Changed
-
#4 changes the constructor of
TaskWorker
to now accept an initialPsr\Container\ContainerInterface
argument. This change should be transparent to most users if they are using theConfigProvider
shipped with the package. -
#4 changes the signature of
TaskInterface::invoke()
to now require aPsr\Container\ContainerInterface
argument.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.