Erlang模块supervisor翻译
child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}
Id = term()
StartFunc = {M,F,A}
M = F = atom()
A = [term()]
Restart = permanent | transient | temporary
Shutdown = brutal_kill | int()>0 | infinity
Type = worker | supervisor
Modules = [Module] | dynamic
Module = atom()
child() = undefined | pid()
child_id() = term() %% 不是pid()
child_spec() =
{Id :: child_id(),
StartFunc :: mfargs(),
Restart :: restart(),
Shutdown :: shutdown(),
Type :: worker(),
Modules :: modules()}
mfargs() = {M :: module(), F :: atom(), A :: [term()] | undefined} %% 如果Restart是temporary,A的值为undefined。
modules() = [module()] | dynamic
restart() = permanent | transient | temporary
shutdown() = brutal_kill | timeout()
strategy() = one_for_all | one_for_one | rest_for_one | simple_one_for_one
sup_ref() = (Name :: atom())
| {Name :: atom(), Node :: node()}
| {global, Name :: atom()}
| {via, Module :: module(), Name :: any()}
| pid()
worker() = worker | supervisor
start_link(Module, Args) -> startlink_ret()
start_link(SupName, Module, Args) -> startlink_ret()
Types:
SupName = sup_name()
Module = module()
Args = term()
startlink_ret() = {ok, pid()} | ignore | {error, startlink_err()}
startlink_err() = {already_started, pid()} | {shutdown, term()} | term()
sup_name() = {local, Name :: atom()} | {global, Name :: atom()} | {via, Module :: module(), Name :: any()}
创建一个监督者进程作为监控树的一部分,在其它方面,函数将确保监督者链接到调用者进程(它的监督者)。
start_child(SupRef, ChildSpec) -> startchild_ret()
Types:
SupRef = sup_ref()
ChildSpec = child_spec() | (List :: [term()])
child_spec() =
{Id :: child_id(),
StartFunc :: mfargs(),
Restart :: restart(),
Shutdown :: shutdown(),
Type :: worker(),
Modules :: modules()}
startchild_ret() = {ok, Child :: child()} | {ok, Child :: child(), Info :: term()} | {error, startchild_err()}
startchild_err() = already_present | {already_started, Child :: child()} | term()
动态增加一个子规范到监督者SuperRef,它启动对应的子进程。
- 进程号;
- Name,supervisor被本地注册的名称;
- {Name,Node},supervisor在其它节点被本地注册;
- {global,Name},supervisor被全局注册;
- {via,Module,ViaName},supervisor通过替代的进程注册表注册。
terminate_child(SupRef, Id) -> Result
Types:
SupRef = sup_ref()
Id = pid() | child_id()
Result = ok | {error, Error}
Error = not_found | simple_one_for_one
restart_child(SupRef, Id) -> Result
Types:
SupRef = sup_ref()
Id = child_id()
Result = {ok, Child :: child()} | {ok, Child :: child(), Info :: term()} | {error, Error}
Error = running | restarting | not_found | simple_one_for_one | term()
告诉监督者SupRef重启一个子进程根据子规范标识符Id。子规范必须存在,对应子进程必须没有在运行。
which_children(SupRef) -> [{Id, Child, Type, Modules}]
Types:
SupRef = sup_ref()
Id = child_id() | undefined
Child = child() | restarting
Type = worker()
Modules = modules()
返回一个新创建列表,含有所有子规范和归属于监督者SupRef的子进程。
- Id - 子规范中定义或在simple_one_for_one监督者情况下为undefined;
- Child - 对应子进程的进程号,函数将被重启为restarting或没有该进程为undefined;
- Type - 定义在子规范;
- Modules - 定义在子规范。
count_children(SupRef) -> PropListOfCounts
Types:
SupRef = sup_ref()
PropListOfCounts = [Count]
Count = {specs, ChildSpecCount :: integer() >= 0} | {active, ActiveProcessCount :: integer() >= 0}
| {supervisors, ChildSupervisorCount :: integer() >= 0} | {workers, ChildWorkerCount :: integer() >= 0}
- specs - 子进程活的或死的总数量;
- active - 所有被监督者管理的激活的运行的子进程数量;
- supervisors - 在规范列表被标记为child_type = supervisor的所有子进程数量,不管子进程是否活着;
- workers - 在规范列表被标记为child_type = worker的所有子进程数量,不管子进程是否活着;
check_childspecs(ChildSpecs) -> Result
Types:
ChildSpecs = [child_spec()]
Result = ok | {error, Error :: term()}
该函数需要一个子规范列表作为参数,如果他们在语法上都正确,返回ok,否则返回{error,Error}。
Module:init(Args) -> Result
Types:
Args = term()
Result = {ok,{{RestartStrategy,MaxR,MaxT},[ChildSpec]}} | ignore
RestartStrategy = strategy()
MaxR = integer()>=0
MaxT = integer()>0
ChildSpec = child_spec()
无论何时使用supervisor:start_link/2,3 监督者被启动,函数被一个新的进程调用找出重启策略、最大重启频率和子规范。
Erlang模块supervisor翻译的更多相关文章
- Erlang模块erl翻译
命令: erl 概述: Erlang模拟器 描述: erl程序启动一个Erlang运行时系统.准确的信息是依赖于系统的(举例,erl是否是脚本或程序,其它程序调用). ...
- Erlang模块gen_server翻译
gen_server 概要: 通用服务器行为描述: 行为模块实现服务器的客户端-服务器关系.一个通用的服务器进程使用这个模块将实现一组标准的接口功能,包括跟踪和错误报告功能.它也符合OTP进程监控树. ...
- Erlang模块file翻译
模块摘要 文件接口模块 描述 模块file提供了文件系统的接口. 在具有线程支持的操作系统上,可以让文件操作以其自己的线程执行,从而允许其他Erlang进程与文件操作并行地 ...
- Erlang模块ets翻译
概要: 内置的存储 描述: 这个模块是Erlang内置存储BIFs的接口.这些提供了在Erlang运行时系统中存储大量数据的能力,并且能够对数据进行持续的访问时间.(在ordered_set的情况下, ...
- Erlang模块gen_fsm翻译
模块摘要 通用有限状态机行为. 描述 用于实现有限状态机的行为模块.使用该模块实现的通用有限状态机进程(gen_fsm)将具有一组标准的接口函数,并包括用于跟踪和错误报告的功能.它 ...
- Erlang模块gen_tcp翻译
概述 TCP/IP套接字接口 描述 gen_tcp模块提供了使用TCP / IP协议与套接字进行通信的功能. 以下代码片段提供了一个客户端连接到端口5678的服务器的简单示例,传输一个二进制文件并关闭 ...
- Erlang模块inet翻译
模块 inet 模块概述 访问TCP / IP协议. 描述 此模块提供对TCP/IP协议的访问. 另请参阅<ERTS用户指南:Inet配置>,以获取有关如何配置用于IP通信的Erlang运 ...
- 理解Erlang/OTP Supervisor
http://www.cnblogs.com/me-sa/archive/2012/01/10/erlang0030.html Supervisors are used to build an hie ...
- [Erlang25]Erlang in anger 翻译
Erlang in anger Erlang in anger 是写Learn some Erlang的帅小伙(照片真是帅死啦)写的,一共87页,可以随意下载(英文原版):http://www ...
随机推荐
- Activiti6系列(5)- 核心API
前言 本来想把<疯狂工作流讲义-activiti6.0>这本书里面的实例拿过来,但是这本书我看完后,认为里面编写的activiti6的核心API代码片段不是很清晰,有不少需要雕琢的地方才好 ...
- Python中input()的使用方法
input()以字符串的方式获取用户输入: >>> x = input() 4.5 >>> type(x) <class 'str'> >> ...
- Unix-IO-同步,异步,阻塞,非阻塞-笔记篇
概念更正 https://www.zhihu.com/question/19732473 错误的四个象限分类 https://www.ibm.com/developerworks/cn/linux/l ...
- 弹性盒子---CSS3布局方式
1.弹性盒子/伸缩盒子 如果要使用弹性盒子属性,首先要将父级元素变成弹性盒子 Flex-direction 设置伸缩盒子的内部元素的排列方式 Row 从左到右安行排列 Column 从上到下按 ...
- thinkphp 框架两种模式 两种模式:开发调试模式、线上生产模式
define(‘APP_DEBUG’,true/false);
- PL/SQL 调用 JAVA代码
1.直接在 SQL Developer中写入代码 create or replace and compile java source named "HelloWorld" as p ...
- (三十九)c#Winform自定义控件-面包屑导航
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- C++责任链
#include <iostream> using namespace std; class Base{ protected: Base *next; public: Base(Base ...
- python聚类算法解决方案(rest接口/mpp数据库/json数据/下载图片及数据)
1. 场景描述 一直做java,因项目原因,需要封装一些经典的算法到平台上去,就一边学习python,一边网上寻找经典算法代码,今天介绍下经典的K-means聚类算法,算法原理就不介绍了,只从代码层面 ...
- cf 1102 B
题意:求字符串中任意相邻两位是否可以可以由前一个加上任意个x或y屏蔽十位与后一位相等,如果可以需要添加的最少数字是多少,x值为0-9,y值也为0-9,求出任意x,y对应情形下字符串需要添加的最少数字, ...