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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DidactMacros" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DidactMacros
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Reading Chapter 5:</p>
<p>It’s really a great book, as expected from Saša Jurić, given his other materials!</p>
<p>I would just note one thing… (this is not really to do with the content of the book, but the interface for readers)</p>
<p>It would be really great if I could pop-up the function definition for a function being referenced on one page, but that was defined a few pages back.</p>
<p>I don’t know if it’s to do with not getting enough sleep but I keep forgetting the function definitions and I have to scroll back a few pages. Not just once but multiple times on one section. The thing is, the section is concise, and clearly explained, but I’m scrolling back due to not remembering the functions.</p>
<p>This is not something that takes away from the book. I make this suggestion as what I think would be a cool, sprinkles-on-top, feature for future books, or even re-releases.</p>
<p>I’ve opted to copy the functions to a separate document and review them as and when.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="331843" 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-in-action-book-club/63088/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-331843" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="331843"
                     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 #71"></div>
  </section>
</div>
    <div class="postbit" id="332109" data-post-id="332109">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I had some pause after chapter 2, but managed to work my way to the end of chapter 5, now.</p>
<p>First of all, I also want to underscore what an enrichment it is, to have <a class="mention" href="/u/bjorng" rel="nofollow">@bjorng</a> here. His insights about the BEAM are a terrific addendum to <a class="mention" href="/u/sasajuric" rel="nofollow">@sasajuric</a>’s book.Thank you, Björn, to let us participate!</p>
<p>My resume of chapters 3 to 5:</p>
<p>Saša gives a fine declaration of pattern matching, multiclause functions and guards in chapter 3. The control structures are well explained and the examples are very helpful. The explanation of the “when” clause is also very good. I think for many people, who are coming from imperative languages, Saša does a good job in explaining the functional way of implementing structures. I also appreciate the part about Streams.</p>
<p>Chapter 4 is about data abstractions. It gives a good introduction on how to organize the code.</p>
<p>In chapter 5, the power of parallelism in Elixir begins to get tangible for me and some of the open questions, I had from chapter 1, are finally answered. This chapter was fun to read and work through, as I get some hunch about the benefits of the BEAM here.</p>
<p>I am looking forward to the next chapters.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332109" data-batch-url="/posts/batch_likers">
                        5
                      </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-in-action-book-club/63088/73">Post #72</a>
	                </div>
	            </div>
              <div id="likers-container-332109" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332109"
                     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 #72"></div>
  </section>
</div>
    <div class="postbit" id="332446" data-post-id="332446">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DidactMacros" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DidactMacros
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Finished Chapter 6 adn completed the conversion of the TodoList abstraction to a GenServer implementation.</p>
<p>During the conversion I found that I was cautious in relying on the difference in arity and privatisation between the implementation and interface functions. Is such dependence alright to permit as standard practice for such conversions, or is it better to use different names to make refactoring later more straightforward?</p>
<p>I</p>
<p><strong>interface func head:</strong></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def add_entry(todo_list, entry)
</code></pre>
<p><strong>Implementation fun head</strong></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defp add_entry(entry)
</code></pre>
<p>The interface calls GenServer.cast(…) which then calls the relevant handle_cast of the callback module. Instead of placing the logic for generating the new state directly in the handle_cast I just forwarded it to the implementation function, as this seems like a good compartmentalisation approach.</p>
<p>I really enjoyed chapter 6, I appreciated the way we are walked through developing are own less feature rich GenServer and how this tour teaches us some of the rational behind GenServers.</p>
<p>The way this book progresses is brilliant, it is obvious a great deal of attention was paid to the flow and ordering of the book.</p>
<p>Chapter six was very demystifying, I’ve marked it for a more attentive reread down the line BGG.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332446" 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-in-action-book-club/63088/74">Post #73</a>
	                </div>
	            </div>
              <div id="likers-container-332446" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332446"
                     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 #73"></div>
  </section>
</div>
    <div class="postbit" id="332711" data-post-id="332711">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DidactMacros" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DidactMacros
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Chapter 7, when there is an amendment to update the todo_server so that a given todo_server knows its own name,there needs to be an amendment to the cache_server’s handle_get, as the Todo.Server.start needs to take a name/key arg when fetch fails. I</p>
<p>t did not need to take such an arg before.</p>
<p>Apologies if this is already shown in the chapter, and I missed it.</p>
<p>This refers to Todo.Cache, not the changes to Todo.Server.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332711" 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-in-action-book-club/63088/75">Post #74</a>
	                </div>
	            </div>
              <div id="likers-container-332711" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332711"
                     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 #74"></div>
  </section>
