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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Ripster" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Ripster/120/8869_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Ripster
                    <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>I’ve been messing around with <code>require</code> quite a bit and still can’t seem to get it to work. What seems to be happening is <code>Mix.Tasks.Xref.calls()</code> comes up empty on first compile. If I edit what seems to be just about any file related to the router and then recompile, it comes up with a list of callers like I expect.</p>
<p>Doing a <code>require</code> on the router module, packet module, or even requiring the actual packet definition in the router does not seem to get it working.</p>
<p>I’ve started looking through the code on github for <code>mix xref callers</code> because it seems to always list out the dependency’s of <code>Packet</code> correctly (or at least the files that use it). I’m hoping that will shed some light on a possible solution.</p>
<p>I have to admit I’m still fairly new to elixir. If you think creating a compiler plugin is a good way to go I would love to know where I can find related documentation so I can learn more. If you don’t mind can you help point me in the right direction here?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76200" data-batch-url="/posts/batch_likers">
                        0
                      </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/function-generation-dynamic-dispatch/13325/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-76200" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76200"
                     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="76250" data-post-id="76250">
  <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="Ripster" data-post="12" data-topic="13325">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ripster/48/8869_2.png" class="avatar"> Ripster:</div>
<blockquote>
<p>I’ve been messing around with require quite a bit and still can’t seem to get it to work. What seems to be happening is Mix.Tasks.Xref.calls() comes up empty on first compile. If I edit what seems to be just about any file related to the router and then recompile, it comes up with a list of callers like I expect.</p>
</blockquote>
</aside>
<p>That says they are either on the wrong file or not put in early in the compilation process.</p>
<aside class="quote no-group" data-username="Ripster" data-post="12" data-topic="13325">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ripster/48/8869_2.png" class="avatar"> Ripster:</div>
<blockquote>
<p>I have to admit I’m still fairly new to elixir. If you think creating a compiler plugin is a good way to go I would love to know where I can find related documentation so I can learn more. If you don’t mind can you help point me in the right direction here?</p>
</blockquote>
</aside>
<p>Honestly I’m thinking this is just a bit odd of a design overall regardless, I would probably just hardcode those all in as it’s not like they are going to be changing often anyway and adding new ones is easy.  ^.^;</p>
<p>If you really want to go the more complex route (which be sure that you do), I’d really say take a look at my afore-mentioned protocol_ex, your solution might look similar to (typed in-post so likely has syntax errors):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Define the main module:
import ProtocolEx
defprotocolEx Blah do
  def parse(header, data) # Since no fallback body then this must be handled by the implementations

  def parse(&lt;&lt;header::integer-little-8, data::bytes), do: parse(header, data)
end
</code></pre>
<p>Then just write the implementations like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import ProtocolEx
defimplEx Login, 1, for: Packet do
  def parse(_, data) do
    # whatever you need here...
  end
  # You could add more `parse/2` callbacks here that handle other numbers as well if you want,
  # or make other implementations like below
end
</code></pre>
<p>Then maybe another one somewhere else:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import ProtocolEx
defimplEx Chat, 2, for: Packet do
  def parse(_, data) do
    # whatever you need here...
  end
end
</code></pre>
<p>Etc…</p>
<p>And of course you can add a run function and all sorts as well too.  Whatever.  (If you need new features in protocol_ex, just ask).  It has a lot of other abilities and optimizations and such you can do as well, but as-is it already does what you posted that you want.</p>
<p>Don’t forget to add the compile for protocol_ex to the <code>mix.exs</code> file as per the documentation too (or you can always handle it manually too if you want).</p>
<p>(EDIT:  Updated examples to be actual code rather than just placeholder 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="76250" 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/function-generation-dynamic-dispatch/13325/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-76250" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76250"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="76283" data-post-id="76283">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Ripster" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Ripster/120/8869_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Ripster
                    <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>I’ll likely either hard code or use ProtocolEx as you’ve suggested. ProtocolEx does look really nice, the only reason I’ve been shying away from it is this is a learning experience for me.</p>
<p>Prior to this project I didn’t even know the difference between <code>use</code>, <code>import</code>, and <code>require</code>. As I’m reading and learning I’m trying to use everything I’m learning in some way even if it’s not the most appropriate for the situation. I need to get it to sink in somehow! <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I appreciate everyone’s patience and I’ve been really surprised by how helpful and knowledgeable the Elixir community is. Thank you for the examples, links, and information you’ve provided. It’s been a huge help.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="76283" 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/function-generation-dynamic-dispatch/13325/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-76283" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76283"
                     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="76284" data-post-id="76284">
  <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="Ripster" data-post="14" data-topic="13325">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ripster/48/8869_2.png" class="avatar"> Ripster:</div>
<blockquote>
<p>I appreciate everyone’s patience and I’ve been really surprised by how helpful and knowledgeable the Elixir community is. Thank you for the examples, links, and information you’ve provided. It’s been a huge help.</p>
</blockquote>
</aside>
<p>We try, don’t hesitate to ask!  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_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="76284" data-batch-url="/posts/batch_likers">
                        0
                      </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/function-generation-dynamic-dispatch/13325/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-76284" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="76284"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>