Questions tagged [gen-event]
15 questions
10
votes
4 answers
Erlang accept incoming tcp connections dynamically
What I am trying to solve: have an Erlang TCP server that listens on a specific port (the code should reside in some kind of external facing interface/API) and each incoming connection should be handled by a gen_server (that is even the…

hyperboreean
- 8,273
- 12
- 61
- 97
4
votes
1 answer
Adding gen_event handlers while initializing an Erlang supervisor process
I'm learning Erlang, and am managing to find answers and work out solutions to most issues relatively efficiently, but have spent an unacceptable amount of time working out this one:
What is the correct way to add handlers to a gen_event module that…

RiqueW
- 212
- 1
- 12
4
votes
3 answers
State in OTP event manager process (not handler!)
Can an OTP event manager process (e.g. a logger) have some state of its own (e.g. logging level) and filter/transform events based on it?

Alexey Romanov
- 167,066
- 35
- 309
- 487
4
votes
2 answers
Launching multiple instances of the same event handler in Elixir
I have a simple event handler in elixir using GenEvent:
defmodule myHandler do
use GenEvent
#Callback
def handle_event {:message, x}, state do
IO.puts("Message value is #{x}")
{:ok, [x|state]}
end
end
I can start one…

Anthony W
- 1,289
- 2
- 15
- 28
3
votes
1 answer
Notify and stop gen_event manager atomically
When a particular message is received by my gen_event manager process, I want it to stop after all handlers have handled it and before they get and handle any other events. The only way I could find is this:
-module(manager).
...
stop(Reason) ->
…

Alexey Romanov
- 167,066
- 35
- 309
- 487
2
votes
1 answer
Erlang: using gen_event global for a remote manager
I can start my event framework just fine when I register it locally:
gen_event:start_link({local, foo_event_container}).
gen_event:add_handler(foo_event_container, foo_event_handler, []).
Calling registered() shows foo_event_container, and when I…

tkersh
- 95
- 1
- 5
2
votes
1 answer
Elixir: Testing GenEvent for error reports
I have a GenEvent that has been added as a handler like so :error_logger.add_report_handler(HoloNet.ErrorLogger)
So that errors/exceptions are captured and forwarded to a exception monitoring service.
I have the following code in a event…

Aaron Dufall
- 1,177
- 10
- 34
2
votes
1 answer
What are the differences between Elixir GenEvent's handle_call and handle_event?
Please look at my answer below for the differences that I found and let me know if they are wrong or if there are more differences. Thank you.

domp
- 751
- 1
- 11
- 23
2
votes
1 answer
gen_event handle_info not getting called
I am using gen_event behaviour and apart from handling events, I wish to be able to handle other generic messages. According to the documentation these messages should be received through handle_info. However, this seems not to be working... unless…

ccol002
- 25
- 6
1
vote
1 answer
How do I use many instances of the same event handler with different state?
I have an OTP application with an event that happens periodically. There are several actors that want to do stuff in response to the event. The stuff each actor does is a function of its own state, but otherwise they're identical.
My problem is with…

nmichaels
- 49,466
- 12
- 107
- 135
1
vote
2 answers
Erlang gen_event don't work
I try to write simple gen_event applcation in erlang.
My code:
-module(test).
-behavior(gen_event).
-export([notify/0]).
%% API
-export([start_link/0, add_handler/0, stop/0]).
%% gen_event callbacks
-export([init/1, handle_event/2, handle_call/2,…

0xAX
- 20,957
- 26
- 117
- 206
1
vote
1 answer
How code_change() function work in gen_server module?
I am a newbie of erlang, So that i have a problem about gen_server. I am still unclear how is code_change() function work?
Can you explain for me?
Thanks and best regards.

Kevin
- 37
- 1
- 6
1
vote
2 answers
Extend gen_event behavior in Erlang
I'm writing an event manager that will take a lot of different event handlers. This event manager will be notified with a lot of different events. Each handler only handle certain events, and ignore the rest. Each handler can also trigger certain…

Sơn Trần-Nguyễn
- 2,188
- 1
- 26
- 30
0
votes
1 answer
Erlang - Exception exit on supervisor and gen_fsm
I have 3 modules: calculadora, log_calculadora and supervisor_calculadora. Calculadora is just a simple calculator that makes sum, subtraction, multiplication and division using gen_fsm and supervisor implements supervisor behaviour. Calculadora…
0
votes
1 answer
Erlang socket.io server with supervisor
I'm currently trying to create a simple chat server with socket.io-erlang. I just started learning Erlang so I have a few problems adapting their demo so it works with modules. Hope you can help me, here's what I have so far. It shouldn't have any…

Luis
- 201
- 3
- 11