</div>
    <div class="postbit" id="332983" data-post-id="332983">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DidactMacros" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DidactMacros
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Finished Chapter 7.  The chapter is brilliant imo,</p>
<p>Chapter 7 explores GenServers, working with simple state persistence external to a stateful server, and the various ways in which performance as well as availability and consistency (I believe used in the axiomatic sense) can be jeopardised via:</p>
<p><strong>Requests outpacing processing</strong>: Synchronous (via long running executions) and asynchronous (via unbound concurrency) risk<br>
<strong>Caller Blocking</strong>: Synchronous risk<br>
<strong>Long-running executions</strong>: Synchronous risk, GenSever timeout</p>
<p>The book looks at various solutions such as reply (and thus code execution) deferment and<br>
pooling.</p>
<p>A very effective way to get familiar with GenServers, necessary considerations and some great associated design practices.</p>
<p>Each new chapter has been better than the last, covering a serious topic concisely and effectively, as well as, providing practice challenges that are relevant to the material and represent an opportunity to obtain a working understanding of the chapter..</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="332983" data-batch-url="/posts/batch_likers">
                        3
                      </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-in-action-book-club/63088/76">Post #75</a>
	                </div>
	            </div>
              <div id="likers-container-332983" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="332983"
                     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 #75"></div>
  </section>
</div>
    <div class="postbit" id="333122" data-post-id="333122">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jnissar" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jnissar
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Very late to the party here but just read through Chapter 1, I find the value proposition stated here super compelling. For me, I used to work on this complicated multiservice architecture in Kotlin and I remember thinking to myself at the time that we really should have a language that bakes in multiservice concepts. That language seems to be Elixir to me.</p>
<p>Another thing I find compelling is that the unique package of benefits that Elixir offers is perfectly for producing a reasonably scalable application with less effort than something like Ruby on Rails.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="333122" 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-in-action-book-club/63088/77">Post #76</a>
	                </div>
	            </div>
              <div id="likers-container-333122" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="333122"
                     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 #76"></div>
  </section>
</div>
    <div class="postbit" id="333132" data-post-id="333132">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry for the long gap, lots had happened.</p>
<p>Anyways, I’m back with Chapter 4.</p>
<p>This was a pretty good chapter especially for folks are new to Elixir. Most of the discussions are what you’d expect from a chapter (in any language) about abstraction.</p>
<p>One thing I did, and I would encourage folks who are trying this book for the first time to do, is, please try out all the codes, and the exercise. Coming from OOP land, I used to not like not being able to do a <code>my_list.append(0, 1)</code> and instead think with <code>List.append(my_list, 0, 1)</code>. Didn’t take more than two modules for me to appreciate this. This way pairs with immutability perfectly, and also makes the code very well navigable. This is also true when composing modules, trying out the awesome Todo list example and adding slight variations or features would offer “A-ha moments” much faster.</p>
<p>Protocols formed the final seciton of chapter 4. It’s a very nice abstraction artifact when implemented right (no pun intended). I don’t recall ever having to create my own protocol, but I sure <code>defimpl</code>-ed a lot of those!</p>
<p>Modules, functions and forming abstractions out of the two takes up the crux of this chapter. And a lot about Elixir syntax gets cleared upon reading this. And rightfully this is the chapter that “soft” ends sequential Elixir and paves way for Concurrent Elixir.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="333132" data-batch-url="/posts/batch_likers">
                        3
                      </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-in-action-book-club/63088/78">Post #77</a>
	                </div>
	            </div>
              <div id="likers-container-333132" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="333132"
                     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 #77"></div>
  </section>
</div>
    <div class="postbit" id="333152" data-post-id="333152">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I also finished chapter 5. But I will go up and catch up with the review of y’all and see if my learning gets a free upgrade <img src="https://forum.elixirforum.com/images/emoji/apple/pray.png?v=15" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"></p>
<p>I will be back with my feedback later in the day. I feel this thread is destined to become an amazing companion to this book!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="333152" 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-in-action-book-club/63088/79">Post #78</a>
	                </div>
	            </div>
              <div id="likers-container-333152" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="333152"
                     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 #78"></div>
  </section>
</div>
    <div class="postbit" id="334012" data-post-id="334012">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Time for some recaps, again.</p>
<p>Worked through chapters 6 and 7.</p>
<p>Chapter 6 is about GenServers which I allready had read about and what you will stumple upon in Elixir land on many occassions. The construction of the GenServer implementation proceeding from the Server Processes of the previous chapters helped me a lot to understand what is going on in GenServer, where only has been a clue before.</p>
<p>Chapter 7 introduces Mix, Elixir’s project management tool, which seems like a combination of Bundler, Gem, and Rake for people being used to Ruby. Very intuitive and going smooth so far. There is also an introduction to testing and persisting data.<br>
The pros and cons of different process architectures are broached to get a feeling, which kind of requirements should be designed in what manner to avoid bottlenecks or errrors. The tasks given help to internalize the learned and to check, if everything is understood correctly. They helped me a lot and I can recommend to write your own code from the beginning, instead of just using Saša’s solutions. So, you can extend your code from chapter to chapter.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="334012" data-batch-url="/posts/batch_likers">
                        3
                      </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-in-action-book-club/63088/82">Post #81</a>
	                </div>
	            </div>
              <div id="likers-container-334012" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="334012"
                     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 #81"></div>
  </section>
