<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif">On Sat, May 15, 2021 at 8:55 PM Stanislav Ledenev <<a href="mailto:s.ledenev@gmail.com">s.ledenev@gmail.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br>mod_api accepts requests and transforms them to calls to mod_x, mod_y.<br>mod_func is crucial for the application but it needs a time consuming procedure <div>of initialization. IRL it is some cryptography related stuff.  </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>While mod_func is in the initialization state, mod_api must return 'not_ready' for all requests.<br>While mod_func initializing it is not available for any requests.<br><br></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I'd definitely go with Roger's idea.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Spawn mod_func as part of a supervision tree. This starts out as the proxy. It spawns mod_func_bg which does the block and the initialization. While initialization is ongoing, mod_func responds not_ready, and will do so with a low latency. Once mod_func_bg is done, it sends its data to mod_func. Now mod_func "becomes" the real process, and can answer requests. This avoids the proxy in the common path.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">In this solution the "notification" *is* the data.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">A crash of mod_func repeats the process. You will go back to the not_ready state. And once you are ready for processing, the state will flip with a new notification from mod_func_bg. Failure in mod_func_bg can be detected by a link (or monitor). I'd probably just link them. The two processes' lifetimes are following each other anyway.</div><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">J.</div></div>