gen-server Questions

2

Solved

While reading the documentation of both GenServer and Agent I wondered what are the Use Cases the Agent solves that GenServer cannot? So, when to prefer Agent over GenServer? I know that functions...
Kaiulani asked 19/7, 2019 at 7:14

2

Solved

Is it possible to obtain the current state of a gen_server process (presumably by sending some system message)? It could be useful when debugging. Of course, I can add a message which returns the...
Approximate asked 23/11, 2010 at 8:31

4

In GenServer.start_link/3 I can register a name locally using an atom for a process like this: defmodule Worker do use GenServer def start_link do GenServer.start_link(__MODULE__, nil, name: :...
Indira asked 18/8, 2016 at 7:43

3

Solved

I writing an Elixir app with GenServer that starts an external application on boot and shuts it down and does other clean-up on exit. I've added bootup functionality in the init/1 callback and clea...
Machismo asked 28/9, 2016 at 20:8

2

Solved

I am in early stages of learning Erlang and I need some further assistance. Not sure if this will get any sunlight but here it goes ... I am looking for a flow diagram on how the example works. Ex...
Venlo asked 15/5, 2017 at 15:3

2

Solved

I know it's pretty much impossible to have a GenServer process call itself because you essentially hit a deadlock. But, I'm curious if there's a preferred way to do this kind of thing. Assume the ...
Sprint asked 13/12, 2016 at 16:22

2

Solved

gen_server documentation on Module:terminate callback says: Even if the gen_server process is not part of a supervision tree, this function is called if it receives an 'EXIT' message from its p...
Seroka asked 10/9, 2016 at 21:6

1

Solved

Given a simple GenServer process. defmodule KVServer do use GenServer def start do GenServer.start(__MODULE__, %{}, name: :kv_server) end def store(k, v) do GenServer.cast(:kv_server, {:st...
Macknair asked 19/8, 2016 at 6:9

1

Solved

I have a problem with a long-time consuming migration, which I desired to run in the parallel (it can be runned in the parallel). Actually migration is about taking all records in the database and ...
Meilhac asked 29/7, 2016 at 17:23

1

Solved

In both approaches I stuck on How to map processes by given set of ids or groups and then map stored struct to filter data. %{group => [users]} implementation. I realized that groups will be lim...
Badgett asked 18/7, 2016 at 12:1

2

Solved

Can someone explain what's the difference between gen_server:start() and gen_server:start_link()? I've been told that it's something about multi threading stuff. EDIT: If my gen_server is called...
Bani asked 12/7, 2016 at 11:11

1

Solved

When looking at abcast abcast man page, and cast cast man page, I couldn't understand what's the difference between those two. Can someone clarify this to me. Thanks
Footnote asked 4/7, 2016 at 12:7

3

Solved

Mainly I want to know if I can send a function in a message in a distributed Erlang setup. On Machine 1: F1 = Fun()-> hey end, gen_server:call(on_other_machine,F1) On Machine 2: handler_c...
Olodort asked 24/5, 2011 at 13:29

2

Solved

How do we implement a reset-able countdown timer with a GenServer? 1) perform a task after fixed amount of time, say every 60 seconds 2) have a way to reset the countdown back to 60 seconds befor...
Phyletic asked 22/1, 2016 at 13:52

2

Solved

I have a mix project with as simple as possible a Supervisor and GenServer. When I call from iex: EchoCmd.Supervisor.start_link([:Hello]) GenServer.call(:echoserver, :echo) GenServer.call(:echoser...

1

Solved

I have a gen_server that when started attempts to start a certain number of child processes (usually 10-20) under a supervisor in the supervision tree. The gen_server's init callback invokes superv...
Paring asked 7/11, 2014 at 20:16

1

Solved

i am calling elixir genserver from handle info function in GenServer to add phone-number getting form client. But as soon as handle_call is called owner process gets crashed [timeout]. Please help....
Gallman asked 8/8, 2014 at 1:57

2

Solved

I was working though a problem and noticed some code where a previous programmer was passing messages using the standard convention of PID ! Message. I have been using gen_server:cast/2. I was wond...
Momentous asked 9/4, 2014 at 16:22

4

Solved

I want to start a gen_server that additionally, will perform one action every minute. What is the best way to schedule that?
Ceto asked 4/5, 2011 at 12:55

1

Solved

I'm very new to OTP, I'm trying to create simple example to understand supervisor behaviour: Here is simple increment server -module( inc_serv ). -behaviour( gen_server ). -export( [ start/0, inc...
Aun asked 23/8, 2012 at 16:34

4

Solved

I have a gen_server module that logs data to a file when a client process sends it data. What happens when two client processes send data at the same time to this module? Will the file operations c...
Unconsidered asked 24/5, 2012 at 21:38

3

Solved

I'm working through the Erlang documentation, trying to understand the basics of setting up an OTP gen_server and supervisor. Whenever my gen_server crashes, my supervisor crashes as well. In fact,...
Bortz asked 5/5, 2010 at 16:39

2

Solved

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(), erlan...
Unravel asked 16/1, 2012 at 11:11

1

Solved

Disclaimer: The author is a newbie in OTP having some basic knowledge of Erlang's syntax, processes and messages. I am trying to grasp the notion of behaviours in Erlang, but a lot of questions sp...
Surfacetosurface asked 11/8, 2011 at 9:29

1

Solved

After checking out Gen_Fsm and Gen_Server documents, I found that, more or less, they act as similar behavior. In my opinion, if there is one loop function for sending broadcast or listening tcp so...
Saritasarkaria asked 1/6, 2011 at 12:34

© 2022 - 2024 — McMap. All rights reserved.