<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmad Elassuty</title>
    <description>The latest articles on DEV Community by Ahmad Elassuty (@ahmadelassuty).</description>
    <link>https://dev.to/ahmadelassuty</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F373182%2F8e8c8854-5e44-43dd-99b2-a4cbcaa6be4a.jpeg</url>
      <title>DEV Community: Ahmad Elassuty</title>
      <link>https://dev.to/ahmadelassuty</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmadelassuty"/>
    <language>en</language>
    <item>
      <title>Accelerate Domain Learning: Explore Application Dependencies with RailsGraph</title>
      <dc:creator>Ahmad Elassuty</dc:creator>
      <pubDate>Tue, 30 May 2023 22:57:05 +0000</pubDate>
      <link>https://dev.to/ahmadelassuty/accelerate-domain-learning-explore-application-dependencies-with-railsgraph-5alh</link>
      <guid>https://dev.to/ahmadelassuty/accelerate-domain-learning-explore-application-dependencies-with-railsgraph-5alh</guid>
      <description>&lt;p&gt;😥 One of the major challenges of data migrations in large codebases is identifying dependencies on the models being migrated. Lack of comprehensive knowledge about the codebase further complicates this task.&lt;/p&gt;

&lt;p&gt;📦 Using &lt;a href="https://github.com/ahmad-elassuty/rails_graph"&gt;RailsGraph&lt;/a&gt;, you could generate an interactive graph that is easy to explore! To learn more please check my blog post.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://ahmad-elassuty.medium.com/accelerate-domain-learning-explore-application-dependencies-with-railsgraph-26329aed9f09" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--j8ze0huo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/v2/resize:fit:1155/1%2ANxErQIdi4YrBmm8EjPnJUw.png" height="542" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://ahmad-elassuty.medium.com/accelerate-domain-learning-explore-application-dependencies-with-railsgraph-26329aed9f09" rel="noopener noreferrer" class="c-link"&gt;
          Accelerate Domain Learning: Explore Application Dependencies with RailsGraph | by Ahmad Elassuty | May, 2023 | Medium
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          RailsGraph: Interactive and queryable graph, making it easy to explore, and unlock insights from complex applications with ease!
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--41Zxt9kW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/v2/1%2Am-R_BkNf1Qjr1YbyOIJY2w.png" width="32" height="32"&gt;
        ahmad-elassuty.medium.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;👀 Spoiler alert&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://player.vimeo.com/video/831676396" width="710" height="399"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>graph</category>
      <category>rails</category>
      <category>ruby</category>
      <category>erd</category>
    </item>
    <item>
      <title>Intuitive Ruby Event Router</title>
      <dc:creator>Ahmad Elassuty</dc:creator>
      <pubDate>Mon, 01 Feb 2021 23:04:14 +0000</pubDate>
      <link>https://dev.to/ahmadelassuty/intuitive-ruby-event-router-4g5g</link>
      <guid>https://dev.to/ahmadelassuty/intuitive-ruby-event-router-4g5g</guid>
      <description>&lt;p&gt;This article explains the motives behind building ruby &lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt; gem. It starts with an example to demonstrate the problem. Then presents how &lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt; can help solve the problem in a clean easy way.&lt;/p&gt;




&lt;p&gt;Imagine we are building GitHub Pull Request (PR) page where you can update the PR description, title and state. We are also going to keep track of all of these updates on the PR activity timeline, and make sure we notify the reviewers of any change. For demonstration purposes, the update action might look like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We first persist the user values into the database. And that is essentially what this action is responsible for. Then, we are performing multiple actions one after another. However, the update action itself should not be responsible for the side effects of a pull request being updated.&lt;/p&gt;

&lt;p&gt;Lets inspect what those actions are doing. They are acting upon the fact that a pull request got updated. Each has a different responsibility and work to do. Which means they should be isolated in terms of execution. If one failed, the rest should not. We also need to retry each action independently and take the necessary steps on failure.&lt;/p&gt;

&lt;p&gt;One way to refactor this, is to emit a single domain event PullRequestUpdated and we create one consumer per each use case. Lets do a bit of refactoring…&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;and &lt;code&gt;PullRequestUpdated&lt;/code&gt; event class can be defined as:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We moved the logic to another class and that approach has couple of benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The new class has only one responsibility, which is to deliver the event to specific set of handlers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Our controller now is smaller and easier to test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to test the PullRequestUpdated class independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The event logic is now reusable, so if we want to emit the same event when a commit is submitted, well you know what to call.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The controller still needs to wait for the event to be delivered to its destinations, right? But for that specific case, we want to return the response back once the update is finished. So lets create a new publish_async method and use it in the controller instead. We can use a background processing library like &lt;a href="https://github.com/mperham/sidekiq"&gt;Sidekiq&lt;/a&gt; but to keep it simple lets use Ruby &lt;a href="https://ruby-doc.org/core-2.5.0/Thread.html"&gt;Thread&lt;/a&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Since the event is processed in background, the previous approach avoids having multiple points of failure while processing the update action.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt; helps you build a similar flow. It supports multiple delivery adapters out of the box and it is also easy to extend and add new delivery backends, e.g RabbitMQ. The controller stays the same and the event can be changed to:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt; will handle the publishing logic for your events. Also it abstracts the delivery backend which you can change when your app needs an upgrade! Here are a few features of &lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Publish events in sync or async way.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deliver events to their destinations using sync or async adapters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build events with arbitrary arguments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Oj serializer you can maintain the arguments structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enrich events with extra payload before they are delivered to their destinations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More to come so make sure to check the repo &lt;a href="https://github.com/ahmad-elassuty/event_router/wiki"&gt;Wiki&lt;/a&gt; for more features and details.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me know what you think about &lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;EventRouter&lt;/a&gt;. You can start a discussion on &lt;a href="https://github.com/ahmad-elassuty/event_router/discussions"&gt;EventRouter Discussions&lt;/a&gt; page. Bug reports and pull requests are also welcome on GitHub &lt;a href="https://github.com/ahmad-elassuty/event_router"&gt;repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Constructive feedback is always welcome. Hope it helps! 👋&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>eventdriven</category>
      <category>opensource</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
