Skip to content

Instantly share code, notes, and snippets.

@fire
Created September 16, 2014 17:35
Show Gist options
  • Save fire/95dec8f9518bb8385e39 to your computer and use it in GitHub Desktop.
Save fire/95dec8f9518bb8385e39 to your computer and use it in GitHub Desktop.
<chrismccord> iFire: Can you explain what you need to do? It depens on what your task needs to perform
<chrismccord> iFire: Have you read up on GenServer's yet on Elixir's getting started guide? It might be a good place to start
<chrismccord> iFire: It would go in lib/
<iFire> in phoenix I need to check if a client has sent a heatbeat message
<iFire> or rather
<iFire> if not sent message set a data entry to active: false
<chrismccord> iFire: http://elixir-lang.org/getting_started/mix_otp/3.html
<adamkitt_> in addition to send_after / send_interval in chris's link there's also apply_after / apply_interval which call a function after n milliseconds or every n milliseconds, more info in the erlang docs http://www.erlang.org/doc/man/timer.html
<adamkitt_> I also put together a little library that lets you pass a block to apply_after / apply_interval instead of needing a named function at https://github.com/adamkittelson/block_timer
<iFire> chrismccord: I edited the question
<chrismccord> gjaldon: Please revise your tests with assertions
<chrismccord> simply calling the CsrfProtect plug is not enough since we dont raise
<chrismccord> we need to either assert the conn was halted or not
<gjaldon> chrismccord: ok will work on it now
<gjaldon> :D
<iFire> adamkitt_: it's not on hex
<chrismccord> gjaldon: Thanks for the work so far btw :)
<adamkitt_> iFire: yeah it's not on hex, I haven't put together a release yet, it's just a thing i've been using in my own projects
<gjaldon> I'm glad to be of some help :)
<chrismccord> iFire: We still don't have enough information about your issue
<iFire> chrismccord: I don't know what you want?
<chrismccord> You need some way of starting/identifiying the request
<iFire> chrismccord: the message is sent in a phoenix controller
<chrismccord> In your controllers whenver the client connects, You'll need to spawn a gen_server
<chrismccord> on each heartbeat, you forward the heartbeat to that process
<chrismccord> if the gen_server receives a timeout/timer call before getting a hearbeat, then it applies the `active: false` to a record id you gave it when spawned
<jschneck> Seemingly easy question - Are there any examples of using an enum as a column in an ecto schema?
<iFire> chrismccord: well the post has a port number and a address. I'm using that to search the database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment