0

I have two genserver implementations, both of which perform a lookup by making a http request and both return the same information, they use different providers in order to do so.

I would like to figure out a way that I could have the first process run and upon failure or validation failure this process would then fail over to the second genserver which makes use of a different provider.

Basically what I'm trying to accomplish is a process failover of sorts: Try process A and if A fails try process B.

What would you recommend would be the best way to go about doing this in Elixir?

Zac
  • 461
  • 5
  • 15

1 Answers1

1

You could make another proxy process (manager), which receives HTTP requests, and decide whether process_A or process_B handles this request, and then do the failover to the other process if failover.

In other words, I think it is not the job of worker processes to handle failover, manager process should take over it.

keroro520
  • 459
  • 4
  • 12
  • Thank you & I completely agree. And how would you recommend that I make the proxy process manager? – Zac Nov 11 '16 at 13:47
  • Take a look at the elixir guide here, http://elixir-lang.org/getting-started/mix-otp/genserver.html#the-need-for-monitoring, You could have your proxy process manager start up process_A and _B and monitor them. Might be tricky to accomplish in a handle_call. I haven't attempted something similar. – Alejandro Huerta Nov 14 '16 at 22:05