</div>
    <div class="postbit" id="334322" data-post-id="334322">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DidactMacros" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DidactMacros
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>EDIT: <em>References to Chapter 9  emended to Chapter 10</em><br>
Wanted to post this for those working on Chapter 10’s exercise.</p>
<p>I did not like my initial answer to Chapter 10’s exercise with respect to the :ets implementation for simple registries.</p>
<p>I did not understand why using <code>Process.flag</code> in the <code>register/1</code> function prior to <code>:ets.new_entry</code> would result in exits being captured in a way that could be handled by the server process as per <a class="mention" href="/u/sasajuric" rel="nofollow">@sasajuric</a> delineation (I’m still not sure on that facet btw). However, my inital alternative to that was to keep the Process.flag in init and have the module call a <code>GenServer.cast @mod, {:register, pid}</code>, having the resultant <code>handle_cast</code> call <code>Process.link pid</code>.</p>
<p>I felt like this may have created a bottleneck, though an ostensibly wide one, out of the registry process, since it was once again burdened with some degree of registration processing.</p>
<p>I could not think of how else to get the process to handle :EXIT messages, I wanted to link the Processes from the client end using <code>Process.link(Process.whereis(@mod))</code> within the ETSR.register/1 function, but this was ineffective at first, which was not surprising as this just linked the registry process to the caller…and I was calling this from the shell!</p>
<p><strong>Handles exits by ets registered process, but requires some handling of registrations by GenServer:</strong></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule ETSR do # (ETSR is short for ets registry)
  use GenServer
  @mod __MODULE__

  def start() do
    GenServer.start(@mod, nil, name: @mod)
  end

  def register({pid, name}) do
    case Process.alive?(pid) do
      true -&gt;
        GenServer.cast(@mod, {:register, pid})
        :ets.insert_new(@mod, {name, pid})
      _ -&gt;
        IO.puts("Process not active")
    end
  end

  def whereis(name) do
    :ets.lookup(@mod, name)
  end

  @impl GenServer
  def init(_) do
    :ets.new(@mod, [:named_table, :public])
    Process.flag(:trap_exit, true)
    {:ok, %{}}
  end

  @impl GenServer
  def handle_cast({:register, pid}, _) do
    Process.link(pid)
    {:noreply, nil}
  end

  @impl GenServer
  def handle_info({:EXIT, pid, _reason}, state) do
    :ets.match_delete(@mod, {:_, pid})
    {:noreply, state}
  end
end
</code></pre>
<p>Then, finally and thankfully, the truth of the exercise dawned on me.</p>
<p>The process itself is to call the ETSR.register({pid, :name}), rather than the call being made from the shell. I’m not sure why I thought that these calls were to be made from the shell, but I’m thankful to have understood the question properly now.</p>
<p><strong>Working implementation without bottleneck:</strong></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule ETSR do
  use GenServer
  @mod __MODULE__

  def start() do
    GenServer.start(@mod, nil, name: @mod)
  end

  def register({pid, name}) do
    case Process.alive?(pid) do
      true -&gt;
        Process.whereis(@mod)
        |&gt; Process.link
        :ets.insert_new(@mod, {name, pid})
      _ -&gt;
        IO.puts("Process not active")
    end
  end

  def whereis(name) do
    case :ets.lookup(@mod, name) do
      [] -&gt; nil
      result -&gt; result
    end
  end

  @impl GenServer
  def init(_) do
    :ets.new(@mod, [:named_table, :public])
    Process.flag(:trap_exit, true)
    {:ok, %{}}
  end

  @impl GenServer
  def handle_info({:EXIT, pid, _reason}, state) do
    :ets.match_delete(@mod, {:_, pid})
    {:noreply, state}
  end
end
</code></pre>
<p>Still not entirely sure why we are to place and Process.flag(:trap_exit, true) in the register/1 function, when I tried that approach (probably incorrectly) the exits were not being handled.</p>
<p><strong>This is the test I performed on the working version:</strong></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(1)&gt; ETSR.start
{:ok, #PID&lt;0.116.0&gt;}
iex(2)&gt; pid1 = spawn(fn -&gt; ETSR.register({self(), :proc1})
...(2)&gt; Process.sleep 10_000
...(2)&gt; end)
#PID&lt;0.117.0&gt;
iex(3)&gt; ETSR.whereis :proc1
[proc1: #PID&lt;0.117.0&gt;]
iex(4)&gt; ETSR.whereis :proc1
nil  #After 10 seconds
</code></pre>
<p>Just wanted to post this in case anyone is pulling their hair out over that exercise due to a silly misunderstanding.</p>
<p>I take pid and match to pid1 just so I can check <code>Process.alive? pid1</code>, however, I did not need to. I may try the benchmarks later BGG.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="334322" 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-in-action-book-club/63088/83">Post #82</a>
	                </div>
	            </div>
              <div id="likers-container-334322" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="334322"
                     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 #82"></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/63088/load_more?page=9">Load more posts (16 remaining)</a>
</div></template></turbo-stream>