| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
dgbm
9年前发布

Game Analytics开源的Erlang集群调度器:gascheduler

该库实现了一个通用的调度程序,用于处理集群中的任务。任务的生成和处理是专门为特定的应用程序。客户端通过一个回调来执行,并返回一个消息,指示任务的状态。
任务由状态机如下图所示的控制。

  execute(SchedulerName, MFA = {Mod, Fun, Args})               |               |               v      .--->[ Pending ]---.      |                  |  node down         spawn worker      |                  |      `---[ Running ]<---'-----------.          |         |                 |          |     exception           retry          |         |                 |          |         `--->[ Failed ]---'       success           |        |          |        max retries  MFA called          |         exceeded    throw(gascheduler_permanent_failure)          |              |        |          |              v        |          |  {error, max_retries} |          |                       v          |                   {error, permanent_failure}          v  {ok, Result = apply(Mod, Fun, Args)}

使用示例

To start the scheduler some configuration is required to be passed in.

    %% Each gascheduler has its own name. There can be multiple gaschedulers.      Name = test,        %% A list of nodes to execute work on. See also erlang:nodes().      Nodes = [...],        %% Maximum number of workers per node.      MaxWorkers = 10,        %% Maximum number of retries for a worker, i.e. it throws some exception.      MaxRetries = 10,        %% Where to send scheduler status messages to.      Client = self(),        %% Start the scheduler.      {ok, _} = gascheduler:start_link(Name, Nodes, Client, MaxWorkers, MaxRetries),

项目主页:http://www.open-open.com/lib/view/home/1438320466285


 本文由用户 dgbm 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1438320466285.html
Erlang开发 gascheduler