quazar

quazar

Passing lambda to exq job

Is it a good idea to pass lambda to exq job. How it will behave after code upgrade ? I am trying to build abstraction layer over some code. Passing lambda seems easy but I am worried because I have faced some serialization issue while working on rails. Basically old failed job serialized some methods which were changed.

Marked As Solved

voughtdq

voughtdq

It’s best to use some form of {module, function, args} or &Module.function(&1, arg1, arg2.., argN)1.

See here and here.

So doing something like

fn x -> 
  {y, z} = fabulate(x)
  send(y, z)  
end

would cause problems, but, on the other hand:

A fully qualified fun (fun Mod:Fun/Arity) will however be a fully
qualified function that doesn’t refer to any specific code version and
will be reloadable.

And here’s one more from Jose Valim: https://github.com/elixir-lang/elixir/issues/6003#issuecomment-294376459

I guess you could get away with it if you’re careful, but I’d rather play it safe and use {module, function, args}

1 I haven’t verified if this form will survive a code reload.

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement