<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="76744" data-post-id="76744">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blackode" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackode/120/21060_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blackode
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The practical guide on how to get back the GenServer previous state.<br>
<a href="https://medium.com/blackode/how-to-retrieve-genserver-state-after-termination-the-practical-guide-1bafcff780bb" class="onebox" target="_blank" rel="noopener nofollow ugc">https://medium.com/blackode/how-to-retrieve-genserver-state-after-termination-the-practical-guide-1bafcff780bb</a></p>
<p><a href="https://medium.com/blackode/how-to-retrieve-genserver-state-after-termination-the-practical-guide-1bafcff780bb" rel="noopener nofollow ugc"><img src="https://forum.elixirforum.com/uploads/default/original/2X/d/d1e40f4c702c297c79f3c75a569c6c4f23e41361.jpeg" alt="Article Image" width="690" height="388"></a></p>
<p>Deep understanding of the usage of Supervisors and GenServer together to achieve the fault tolerance.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76744" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/314">Post #313</a>
	                </div>
	            </div>
              <div id="likers-container-76744" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76744"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #313"></div>
  </section>
</div>
    <div class="postbit" id="76861" data-post-id="76861">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="blackode" data-post="314" data-topic="150">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackode/48/21060_2.png" class="avatar"> blackode:</div>
<blockquote>
<p>The practical guide on how to get back the GenServer previous state.</p>
</blockquote>
</aside>
<p>Careful with that though, the <code>terminate/2</code> callback is not always called…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76861" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/315">Post #314</a>
	                </div>
	            </div>
              <div id="likers-container-76861" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76861"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #314"></div>
  </section>
</div>
    <div class="postbit" id="76866" data-post-id="76866">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kokolegorille" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/120/4784_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kokolegorille
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I save to stash on each call instead of terminate.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def handle_call(..., state) do
    ...
    reply_success(state, :ok)
  end

  defp reply_success(state, reply) do
    name = state.uuid
    persist_state(name, state)
    {:reply, reply, state, @timeout}
  end
</code></pre>
<p>As mentionned, terminate is not always executed. It allows me to configure call replies on one spot.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76866" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/316">Post #315</a>
	                </div>
	            </div>
              <div id="likers-container-76866" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76866"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #315"></div>
  </section>
</div>
    <div class="postbit" id="76893" data-post-id="76893">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blackode" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackode/120/21060_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blackode
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="315" data-topic="150">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Careful with that though, the terminate/2 callback is not always called…</p>
</blockquote>
</aside>
<p>Well, Thanks for the information. <img src="https://forum.elixirforum.com/images/emoji/apple/bouquet.png?v=15" title=":bouquet:" class="emoji" alt=":bouquet:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76893" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/317">Post #316</a>
	                </div>
	            </div>
              <div id="likers-container-76893" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76893"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #316"></div>
  </section>
</div>
    <div class="postbit" id="76894" data-post-id="76894">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blackode" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackode/120/21060_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blackode
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kokolegorille" data-post="316" data-topic="150">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/48/4784_2.png" class="avatar"> kokolegorille:</div>
<blockquote>
<p>I save to stash on each call instead of terminate.</p>
</blockquote>
</aside>
<p>That is a great approach <img src="https://forum.elixirforum.com/images/emoji/apple/clap.png?v=15" title=":clap:" class="emoji" alt=":clap:" loading="lazy" width="20" height="20"> .</p>
<p>I appreciate that. However, I have a doubt on this. Will that be a duplication of state? As we are saving state for every request? What makes difference with <code>GenServer</code> state ?</p>
<p>Thank you.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76894" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/318">Post #317</a>
	                </div>
	            </div>
              <div id="likers-container-76894" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76894"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #317"></div>
  </section>
</div>
    <div class="postbit" id="76906" data-post-id="76906">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kokolegorille" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/120/4784_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kokolegorille
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The stash used is a public ets table… There is one state in the server, and one copy in an ets table, under a given key (Here I use the worker uuid). The solution does not survive a reboot, but the read/write are fast enough.</p>
<p>I start worker from a master GenServer, linked to each worker and trapping exit.</p>
<p>So when a worker dies with :normal reason, I delete stash entry from the exit call_back of the master GenServer. This is how I clean up old state…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76906" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/319">Post #318</a>
	                </div>
	            </div>
              <div id="likers-container-76906" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76906"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #318"></div>
  </section>
</div>
    <div class="postbit" id="76926" data-post-id="76926">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dom" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dom/120/9313_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dom
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Be careful with saving the entire state to a stash: the point of restarting the process, rather than just doing a try/catch, is to start from a clean slate so the system can recover from a bad state. When possible it’s better to recompute things or refetch them from database during the process startup.</p>
<p>See for instance <a href="http://learnyousomeerlang.com/building-applications-with-otp" rel="noopener nofollow ugc">The Onion Layer Theory</a> and <a href="http://jlouisramblings.blogspot.jp/2010/11/on-erlang-state-and-crashes.html?m=1" rel="noopener nofollow ugc">On Erlang, State and Crashes</a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76926" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/321">Post #320</a>
	                </div>
	            </div>
              <div id="likers-container-76926" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76926"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #320"></div>
  </section>
</div>
    <div class="postbit" id="76929" data-post-id="76929">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kokolegorille" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/120/4784_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kokolegorille
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The workers I have in this example are db-less… they hold dynamic state for a game of go.</p>
<p>For something related to retrieve state from db, there is this excellent talk.</p>
<aside class="quote quote-modified" data-post="1" data-topic="13219">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/axelson/48/26351_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/5-lonestar-elixirconf-2018-managing-state-in-distributed-elixir-jerel-unruh/13219" rel="nofollow">5) Lonestar ElixirConf 2018 - Managing state in distributed Elixir - Jerel Unruh</a> <a class="badge-category__wrapper " href="/c/learning-resources/talks/58" rel="nofollow"><span data-category-id="58" style="--category-badge-color: #3AB54A; --category-badge-text-color: #FFFFFF; --parent-category-badge-color: #3AB54A;" data-parent-category-id="8" data-drop-close="true" class="badge-category --style-square --has-parent" title="Elixir Talks Section"><span class="badge-category__name">Talks</span></span></a>
    </div>
  </div>
  <blockquote>
    Here’s the Lonestar ElixirConf video of the day! 
Managing state in distributed Elixir - Jerel Unruh 
<a href="https://www.youtube.com/watch?v=V3iBgStaPmA" class="onebox" target="_blank" rel="noopener nofollow">https://www.youtube.com/watch?v=V3iBgStaPmA</a> 

You wrote a beautiful Elixir application and have been running it on one node. Now you need to add additional nodes for scaling or resilience. The web layer works fine as-is but you have a few processes that should run once in the entire cluster, not on every node. What to do? In this talk I’ll show how we’ve solved some problems at Toyota Connected …
  </blockquote>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76929" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/322">Post #321</a>
	                </div>
	            </div>
              <div id="likers-container-76929" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76929"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #321"></div>
  </section>
</div>
    <div class="postbit" id="76935" data-post-id="76935">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blackode" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackode/120/21060_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blackode
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kokolegorille" data-post="319" data-topic="150">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/48/4784_2.png" class="avatar"> kokolegorille:</div>
<blockquote>
<p>So when a worker dies with :normal reason, I delete stash entry from the exit call_back of the master GenServer. This is how I clean up old state…</p>
</blockquote>
</aside>
<p>Gotcha… <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76935" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/323">Post #322</a>
	                </div>
	            </div>
              <div id="likers-container-76935" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76935"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #322"></div>
  </section>
</div>
    <div class="postbit" id="77532" data-post-id="77532">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jorinvo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jorinvo/120/9304_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jorinvo
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi there, I am new to Elixir and like to share a post about my first impressions of getting started and a basic example application that might be interesting for others just starting with Elixir. All feedback is welcome!</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://dev.to/jorinvo/learn-elixir-by-creating-a-command-line-application-3766">
  <header class="source">

      <a href="https://dev.to/jorinvo/learn-elixir-by-creating-a-command-line-application-3766" target="_blank" rel="noopener nofollow ugc" title="06:00AM - 09 April 2018">dev.to – 9 Apr 18</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://dev.to/jorinvo/learn-elixir-by-creating-a-command-line-application-3766" target="_blank" rel="noopener nofollow ugc">Learn Elixir by Creating a Command Line Application — jorin.me</a></h3>

  <p>I'd like to share my experience of getting started with Elixir by writing a simple command line application and introduce the setup for basic Elixir projects.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Cheers<br>
Jorin</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="77532" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-blog-posts/150/324">Post #323</a>
	                </div>
	            </div>
              <div id="likers-container-77532" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="77532"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #323"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/150/load_more?page=30">Load more posts (932 remaining)</a>
</div></template></turbo-stream>