: This article mainly introduces the QPM-PHP multi-process development-Supervisor configuration reference, for PHP tutorials interested in students can refer.
QPM is a PHP process management framework that can be used to simplify Daemon development, the project address in: https://github.com/Comos/qpm
As of version 0.2, QPM supports three Supervison modes: OneForOne MultiGroupOneForOne and TaskFactoryMode. Different models can be used to establish different process tree combinations, restart sub-processes, and different concurrency control policies to adapt to different application scenarios. Different modes correspond to different factory methods. for example, the method for creating OneForOne is qpm \ supervisor \ Supervisor: oneForOne ($ config );
OneForOne
Method
Qpm \ supervisor \ Supervisor: oneForOne ($ config)
Use cases
All sub-processes use the same callback function or Runnable class.
Configuration field
* RunnableCallback or runnableClass. type callable or qpm \ process \ Runnable runnableCallback is the callback for executing the actual task in the sub-process. RunnableClass is the class used to execute the actual task in the sub-process. it is either runnableCallback or runnableCallback.
The quantity type integer defaults to 1 concurrency.
MaxRestartTimes integer can be used with withInSeconds for the maximum number of restarts.
The withInSeconds type integer and maxRestartTimes indicate the maximum number of restarts of the master process within the specified time. Example 1
'Justdoit', 'quantity '=> 3]; $ sup = qpm \ supervisor \ Supervisor: oneForOne ($ config); $ sup-> start (); Example 2
'Foo', 'quantity '=> 5, 'maxrestarttimes' => 100, 'withinseconds' => 10]; $ sup = qpm \ supervisor \ Supervisor :: oneForOne ($ config); $ sup-> start ();MultiGroupOneForOne
Method
Qpm \ supervisor \ Supervisor: oneForOne ($ config)
Use cases
MultiGroupOneForOne is an upgraded version of OneForOne. it can manage multiple sets of OneForOne processes. The MultiGroupOneForOne configuration is an array embedded with several OneForOne configurations.
TaskFactoryMode
Task factory mode. a task is generated by a specified factory method.
Method
Qpm \ supervisor \ Supervisor: taskFactoryMode ($ config)
Use cases
Different parameters, classes, or Run functions are required for different tasks executed by each sub-process. Therefore, each task is generated by the job factory.
Configuration field
* FactoryMethod callable is used to generate a job object or callable factory method. The returned value of factoryMethod can be qpm, process, Runnable, or callable.
The quantity type integer defaults to 1 concurrency.
As of version 0.2, QPM supports three Supervison modes: OneForOne MultiGroupOneForOne and TaskFactoryMode. Different models can be used to establish different process tree combinations, restart sub-processes, and different concurrency control policies to adapt to different application scenarios. Different modes correspond to different factory methods. for example, the method for creating OneForOne is qpm \ supervisor \ Supervisor: oneForOne ($ config );
OneForOne
Method
Qpm \ supervisor \ Supervisor: oneForOne ($ config)
Use cases
All sub-processes use the same callback function or Runnable class.
Configuration field
* RunnableCallback or runnableClass. type callable or qpm \ process \ Runnable runnableCallback is the callback for executing the actual task in the sub-process. RunnableClass is the class used to execute the actual task in the sub-process. it is either runnableCallback or runnableCallback.
The quantity type integer defaults to 1 concurrency.
MaxRestartTimes integer can be used with withInSeconds for the maximum number of restarts.
The withInSeconds type integer and maxRestartTimes indicate the maximum number of restarts of the master process within the specified time. Example 1
'Justdoit', 'quantity '=> 3]; $ sup = qpm \ supervisor \ Supervisor: oneForOne ($ config); $ sup-> start (); Example 2
'Foo', 'quantity '=> 5, 'maxrestarttimes' => 100, 'withinseconds' => 10]; $ sup = qpm \ supervisor \ Supervisor :: oneForOne ($ config); $ sup-> start ();MultiGroupOneForOne
Method
Qpm \ supervisor \ Supervisor: oneForOne ($ config)
Use cases
MultiGroupOneForOne is an upgraded version of OneForOne. it can manage multiple sets of OneForOne processes. The MultiGroupOneForOne configuration is an array embedded with several OneForOne configurations.
TaskFactoryMode
Task factory mode. a task is generated by a specified factory method.
Method
Qpm \ supervisor \ Supervisor: taskFactoryMode ($ config)
Use cases
Different parameters, classes, or Run functions are required for different tasks executed by each sub-process. Therefore, each task is generated by the job factory.
Configuration field
* FactoryMethod callable is used to generate a job object or callable factory method. The returned value of factoryMethod can be qpm, process, Runnable, or callable.
The quantity type integer defaults to 1 concurrency.
The above introduces the QPM-PHP multi-process development-Supervisor configuration reference, including the content of the aspect, hope to be interested in PHP Tutorial friends help.