805 questions
1
vote
1
answer
77
views
How to structure MQ consumer loop in Erlang/OTP?
I need to create simple application that consumes message queue and asynchronously handles messages using Erlang/OTP. Consider this pseudo-example in Golang:
var queue chan
func main() {
for req :...
-1
votes
2
answers
120
views
Need to Skip Repetitive logs in Elixir
I have a particular log statement in my Elixir code which is supposed to be called very frequently, but I dont want to print that log statement every time. May be I want to print that once in every 5 ...
3
votes
2
answers
643
views
How can i measure disk size using elixir?
i am new into elixir and phoenix. I have found in erlang, to check disk space using --diskup. And i have found another function/statement inside elixir to check total memory usage:
> :erlang....
1
vote
1
answer
711
views
Convert from erlang:system_time() to os:timestamp()
How can I convert erlang:system_time(), integer, to os:timestamp() {MegaSecs, Secs, MicroSecs} ?
4
votes
1
answer
627
views
gen_server:call with new State
A module calls a gen_server to handle a stream, which uses record as State.
handle_call handles stream using a function from State, which separates completed piece of data and tail,
Now next time, ...
5
votes
1
answer
227
views
Erlang beginnings: moving a function from an escript into OTP
There is a simple implementation of the factorial function in an 'escript' in the Erlang docs. The factorial function is given as:
fac(0) -> 1;
fac(N) -> N * fac(N-1).
That's all fine, I can ...
1
vote
1
answer
324
views
Running a "Select * From tableName" query using MySQL/OTP, with no 'WHERE'
This Driver lets you call a mysql database within an Erlang program.
They provide an example for "Multiple Query and Multiple Result sets"
{ok, [{[<<"foo">>], [[42]]}, {[<<"bar"&...
0
votes
1
answer
586
views
Message passing in Erlang does not print to console
I'm trying to talk in a chatroom using erlang. Everything is almost good in it I think but none of the messages send to other users print to the console. I sent up some tests to see if anything would ...
1
vote
1
answer
343
views
DynamicSupervisor - problem with communication with the workers
I have a problem with communication with the workers created in my dynamicSupervisor. after start all my workers i try make a call to one by pid and is generated one error (always).
At the beginning ...
0
votes
1
answer
2k
views
Count open socket and channel connections in a Phoenix application
Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter ...
0
votes
4
answers
191
views
Actor Model : Can we get the semantics of a shared lock with the actor model?
The fact that an actor processes one message at a time and encapsulates state, which it does not share, is sufficient to provide synchronization semantics. So mutual exclusion (write-lock) is taken ...
0
votes
2
answers
325
views
Are Erlang -callbacks to be invoked only through MFA functions (apply/3, spawn/3, ...)? (Custom Behaviors HOWTO)
That's my suspicion as this simple code
-module(simple_server).
-export( [sayHello/0] ).
-callback say(Num :: term()) -> term().
sayHello() ->
io:fwrite( "Hello 1: ~p\n", [ say(1) ]) ,
...
1
vote
2
answers
456
views
lists:map with side-effects in Erlang
I have a list of batches(sublists) of ids and I want to iterate over this list and spawn a worker process for each id in the batch of ids. Each of these workers will query some service, get the result ...
0
votes
1
answer
572
views
Erlang/OTP upgrade lose existing RabbitMQ messages
I had Erlang/OTP 17 and RabbitMQ Server 3.4.3 installed on my local windows box. Before upgrading to the newer versions in production, I wanted to give it a try on my local box to see if upgrade won't ...
-1
votes
1
answer
350
views
Use unicode characters correctly
I am attempting to save a binary with characters of any type for example:
$ LC_CTYPE=en_US.UTF-8 erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [...
0
votes
2
answers
127
views
Why does my iex return a '-C' or a '-A' when I run this function
I've been learning Elixir for awhile now but I came across something today that totally confused me.
I made this filtering function:
thingy = for a <- ["may", "lay", "45", "67", "bay", "34"], do: ...
1
vote
1
answer
463
views
Correct way to structure Elixir GenServer with listening process
I'm using the elixir-socket library as a way to connect to my backend application to an external websocket. I need this process to be managed (restart if something fails, backoff exponentially if it ...
0
votes
2
answers
980
views
Elixir DynamicSupervisor get child by name
In the DynamicSupervisor module we have a function called start_child which registers a child and starts it. My question is: how later on i can find that particular child by name, because for example ...
2
votes
1
answer
461
views
Elixir get all scheduled messages
I am using the following Process.send_after in order to schedule some event, my question is for given pid can i get all the scheduled events?
1
vote
1
answer
229
views
Convert Core Erlang forms into Erlang source code string
I have Core Erlang forms constructs with the cerl module. I wish to "decompile" it into an Erlang source code string.
I though I could do something like this:
Forms = erl_syntax:form_list(CoreForms),...
1
vote
1
answer
259
views
Process.whereis(:user) returns a pid. What is this pid?
In Elixir's repl iex when I enter Process.whereis(:user) it returns a pid. What is this :user process? What does it do? What is it's state?
It seems to be permanently blocked or sleeping as I have ...
0
votes
2
answers
369
views
Elixir understanding GenServer
I am new to Elixir and was reading through a book and doing some examples. Here is the piece of code that makes me ask question here:
defmodule Sequence.Server do
use GenServer
def init(...
0
votes
0
answers
90
views
how to supervisor a new GenServer on Erlang VM do hot upgrade?
I'm exploring Elixir language, also deep into Erlang environment recently.
I want to know how to use hot upgrade in this situation:
Usually we deploy a application begin with a root supervisor. ...
5
votes
2
answers
242
views
What is explanation for the names given to the supervisor restart strategies?
OTP supervisor restart strategy names seems weird to me, maybe because I'm not a native English speaker.
one_for_one: when one child dies, it restarts that child
one_for_all: when one child dies, it ...
0
votes
1
answer
52
views
Consolidate response of API's though cast method of Genserver
I am trying to call one API 10 times asynchronously though cast method of Genserver. Can someone guide me how I can collect the responses of 10 API and consolidate in one list of tuples?
defmodule ...