-
-
Save s3cur3/63989939f34d14a3ef24db58ab6f8a53 to your computer and use it in GitHub Desktop.
Another GenServer that will crash intermittently
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Greeter2 do | |
use GenServer | |
... | |
@impl GenServer | |
def handle_info(:sleep, server_name) do | |
%{minute: minute} = DateTime.utc_now() | |
timeout = | |
if minute == 0 do | |
60_000 | |
else | |
250 | |
end | |
Process.sleep(timeout) | |
{:noreply, server_name} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment