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 ...
随机推荐
- Spring的数据库编程浅入浅出——不吹牛逼不装逼
Spring的数据库编程浅入浅出——不吹牛逼不装逼 前言 上文书我写了Spring的核心部分控制反转和依赖注入,后来又衔接了注解,在这后面本来是应该写Spring AOP的,但我觉得对于初学者来说,这 ...
- Elasticsearch实战 | 必要的时候,还得空间换时间!
1.应用场景 实时数据流通过kafka后,根据业务需求,一部分直接借助kafka-connector入Elasticsearch不同的索引中. 另外一部分,则需要先做聚类.分类处理,将聚合出的分类结果 ...
- java并发编程(二十六)----ThreadLocal的使用
其实ThreadLocal很多接触过多线程的同学都可能会很陌生,他不像current包里面那些耳熟能详的api一样在我们面前经常出现,更多的他作为一个本地类出现在系统设计里面.我们可以说一下Sprin ...
- 2019牛客多校训练第三场H.Magic Line(思维)
题目传送门 大致题意: 输入测试用例个数T,输入点的个数n(n为偶数),再分别输入n个不同的点的坐标,要求输出四个整数x1,y1,x2,y2,表示有一条经过点(x1,y1),(x2,y2)的直线将该二 ...
- 从输入URL到浏览器显示页面发生了哪些事情---个人理解
经典面试题:从输入URL到页面显示发生了哪些事情 以前一直都记不住,这次自己理解了一下 用自己的话总结了一次,不对的地方希望大佬给我指出来 1.主机通过DHCP协议获取客户端的IP地址.子网掩码和DN ...
- Python模拟登录淘宝
最近想爬取淘宝的一些商品,但是发现如果要使用搜索等一些功能时基本都需要登录,所以就想出一篇模拟登录淘宝的文章!看了下网上有很多关于模拟登录淘宝,但是基本都是使用scrapy.pyppeteer.sel ...
- Keras载入mnist数据集出错问题解决方案
找到本地keras目录下的mnist.py文件 通常在这个目录下. ..\Anaconda3\Lib\site-packages\keras\datasets 下载mnist.npz文件到本地 下载链 ...
- Linux环境搭建 | 手把手教你配置Linux虚拟机
在上一节 「手把你教你安装Linux虚拟机」 里,我们已经安装好了Linux虚拟机,在这一节里,我们将配置安装好的Linux虚拟机,使其达到可以开发的程度. Ubuntu刚安装完毕之后,还无法进行开发 ...
- 矩阵微分与向量函数Taylor展开
参考博客:https://blog.csdn.net/a_big_pig/article/details/78994033
- 安装VMware Workstation时遇到Microsoft Runtime DLL安装程序未能完成安装
解决:这时不要点确定.开始菜单运行输入‘%temp%’,在弹出的窗体中找到一个文件名中含‘{XXXXXXXXXXXXX}~setup'的文件夹,打开里面会看到有 xxx.msi的,运行就开始vmwar ...