QPM-PHP multi-process development-Supervisor Configuration Reference

Source: Internet
Author: User
: 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.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.