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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Definitely pass the data around. If you use global configuration (e.g. application env) it means<br>
you have less flexibility, you only have one configuration and so you can’t configure <em>this</em><br>
connection with X and <em>that</em> connection with Y.</p>
<p>As others have mentioned you likely have some startlink/init/connect/new/whatever function, so accept configuration there and pass it around to further calls. And if passing options is annoying to the users of the library they can (and often should) wrap the library with their own module.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134766" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-134766" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134766"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="134768" data-post-id="134768">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="LostKobrakai" data-post="10" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>Unless you have critical state to keep around I’d try to stay with a simple restart when changes need to be applied.</p>
</blockquote>
</aside>
<p>Well, since this handle is a <code>Reference</code> to a NIF resource then I’m weary of restarting. I prefer having a runtime-updatable configuration as you called it and it just takes effect for all work done under the NIF handle after the config is modified. As per my two above examples: modifying the execution timeout or batch size count are quite okay options to modify as you go. They are not some mythical gospels so big and powerful that the <code>GenServer</code> must absolutely be restarted to cope with their change. If I am missing something here, do let me know though!</p>
<aside class="quote no-group quote-modified" data-username="LostKobrakai" data-post="10" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>…but I’m not really a fan of using a process, which does only store config. If I want to keep config around I’d much rather put it in the application env and have it optimized for read concurrency than putting it in a process to have access to it serialized.</p>
</blockquote>
</aside>
<p>The library definitely does <em>not</em> need <code>GenServer</code>s per se. It’s just that I view them as a very sensible default way to organize your work in the case of e.g. your application uses 15 sqlite databases. And each <code>GenServer</code> will hold (a) configuration and (b) the NIF resource <code>Reference</code>. In other words, the entire vanilla data structure that you otherwise have to pass around.</p>
<p>If we were working together on such a PR, would you press your point that optional OTP primitives in these cases shouldn’t be a part of a library? I am curious. I view automatic organisation of sqlite database handles via <code>GenServer</code>s as a pretty handy mechanism, it’s really minimal and is strictly opt-in. (I agree that just carrying a structure around is the best default vanilla approach and that’s what I am going to do first. The OTP stuff is going to be a small, hopefully useful, extra.)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134768" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-134768" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134768"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="134769" data-post-id="134769">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Rebar3" data-username="tristan" data-post="11" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tristan/48/12307_2.png" class="avatar"> tristan:</div>
<blockquote>
<p>I can’t say I’ve seen this much in Elixir so I may be off base here but in Erlang we put defaults in the <code>.app</code> / <code>.app.src</code> file under the <code>env</code> key. You can do the same with the <code>application</code> configuration in your <code>mix.exs</code> .</p>
</blockquote>
</aside>
<p>Interesting, haven’t looked at how Erlang does it, thanks! Learned something.</p>
<p>As for the application configuration, that’s what I am trying to establish here – can I do away with it altogether? I view all options related to an opened sqlite database as specific for the instance, not global. And they’ll have sensible defaults of course.</p>
<aside class="quote group-Rebar3" data-username="tristan" data-post="11" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tristan/48/12307_2.png" class="avatar"> tristan:</div>
<blockquote>
<p>(1) should never be used :). Not that the pdict should never be used, just almost never, but for configuration I think it is safe to say just “never”.</p>
</blockquote>
</aside>
<p>I am quite inexperienced in that area. Why is process dictionary almost never applicable in your eyes? As for configuration, yeah, I got to the same conclusion – looks like surprise mechanics nobody wants: you are calling a library function and boom, you now have state in the process dictionary. Definitely wouldn’t like to have that done to me.</p>
<aside class="quote group-Rebar3" data-username="tristan" data-post="11" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tristan/48/12307_2.png" class="avatar"> tristan:</div>
<blockquote>
<p>Also your (2) and (3) aren’t mutually exclusive. If you have an application that must start servers you likely want to give the user a way to start them in their own supervision tree and have them pass in configuration to the start_link of whatever they are starting from your application.</p>
</blockquote>
</aside>
<p>Yep, I am going to do just that – make my own <code>GenServer</code> that is able to get initialised with a database and its options plus is pluggable under any <code>Supervisor</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134769" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-134769" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134769"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="134770" data-post-id="134770">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="12" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>Definitely pass the data around. If you use global configuration (e.g. application env) it means<br>
you have less flexibility, you only have one configuration and so you can’t configure <em>this</em><br>
connection with X and <em>that</em> connection with Y.</p>
</blockquote>
</aside>
<p>Absolutely. After reading the rationale linked in the Elixir 1.9 announcement, I found myself nodding at every phrase. And you summarised it quite well, too.</p>
<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="12" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>As others have mentioned you likely have some startlink/init/connect/new/whatever function, so accept configuration there and pass it around to further calls. And if passing options is annoying to the users of the library they can (and often should) wrap the library with their own module.</p>
</blockquote>
</aside>
<p>Well, a standard pluggable <code>GenServer</code> is in my eyes good enough for convenience in organising several databases under a <code>Supervisor</code>, be it static or dynamic. Indeed, if that’s not good enough for somebody, they have all the tools in their hands to roll their own solution.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134770" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-134770" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134770"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="134774" data-post-id="134774">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="dimitarvp" data-post="13" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Well, since this handle is a <code>Reference</code> to a NIF resource then I’m weary of restarting. […] If I am missing something here, do let me know though!</p>
</blockquote>
</aside>
<p>I’d say this can be reason enough to not want to restart a process.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134774" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-134774" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134774"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="134775" data-post-id="134775">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="13" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>The library definitely does <em>not</em> need <code>GenServer</code> s per se. It’s just that I view them as a very sensible default way to organize your work in the case of e.g. your application uses 15 sqlite databases.</p>
</blockquote>
</aside>
<p>I’d compare it to ETS. There you also configure it once and get a reference back, which you then pass around to use. But also ETS is never reconfigured and doesn’t need configuration once initialized. I’d certainly try to explore the non-process version.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134775" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-134775" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134775"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="134778" data-post-id="134778">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="LostKobrakai" data-post="17" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>I’d certainly try to explore the non-process version.</p>
</blockquote>
</aside>
<p>Totally agree, if you don’t need a process, don’t create one! As you all may know, <a href="https://github.com/ericmj/mint" rel="noopener nofollow ugc">Mint</a> is following a process-less architecture and that’s definitely a great example to look at (and blog posts, talks etc associated with it). Shameless plug: In <a href="https://github.com/elixir-ecto/myxql" rel="noopener nofollow ugc">MyXQL</a> even though the public API is so to speak stateful (by way of using db_connection), under the hood there’s a <a href="https://github.com/elixir-ecto/myxql/blob/master/lib/myxql/client.ex" rel="noopener nofollow ugc">separate module</a> that the db_connection callback module calls into - and that one is process-less and thus much more easy to understand, test, debug, and generally more usable in different contexts.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134778" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-134778" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134778"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="134781" data-post-id="134781">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So you guys wouldn’t include any OTP wiring in a library and would point the users at <code>:ets</code> or <code>Registry</code> if they want to manage many of those native handles?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134781" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-134781" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134781"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="134782" data-post-id="134782">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tristan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tristan/120/12307_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tristan
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Rebar3 Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="14" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>As for the application configuration, that’s what I am trying to establish here – can I do away with it altogether? I view all options related to an opened sqlite database as specific for the instance, not global. And they’ll have sensible defaults of course.</p>
</blockquote>
</aside>
<p>Yea, you likely can. I tend to provide both options. You are working with sqlite in this case so maybe similar to my <code>pgo</code> library, <a href="https://github.com/erleans/pgo#use" class="inline-onebox" rel="noopener nofollow ugc">GitHub - erleans/pgo: Erlang Postgres client and connection pool · GitHub</a> – configuration is specific to a pool, so they can be separated in the config file that way, allowing the option of starting them on boot or passing a config <code>pgo_pool:start_link</code> in a supervisor.</p>
<p>I do the same with grpcbox server and client <a href="https://github.com/tsloughter/grpcbox#using-a-service-client" class="inline-onebox" rel="noopener nofollow ugc">GitHub - tsloughter/grpcbox: Erlang grpc on chatterbox · GitHub</a></p>
<p>But I have yet to decide if this is good design in Erlang or Elixir, so interested in reading this thread. It feels like I shouldn’t provide different way to start services and should force the user to always start in their own supervisor…</p>
<p>As for the pdict, one reason to not use it is that it is confusing and harder to read code when state is hidden there. It is much easier to understand what is going on (and to test the code) when state is explicitly passed in and returned from functions.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134782" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-134782" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134782"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="134787" data-post-id="134787">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Rebar3" data-username="tristan" data-post="20" data-topic="23663">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tristan/48/12307_2.png" class="avatar"> tristan:</div>
<blockquote>
<p>But I have yet to decide if this is good design in Erlang or Elixir, so interested in reading this thread. It feels like I shouldn’t provide different way to start services and should force the user to always start in their own supervisor…</p>
</blockquote>
</aside>
<p>I feel like options aren’t bad at all. I’m using <code>ex_cldr</code> and <code>ecto</code> in their non dynamic functions compiled into my module modes and I’m quite happy to use those as e.g. <code>MyRepo.func</code> and not <code>Ecto.Repo.func(MyRepo, …)</code>, but I can also see the other side of the coin where this is limiting (e.g. commanded is a lib, which only supports a single “instance” at the moment).</p>
<aside class="quote no-group" data-username="dimitarvp" data-post="19" data-topic="23663" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>So you guys wouldn’t include any OTP wiring in a library and would point the users at <code>:ets</code> or <code>Registry</code> if they want to manage many of those native handles?</p>
</blockquote>
</aside>
<p>I’d at least expect that users might already have some infrastructure in their applications to handle the many databases in their business context. Mustn’t be, but it’s nice to plug things into the places they belong instead of having similar setups in many places. For the rest you could still provide some genservers if you really want.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="134787" 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/advice-how-to-go-about-library-configuration-from-elixir-1-9-and-on/23663/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-134787" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="134787"
                     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 #20"></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/23663/load_more?page=3">Load more posts (13 remaining)</a>
</div></template></turbo-stream>