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 ...
随机推荐
- jQuery插件之路(三)——文件上传(支持拖拽上传)
好了,这次咱一改往日的作风,就不多说废话了,哈哈.先贴上源代码地址,点击获取.然后直接进入主题啦,当然,如果你觉得我有哪里写的不对或者欠妥的地方,欢迎留言指出.在附上一些代码之前,我们还是先来了解下, ...
- table 表格 细边框 最简单样式
table 表格细边框的效果实现方法虽然不难,但网上简单有效的方法却很少,在此记录一下 css 样式 /** table 细边框 **/ table{border-collapse: collapse ...
- Cannot attach the file “MvcMovie.mdf” as database “aspnet-MvcMovie”
今天在微软开发人员官网上学习asp.net mvc5入门的时候,遇到一个棘手的问题,我是按照教程一步一步操作的,但期间遇到一个自己觉得莫名其妙的问题,教程中也没有提到这个, 在添加新字段这一章节,跟着 ...
- 几大排序算法的Java实现(原创)
几大排序算法的Java实现 更新中... 注: 该类中附有随机生成[min, max)范围不重复整数的方法,如果各位看官对此方法有什么更好的建议,欢迎提出交流. 各个算法的思路都写在该类的注释中了,同 ...
- java秒杀系列(2)- 页面静态化技术
前言 通过代码片段分别介绍服务端渲染.客户端渲染.对象缓存三种方式的写法. 代码片段仅供参考,具体实现需要根据业务场景自行适配,但思想都是一样. 一.服务端渲染方式 1.接口返回html页面的设置 @ ...
- Linux配置部署_新手向(二)——Nginx安装与配置
目录 前言 Nginx 配置(后续补充) 小结 @ 前言 上一篇整完Linux系统的安装,紧接着就开始来安装些常用的东西吧,首先Nginx. Nginx 简介 Nginx作为转发,负载均衡,凭着其高性 ...
- Linux下复位USB设备
有时候USB设备出错,这时我们希望通过软件复位一下USB设备,可以参考下面这段代码: #include <stdio.h> #include <unistd.h> #inclu ...
- jquery实现表格导入到Excel(加图片)
话不多说直接上代码 第一步:导入jquery的插件https://github.com/rainabba/jquery-table2excel HTML部分: 第二步:添加一个按钮 <but ...
- OCP培训 MySQL OCP认证实战培训【低价送OCP考证名额】
一.OCP培训 MySQL 5.7 OCP认证全套实战培训[低价送OCP考试名额] 课程目标: 风哥为满足想参加MySQL OCP考证的学员,而设计的一套比较全面OCP实战培训课程. 课程涉及MySQ ...
- PicGo+GitHub:你的最佳免费图床选择!
# PicGo介绍 这是一款图片上传的工具,目前支持SM.MS图床,微博图床,七牛图床,腾讯云COS,阿里云OSS,Imgur,又拍云,GitHub等图床,未来将支持更多图床. 所以解决问题的思路就是 ...