Skip to content

phly-swoole-taskworker 2.0.0

Latest
Compare
Choose a tag to compare
@weierophinney weierophinney released this 10 Mar 20:22
· 1 commit to master since this release
2.0.0

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 a getListener() method for retrieving the composed listener later. When invoked, it creates a ServiceBasedTask instance with the service name and payload arguments.

    • #4 adds the ServiceBasedTask class, which implements TaskInterface. When invoked, it pulls the composed service from the container instance passed to its invocation method; if that instance is a DeferredServiceListener, it re-assigns the instance to the results of calling the getListener() method on that class. The service is then called to process the payload arguments.

    • #4 adds the DeferredServiceListenerDelegator. It creates a DeferredServiceListener 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 initial Psr\Container\ContainerInterface argument. This change should be transparent to most users if they are using the ConfigProvider shipped with the package.

  • #4 changes the signature of TaskInterface::invoke() to now require a Psr\Container\ContainerInterface argument.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.