otp

Why Supervisor.start_child dont work

China☆狼群 提交于 2020-01-14 03:59:07
问题 I'm beginner in Elixir. I have one application that initiate one custom supervisor in application.ex. Code: defmodule MyApp do use Application def start(_type, _args) do import Supervisor.Spec children = [ supervisor(MyApp.Web.Endpoint, []), supervisor(MyApp.Repo, []), #my notifier MyApp.MyNotifier.Supervisor ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end And the code of supervisor is something like this: defmodule MyApp.MyNotifier

How does Erlang hot code swapping work in the middle of activity?

谁说胖子不能爱 提交于 2020-01-12 23:44:52
问题 I am currently working on a live media server, which will allow general consumers to send live video to us. In our current environment we've seen broadcasts sent to us with the duration of days, so the idea of being able to fix a bug (or add a feature) without disconnecting users is extremely compelling. However as I was writing code I realized that hot code swapping doesn't make any sense unless I write every process so that all state is always done inside a gen_server, and all external

Erlang gen_server with long-running tasks

筅森魡賤 提交于 2020-01-12 05:21:19
问题 Good day, I have a gen_server process which does some long-running state-updating tasks periodically in handle_info : handle_info(trigger, State) -> NewState = some_long_running_task(), erlang:send_after(?LOOP_TIME, self(), trigger), {noreply, NewState}. But when such task runs, then whole server gets unresponsive and any call to it leads to whole server crash: my_gen_server:status(). ** exception exit: {timeout,{gen_server,call,[my_gen_server,status]}} in function gen_server:call/2 How it is

Data persistence when worker process dies, how?

本秂侑毒 提交于 2020-01-04 13:48:44
问题 I have worker processes that needs gathered/calculated data as arguments on start up. This is then needed on re-starts as well. Where should I put the initialization code? Inside the supervisors init? Or inside the modules start_link, or init? Are there any best practices in Erlang when it comes to this? 回答1: If the gen_server component has critical state, or state which cannot be re-calculated/re-gathered, I generally avoid keeping the state in gen_server itself. I instead choose to maintain

Data persistence when worker process dies, how?

久未见 提交于 2020-01-04 13:47:33
问题 I have worker processes that needs gathered/calculated data as arguments on start up. This is then needed on re-starts as well. Where should I put the initialization code? Inside the supervisors init? Or inside the modules start_link, or init? Are there any best practices in Erlang when it comes to this? 回答1: If the gen_server component has critical state, or state which cannot be re-calculated/re-gathered, I generally avoid keeping the state in gen_server itself. I instead choose to maintain

Does supervisor block calls while restarting children?

百般思念 提交于 2020-01-04 05:40:40
问题 I'm trying to understand what's happening here: I have a supervisor that is cyclically restarting one client without triggering the MaxR, MaxT mechanism. The client just crashes slowly enough never to trigger the rate limitation. There would have been another mechanism that uses supervisor:which_children/1 and delete_child/2, start_child/2 to adapt the set of children to reality (its scanning for USB devices trying to have one supervisor child per device found). This would normally behave

Erlang (Elixir) Dialyzer - confusing supertype error

荒凉一梦 提交于 2020-01-03 17:22:14
问题 I have defined an Elixir behaviour X . A callback start_link is spec'ed as: @callback start_link( args :: producer_args, opts :: GenServer.options ) :: GenServer.on_start where producer_args type is defined as: @type producer_args :: %{job_queue_name: String.t} In the client code Y that implements the behaviour, start_link is defined as: def start_link(args = %{job_queue_name: _job_queue_name, redis_url: _redis_url}, opts) do GenStage.start_link(__MODULE__, args, opts) end Dialyzer doesn't

Java to Erlang messages

北城以北 提交于 2019-12-30 08:45:08
问题 I'm making a application in Erlang, with a GUI in Java. I've managed to establish a connection between the to languages, but now i need to (i guess) send a message from Java to Erlang, every time I e.g press a button. Is that the right way to go? How would such a message look? I've found a few good sites about this form of integration, but I feel like im not getting everything. http://www.trapexit.org/How_to_communicate_java_and_erlang 回答1: If jinterface is too complicated you might just use

OTP encoded polyline same as Google encoded polyline?

Deadly 提交于 2019-12-25 14:06:30
问题 I have been researching and trying to make sense. My question: are the encoded polylines that Google gives in its directions api same as the leg geometry encoded polylines of Open Trip Planner? 回答1: Late answer, but yes, Open Trip Planner returns google Encoded Polyline format. You can check this link for reference https://groups.google.com/forum/#!topic/opentripplanner-dev/kuR6fM3fY7I 来源: https://stackoverflow.com/questions/27045701/otp-encoded-polyline-same-as-google-encoded-polyline

单片机常用名词解释与常用逻辑电路

拈花ヽ惹草 提交于 2019-12-25 10:40:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> MCS-51系列单片机 MCS-51系列单片机分为两大系列,即51子系列与52子系列。 51子系列:基本型,根据片内ROM的配置,对应的芯片为8031、8051、8751、8951 52子系列:增强型,根据片内ROM的配置,对应的芯片为8032、8052、8752、8952 这两大系列单片机的主要硬件特性如下表: 从上表中可以看到,8031、8031、8032、80C32片内是没有ROM的,对应着上表看,我们可以发现,51系列的单片机的RAM大小为128B,52系列的RAM大小为256B,51系列的计数器为两个16位的,52系列的计数器为三个16位计数器。51系列的中断源为5个,52系列的中断源为6个。 8051与80C51的区别: 80C51单片机是在8051的基础上发展起来的,也就是说在单片机的发展过程中是先有8051,然后才有80C51的。 8051单片机与80C51单片机从外形看是完全一样的,其指令系统、引脚信号、总线等完全一致(完全兼容),也就是说在8051下开发的软件完全可以在80C51上应用,反过来,在89C51下开发的软件也可以在8051上应用。这两种单片机是完全可移植的。 既然这两种单片机外形及内部结构都一样,那它们之间的主要差别在哪里呢?