<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hasnat Raza on Medium]]></title>
        <description><![CDATA[Stories by Hasnat Raza on Medium]]></description>
        <link>https://medium.com/@hasnatraza.dev?source=rss-810381c8c9a2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*K8ZTx869wVk5fTeeom4hSg.jpeg</url>
            <title>Stories by Hasnat Raza on Medium</title>
            <link>https://medium.com/@hasnatraza.dev?source=rss-810381c8c9a2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 03:49:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hasnatraza.dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rails Cron Jobs — Task Scheduling In Rails]]></title>
            <link>https://medium.com/@hasnatraza.dev/rails-cron-jobs-task-scheduling-in-rails-f7662106feaa?source=rss-810381c8c9a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7662106feaa</guid>
            <category><![CDATA[cronjob]]></category>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[hasnat-raza]]></category>
            <dc:creator><![CDATA[Hasnat Raza]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 13:42:20 GMT</pubDate>
            <atom:updated>2023-06-19T13:42:20.256Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rails Cron Jobs — Task Scheduling In Rails</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*yQHMKuxDQUFjzJidiCok7g.jpeg" /></figure><p>Have you ever found yourself in a situation where you needed to schedule tasks to run automatically? It could be things like sending daily emails or regularly syncing data with an external API. That’s where Cron jobs come in handy. They allow you to automate these tasks effortlessly. In this blog, I’ll introduce you to Cron, a fundamental software integrated into Unix/Linux systems for running scheduled tasks. I’ll also provide a quick guide on using the Ruby Whenever Gem to easily deploy Cron jobs specifically in Rails applications.</p><h3>What Are Cron Jobs?</h3><p>Before we dive into the usage of Cron Jobs in Rails with the Whenever Gem, let me provide you with a simple explanation of what a cron job is. (I’ll be writing a detailed article on this topic soon)</p><p>In basic terms, Cron is a command line tool that allows you to schedule and run recurring tasks at specific times. These tasks are called cron jobs. Since Cron is built into Linux/Unix systems, you don’t need to install any additional dependencies. Typically, cron jobs are written in a file called crontab, which stands for Cron Table. The syntax of a crontab task/cron job consists of five numbers separated by spaces, representing when a task should be executed, followed by the script to run. The syntax should look like this:</p><pre># ┌───────────── minute (0 - 59)<br># │ ┌───────────── hour (0 - 23)<br># │ │ ┌───────────── day of month (1 - 31)<br># │ │ │ ┌───────────── month (1 - 12)<br># │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;<br># │ │ │ │ │ 7 is also Sunday on some systems)<br># │ │ │ │ │<br># │ │ │ │ │<br># * * * * * command to execute</pre><p>The diagram below illustrates the syntax well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*ifR19LYELfM17Ry1PceE-A.png" /></figure><p>While it is possible to schedule Rails jobs using the crontab, it can feel outdated and cumbersome. The process involves using the command:</p><pre>0 * * * * &#39;cd path/to/project &amp;&amp; bundle exec some_task&#39;</pre><h3>Whenever Gem</h3><p>Now, let me explain a better way to handle cron jobs in Rails. Instead of dealing with the traditional and somewhat messy crontab, there’s a Ruby Gem that makes scheduling cron jobs much simpler and more elegant. The go-to gem for this purpose is called Whenever.</p><p>Whenever is a gem that streamlines the process of setting up cron jobs. Rather than manually editing the crontab, you can write your cron jobs in Ruby code using Whenever. This gem takes care of updating the crontab for you. We can</p><h3>Setting Up Whenever Gem</h3><p>Now let’s set up the gem in our application and use it. We will start with the installation of the gem. Just include the gem in your Gemfile, as shown below, and run bundle install.</p><pre>gem &#39;whenever&#39;, require: false</pre><p>Now let’s initialize the gem by running</p><pre>bundle exec .wheneverize</pre><p>When you run the .wheneverize command, it will create a file named schedule.rb in the config directory, specifically config/schedule.rb. This file is responsible for defining the timing for job execution and specifying the Rake task to be executed.</p><p>Now once the gem is set up, let’s move toward actually scheduling a job. For that, you will start by creating a Rake task.</p><pre>rails g task batch send_messages</pre><p>Once the rake task is created, the file for the task can be found in lib/tasks/sample.rb. Now, let&#39;s add a functionality to send emails in it.</p><pre># lib/tasks/send_messages.rake<br><br>namespace :messages do<br>  desc &quot;Send messages to users&quot;<br>  task send: :environment do<br>    User.all.each do |user|<br>      MessageMailer.send_message(user.email).deliver_now<br>      puts &quot;Message sent to #{user.email}&quot;<br>    end<br>  end<br>end</pre><p>Once we have added the logic to our Rake task, we can register it in the schedular.rb file. In our example, let&#39;s give it 1 minute.</p><pre>every 1.minute do<br>    rake &#39;messages:send&#39;<br>end</pre><p>Then we will update our crontab and will add the job there by running the command</p><pre>whenever --update-crontab</pre><p>Your Cron Job has been successfully set up. It has been scheduled to run at a specified time. Additionally, you have the option to clear your crontab using the command whenever --clear-crontab and view the crontab using crontab -l.</p><h3>Sidekiq-Cron Gem</h3><p>Sidekiq-cron is an add-on for Sidekiq, a job processing library. Sidekiq-cron allows you to schedule jobs to run at specific times or intervals. It’s important to note that Sidekiq-cron is not an official gem provided by Sidekiq.</p><p>In Sidekiq, scheduling jobs is typically considered an enterprise-level feature that may require a paid license. However, if you don’t want to spend money on the enterprise version, Sidekiq-cron is a suitable alternative for you.</p><p>In simpler terms, Sidekiq-cron is a tool that enables you to schedule jobs within Sidekiq without having to pay for the official enterprise version. It provides similar scheduling capabilities, allowing you to specify when and how often your jobs should run.</p><h3>Setting Up Sidekiq-Cron Gem</h3><p>Now let’s set up the Sidekiq-Cron gem in our application. We will start with the installation of the gem. Just include the gem in your Gemfile, as shown below, and run bundle install.</p><pre>gem &#39;sidekiq-cron&#39;</pre><p>Then create a schedule.yml in the config/ directory, just like it was done in Whenever Gem&#39;s case. Although, unlike Whenever, Sidekiq-Cron does not provide a scaffolding mechanism to initialize the file. We will also be creating another file in config/initializers with the name sidekiq.rb with the following content in it</p><pre>schedule_file = &quot;config/schedule.yml&quot;<br>if File.exist?(schedule_file) &amp;&amp; Sidekiq.server?<br>   Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)<br>end</pre><p>After this our initial configuration is complete. Now it’s time to create the actual job. For that go to the terminal and type</p><pre>rails generate job send_bulk_emails</pre><p>And then add some functionality to this code.</p><p><em>NOTE:</em> <em>For a detailed tutorial on how to set up, create and use Rails Background Jobs/Workers please refer to</em> <a href="https://medium.com/@hasnatraza.dev/rails-background-jobs-reconstruct-your-application-ccaef2860552"><em>this article</em></a><em>.</em></p><pre>class SendBulkEmailJob &lt; ApplicationJob<br>  queue_as :default<br><br>def perform(emails)<br>    begin<br>      BulkEmailService.send_emails(emails)<br>    rescue StandardError =&gt; e<br>      Rails.logger.error &quot;Error sending bulk emails: #{e.message}&quot;<br>      raise e<br>    end<br>  end<br>end</pre><p>After making the Job, run it by typing sidekiq in the terminal and add the created job to the schedular file like this:</p><pre>email_job:<br>   cron: &quot;*/5 * * * *&quot;<br>   class: &quot;SendBulkEmailJob&quot;</pre><p>To run the worker, open a new tab in the terminal. It’s important to note that the worker should continue running while the app is active. If you need to run other commands like starting the Rails server or any other tasks, make sure to switch to a different tab.</p><p>That’s all! Congratulations on creating your first sidekiq-cron job. Celebrate your accomplishment!</p><h3>Conclusion</h3><p>In summary, Cron jobs are essential for automating recurring tasks in Unix/Linux systems. The Whenever gem simplifies scheduling cron jobs in Rails applications by allowing you to write them in Ruby code and automatically updating the crontab. Sidekiq-Cron is a useful gem for scheduling jobs in Sidekiq. Both gems streamline the process of managing and executing cron jobs, improving automation and efficiency in your application.</p><p>In future articles, we’ll explore more about how Rails works behind the scenes. So make sure to stay tuned and keep learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7662106feaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails Background Jobs — Reconstruct Your Application]]></title>
            <link>https://medium.com/@hasnatraza.dev/rails-background-jobs-reconstruct-your-application-ccaef2860552?source=rss-810381c8c9a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccaef2860552</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[hasnat-raza]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Hasnat Raza]]></dc:creator>
            <pubDate>Tue, 06 Jun 2023 15:33:32 GMT</pubDate>
            <atom:updated>2023-06-08T00:30:15.435Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rails Background Jobs — Reconstruct Your Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*yQHMKuxDQUFjzJidiCok7g.jpeg" /></figure><p>Has your Rails application ever experienced a situation where it becomes slow while handling large amounts of data, sending emails, or performing other demanding computations? During those times, you probably wished for a solution that could efficiently handle these time-consuming tasks without negatively affecting the user experience. Enter Rails background jobs — they are a concept that can completely transform your development environment and can wipe out all your worries.</p><p>In this article, I will provide you with a thorough understanding of Rails Background Jobs. Whether you’re new to the concept and wondering, “What are background jobs?” or looking for guidance on how to effectively implement them in your Rails applications. Let’s begin by understanding the need for Background Jobs through a practical example of where it might be needed.</p><h3>Practical Example</h3><p>Imagine you are the owner of an e-commerce platform with loads of traffic, where numerous customers are placing orders every minute. Your business must process these orders promptly and keep up with the growing demand. However, without the help of background jobs, your application could struggle to handle the immense workload required to fulfill each order.</p><p>Consider there is a surge of orders flooding your platform, and your application needs to perform a series of complex tasks such as calculating prices, checking inventory, generating shipping labels, and sending confirmation emails. These computations would take a considerably long time if they are being implemented in an order or a flow in the same application and server, causing delays and frustrating your customers.</p><p>But fear not! This is where Rails’ background jobs come to the rescue. By leveraging the power of background jobs, you can assign these resource-intensive tasks to a separate and dedicated workforce. Think of it as an invisible army of workers tirelessly working in the background while your users navigate through your platform, unaware of the heavy computations taking place behind the scenes.</p><p>With background jobs, your application can gain the ability to efficiently handle order processing, email sending, and inventory updates without sacrificing the user experience. It ensures that your platform remains responsive and snappy, even during peak activity periods when the workload is overwhelming. Your customers can continue their shopping journey uninterrupted, while the background jobs diligently carry out their assigned tasks.</p><h3>When to use it?</h3><p>Now there is a possibility that you might be wondering that, in exactly what scenarios the background jobs should be used. Here are a few scenarios where background jobs can be used efficiently:</p><ol><li>Performing <strong>resource-intensive tasks</strong>, such as logging and tracking, by utilizing a queue and background job model, helps alleviate the heavy workload on the database.</li><li>For operations that involve reading a <strong>large amount of data</strong> for reporting purposes, even though it may take time to process and aggregate the data, it is more efficient to execute these operations with fewer requests.</li><li>In situations where there is <strong>high service latency</strong> caused by factors like slow network connectivity or peak usage periods, it is better to respond to the user with a message acknowledging the delay and requesting their patience. This approach ensures that users are aware of the ongoing processing and allows for serving more users simultaneously.</li><li>When <strong>interacting with external services</strong> that are not critical to the immediate operation, such as collecting system history or sending emails, it is advisable to handle these tasks separately. By doing so, the system can remain responsive and efficient while interacting with other sources of information.</li><li>By organizing independent jobs in a queue, the system becomes more <strong>scalable as additional worker nodes</strong> can be added to handle the workload effectively. This enables the system to handle increased demands and process jobs concurrently without sacrificing performance. The term used above i.e. <strong>Worker nodes</strong> are additional computing resources, usually separate services, processes or instances, dedicated to executing background jobs. These nodes actively listen to the job queue for incoming tasks and process them one by one. By using multiple worker nodes, the system can parallelize job execution, increasing <strong>throughput and reducing processing time</strong>.</li></ol><h3>External Dependencies</h3><p>There are several different ways to implement background jobs in Ruby on Rails. The most common approach is using a gem such as Sidekiq, Delayed Job, or many more, which provides a simple and efficient way to manage your background jobs. These gems make it easy to enqueue jobs, set priorities, and track their progress.</p><p>Sidekiq is a Ruby framework to perform background jobs. It is an open-source job scheduler written in Ruby that is very useful for handling expensive computations and processes that are better served outside of the main web application. Basically, instead of having the main web app thread handle the complex computation, you can instead punt this tedious and memory-consuming task over to your trusty Sidekiq — a background worker that allows you to execute tasks outside of the main web application thread. The image attached shows the high-level architecture of the application would look with Sidekiq &amp; Jobs/Workers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*pFHZ3nO3lp9e6mxP" /></figure><p>Sidekiq requires a <strong>web server</strong> ( Puma, unicorn e.c.t.), <strong>Redis</strong> server, and an <strong>application server</strong> to run properly. When creating a Rails application, the web and application servers are usually present already, but you might need to install Redis server manually.</p><h3>Setting Up Workers in Rails</h3><p>In Rails, background jobs are termed as either Jobs or Workers. ActiveJob calls it a Job whereas Sidekiq calls it a Worker. You can use either one. Also, note that ActiveJob does not provide access to the full set of Sidekiq options so if you want advanced customization options for your job you might need to make it a Worker.</p><p>Unlike Jobs that are provided by default, you will need to set up workers manually. So you can start by creating the workers directory and an application_worker.rb in it.</p><pre>mkdir app/workers<br>cd app/workers<br>touch application_worker.rb</pre><p>The application_worker.rb will be responsible for defining the base behavior of the workers. Although, this is completely optional and is dependent on your requirements. The file would look something like this:</p><pre># app/workers/application_worker.rb<br><br>class ApplicationWorker<br>  include Sidekiq::Worker<br><br>  # Add any common configuration or behavior for all workers here<br><br>  # Optional method<br>  def self.before_perform(*args)<br>    # You can add any shared setup or logic here<br>  end<br>end</pre><p>Once this is set up, this class will behave exactly like the built-in jobs provided by Rails. In the upcoming implementation discussed in the article, we will be using the syntax of Jobs.</p><h3>Creating Rails Background Jobs</h3><p>Before starting the creation of a background job you will need to install dependencies like Redis and Sidekiq. If you are not aware of how to do that, this <a href="https://www.digitalocean.com/community/tutorials/how-to-add-sidekiq-and-redis-to-a-ruby-on-rails-application">article</a> might help you. Now considering you have Redis and Sidekiq setup on our machine, and have a Rails application setup you can finally start creating and using background jobs. Unlike Services, the background jobs are provided by default, so you don’t have to set them up manually.</p><p>Let’s set up the configurations first. To use Active Job, specify which queueing backend you want to use in your config/application.rb file. For example, if you&#39;re using Sidekiq, you would add the following line to your configuration file:</p><pre>config.active_job.queue_adapter = :sidekiq</pre><p>Now before actually running a background job, let’s start the Sidekiq and Redis servers on different terminals. Use the following commands to start the servers:</p><pre>redis-server<br>bundle exec sidekiq</pre><p>Now consider the following scenario: You have a controller action in your application that is responsible for initiating the sending of bulk emails. To handle this functionality, you have implemented a service that handles the actual process of sending out emails. The controller code would look something like this:</p><pre>class EmailsController &lt; ApplicationController<br>  def send_bulk_emails<br>    # Retrieve email data or recipients from params or database<br>    emails = params[:emails]<br><br>    # Call the email service to send the bulk emails<br>    BulkEmailService.send_emails(emails)<br><br>    # Redirect or render a response<br>    redirect_to root_path, notice: &quot;Bulk emails sent successfully.&quot;<br>  end<br>end</pre><p>The solution mentioned above will work, but it has a potential drawback. Since the processing of bulk emails is done within the core application, it can consume a significant amount of computational power and put a heavy load on the application. As a result, the overall performance of the application may suffer.</p><p>To address this issue and improve performance, we can implement a background job mechanism. Instead of processing the bulk emails directly within the controller method, we can offload this task to a background job.</p><p>By utilizing a background job, the heavy and complex processing involved in sending bulk emails can be performed in the background, separate from the main application flow. This means that the application can continue serving user requests without being slowed down by the email processing task.</p><p>The background job can be called from the controller method, triggering the email-sending process in the background. This allows the application to handle other tasks while the emails are being processed concurrently. As a result, the overall performance of the application will improve, as the email processing is handled separately and does not impact the responsiveness of the application.</p><p>Now, to create a job we will use the rails built-in job generator:</p><pre>rails generate job send_bulk_emails</pre><p>Once we run this, a file in app/jobs will be created and the content would be somewhat like this:</p><pre>class SendBulkEmailJob &lt; ApplicationJob<br>  queue_as :default<br><br>  def perform(*args)<br>    # Do something later<br>  end<br>end</pre><p>Now once this is done let’s transfer the logic defined in the controller to the job.</p><pre>class SendBulkEmailJob &lt; ApplicationJob<br>  queue_as :default<br><br>def perform(emails)<br>    begin<br>      BulkEmailService.send_emails(emails)<br>    rescue StandardError =&gt; e<br>      Rails.logger.error &quot;Error sending bulk emails: #{e.message}&quot;<br>      raise e<br>    end<br>  end<br>end</pre><p>And the controller would now look like this:</p><pre>class EmailsController &lt; ApplicationController<br>  def send_bulk_emails<br>    # Retrieve email data or recipients from params or database<br>    emails = params[:emails]<br><br>    # Enqueue the job to send bulk emails<br>    SendBulkEmailsJob.perform_async(emails)<br><br>    # Redirect or render a response<br>    redirect_to root_path, notice: &quot;Bulk emails sent successfully.&quot;<br>  end<br>end</pre><p>Now when this action is called, it will not be performing these tasks on the main application process but will be performing them in the sidekiq server. This will not block or slow down the processing power of the main Rails application. We can use multiple methods like perform_async, perform_now, perform_later e.t.c. to call background jobs.</p><h3>Types of Rails Background Jobs</h3><p>Based on use cases, the background jobs can be categorized into two distinct types:</p><ol><li>One type of job scheduling method is known as Schedule Background Jobs, which combines the concepts of background jobs and cron jobs. In certain scenarios, we may need to implement specific functionalities at regular intervals of time. This is where background jobs become useful. To illustrate this, let’s consider a situation where we need to send bulk emails to our subscribers every week. Instead of manually triggering this task, we can automate it using background jobs. By incorporating the defined job into a scheduler, we can ensure that it runs automatically at the desired interval. To accomplish this, we use a command in the format of a cron expression: 0 0 * * 0 cd app &amp;&amp; bin/rails your_rake_task:trigger_background_jobs. Instead of writing the jobs directly, we have the option to use a Rails gem. When it comes to dealing with somewhat complicated and universally used tasks like cron jobs, there is a Ruby Gem available that makes programming them much easier and more visually appealing. There are several helpful gems in this regard, but the most commonly used and popular one is called <a href="https://github.com/javan/whenever">Whenever</a> for tasks and <a href="https://github.com/sidekiq-scheduler/sidekiq-scheduler">Sidekiq Scheduler</a> for background jobs.</li><li>Background jobs also serve as a valuable tool for performing basic asynchronous operations in Rails. These jobs are designed to run in response to specific user demands or event listeners. By offloading these tasks to the background, they can be executed independently of the main user interaction with the application, ensuring a smoother and more responsive user experience. When a user initiates an action that requires additional processing or time-consuming tasks, such as generating reports, sending notifications, or performing complex calculations, background jobs come into play. Rather than making the user wait for these operations to complete before proceeding, the tasks are delegated to the background, allowing the user to continue using the application without interruption. Event listeners also utilize background jobs to handle specific events or triggers within the application. For example, when a new user signs up, an event listener can be configured to perform certain tasks automatically, such as sending a welcome email or updating user statistics. By executing these operations asynchronously in the background, the application remains responsive and can swiftly handle other user requests or events.</li></ol><h3>Some Useful Tips</h3><ol><li>When using something like Sidekiq, it’s recommended to send only necessary information to the job. Inside the job, you can include extra instructions to find records and carry out more complex tasks. Other than that, if you make sure that your job is idempotent and transactional (meaning it can be repeated multiple times without causing issues), it will be even better.</li><li>Sometimes, you may need to run a job after a specific time, but you don’t know the exact time beforehand. In such cases, you can use the “set” keyword to fetch a particular timestamp from the database and schedule the job accordingly. This allows you to rely on a specific timeframe before the job is executed or create a custom time delay using simple Ruby code. Here’s an example code SomeJob.set(wait: 3.week).perform_later(params). This code schedules the job called “SomeJob” to be performed later, waiting for three weeks before executing. The job is given some parameters that it will use when it runs.</li><li>Active Job offers functionality to trigger specific actions at different stages of a job’s life cycle. These actions, known as callbacks, can be implemented as regular methods. To register these callbacks, you can use a convenient class method that follows a macro-style approach, similar to other callbacks used in Rails. The callbacks include: <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-before_enqueue">before_enqueue</a>, <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-around_enqueue">around_enqueue</a>, <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-after_enqueue">after_enqueue</a>, <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-before_perform">before_perform</a>, <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-around_perform">around_perform</a>, <a href="https://api.rubyonrails.org/v7.0.5/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-after_perform">after_perform</a></li></ol><h3>Conclusion</h3><p>Background Job plays a crucial role in maintaining the efficiency of your application by keeping daily loaded business logic separate from the main application. By adopting this approach, we can significantly reduce complexity within our codebase and make the application’s performance much better. We can also create cron jobs in dockerized rails applications, which will be covered in future articles.</p><p>So, stay tuned and keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccaef2860552" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails Interactors — Reconstruct Your Application]]></title>
            <link>https://medium.com/@hasnatraza.dev/rails-interactors-reconstruct-your-application-13f9fdcb4204?source=rss-810381c8c9a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/13f9fdcb4204</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[interactors]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Hasnat Raza]]></dc:creator>
            <pubDate>Tue, 30 May 2023 17:15:14 GMT</pubDate>
            <atom:updated>2023-06-06T15:37:04.725Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rails Interactors — Reconstruct Your Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*yQHMKuxDQUFjzJidiCok7g.jpeg" /></figure><p>In my previous article, we explored the purpose of service objects and their role in encapsulating external business logic, particularly when interacting with third-party APIs. However, in scenarios where we need to extract the business logic of a specific use case into an object, traditional service objects may not offer all the necessary functionalities. This is where the Rails Interactors gem comes into play. Interactors build upon the concept of service objects and provide additional features to enhance overall functionality and improve code organization.</p><p>The Rails Interactors gem offers a structured approach to handling complex use cases by breaking them down into smaller, more manageable components. These components, known as interactors, encapsulate the business logic of a particular use case. Interactors enable better separation of concerns, enhance code reusability, and improve testability.</p><h3>Initial Setup</h3><p>We will begin by setting up the Interactor Gem and then proceed with an example. The Interactor Gem can be installed by first adding this line in your application’s Gemfile.</p><pre>gem &#39;interactor&#39;</pre><p>Then, just need to run bundle install to install the Gems and their dependencies</p><pre>bundle install</pre><p>Well, that’s it! Now your application is ready to use Interactors. Now there are two different ways to create interactors:</p><p>First is by using the generator. The Gem comes with a generator that allows us to create an interactor class just by running the following command:</p><pre> rails generate interactor example_interactor</pre><p>Secondly, we can include the module. A way to create an interactor is by including the interactor module in your class and implementing a method named call. That&#39;s it! Just by following these two steps, your PORO is now an Interactor.</p><p>Finally, there is one last step to complete the setup, which is the addition of the application_interactor.rb and application_organizer.rb (Organizers covered later in this article) files. This step is optional and depends on your specific application requirements, but it is generally considered a good practice.</p><p>By creating these files, you establish a central place to define common functionality and configurations for your Interactors and Organizers. This promotes code reusability and helps maintain consistency throughout your application. In these files, you can define a base class for your Interactors that includes any shared methods or behavior. For example, you may want to add methods for error handling, logging, or authorization that apply to multiple Interactors in your application.</p><p>By separating these common functionalities into base classes, you can easily extend and customize your Interactors and Organizers as needed, while keeping the overall structure and behavior consistent.</p><p>Remember that adding these files is optional, and you can always start without them. However, as your application grows and you find yourself reusing certain functionality across Interactors and Organizers, introducing these files can help streamline your development process and improve code maintainability.</p><p>The files should look something like this:</p><p><strong>Application Interactor</strong></p><pre>class ApplicationInteractor<br>  include Interactor<br>    class &lt;&lt; self<br>        def call(context = {})<br>          context ||= {}<br>          # code here<br>        end<br><br>        def call!(context = {})<br>          context ||= {}<br>          # code here<br>        end<br>    end<br>end</pre><p><strong>Application Organizer</strong></p><pre>class ApplicationOrganizer<br>  include Interactor::Organizer<br>    class &lt;&lt; self<br>        def call(context = {})<br>          context ||= {}<br>          # code here<br>        end<br><br>        def call!(context = {})<br>          context ||= {}<br>          # code here<br>        end<br>    end<br>end</pre><p>After this process, the directory structure of your application should look something like this:</p><pre>interactors<br>├── application_interactor.rb<br>├── application_organizer.rb<br>└── movie_manager<br>      └── get_movies_interactor.rb<br>      └── some_other_interactor.rb<br>      └── combining_organizer.rb<br>└── anime_manager<br>      └── get_anime_interactor.rb<br>      └── some_other_interactor.rb<br>      └── combining_organizer.rb</pre><h3>Basic Concepts</h3><p>Before moving towards an example, let’s cover some of the basics of Interactors.</p><p><strong>Organizers</strong> are a way to compose multiple Interactors together to handle more complex use cases or workflows. They provide a structured approach to coordinating the execution of Interactors and managing the flow of data between them. Another great thing about Organizers is that if any one of the organized interactors fails its context, the organizer stops.</p><p><strong>Contexts</strong> serve as a container for data and state relevant to the interactor’s execution. The context object’s data is accessible throughout the interactor. We can implement a context class that inherits from Interactor::Context. For example:</p><pre> class CreateUserContext &lt; Interactor::Context<br>   attr_accessor :name, :email<br> end</pre><p>Additionally, the context object in the Interactor gem provides a mechanism for handling failures and exceptions. If an issue arises within your interactor, you can indicate a failure by invoking the <a href="http://context.fail/">context.fail</a>! method. This method allows you to store an error message in context.error as well. Moreover, you can check whether the context represents a failure or success using context.failure? and context.success? respectively.</p><p><strong>Hooks</strong> in interactors are used to implement before, after and around hooks. There can be times when an interactor needs to prepare its context before the interactor is even run. This can be done with before hooks on the interactor. For example:</p><pre> before do<br>   context.is_loggedin = false<br> end<br><br> ###########################################################<br><br> before :is_loggedin<br><br> def is_loggedin<br>   context.is_loggedin = false<br> end</pre><p>Like in the above example we can either make a block preparing a context or pass a symbol executing a method describing a functionality.</p><p>Then we have the after hooks. These can be used to perform teardown operations after the interactor instance is run. For example:</p><pre> after do<br>   context.user.reload<br> end<br><br> ###########################################################<br><br> after :reload_user<br><br> def reload_user<br>   context.user.reload<br> end</pre><p>Finally, we have the around hooks. The around hooks can be implemented the same way as before or after hooks, using either a block or a symbol method name, but there is one thing that is a bit different. This hook allows you to define code that will be executed before and after the interactor’s call method. It wraps the entire execution of the interactor.</p><pre> class MyInteractor<br>   include Interactor<br><br>   around do |interactor|<br>     # Code executed before the interactor&#39;s `call` method<br>     puts &quot;Before executing the interactor&quot;<br><br>     # Execute the interactor&#39;s `call` method<br>     interactor.call<br><br>     # Code executed after the interactor&#39;s `call` method<br>     puts &quot;After executing the interactor&quot;<br>   end<br><br>   def call<br>     # Core logic of the interactor<br>     puts &quot;Executing the interactor&quot;<br>   end<br> end</pre><p>The around can also be extended to form the around_each hook. This hook allows you to define code that will be executed before and after each step of the interactor. It wraps the execution of each step individually.</p><pre> class MyInteractor<br>   include Interactor<br><br>   around_each do |interactor|<br>     # Code executed before each step<br>     puts &quot;Before executing each step&quot;<br><br>     # Execute the step<br>     interactor.call<br><br>     # Code executed after each step<br>     puts &quot;After executing each step&quot;<br>   end<br><br>   def call<br>     # First step<br>     puts &quot;Executing the first step&quot;<br><br>     # Second step<br>     puts &quot;Executing the second step&quot;<br>   end<br> end</pre><p>By using hooks, you can add additional functionality or behavior around the core logic of the interactor, such as logging, transaction management, or error handling. It allows for better encapsulation and flexibility in managing the interactor’s execution flow.</p><h3>Creating Interactors</h3><p>Now let’s dive in deeper and move toward the practical part and implement some functionality using Interactors. Let’s consider we have to implement a functionality that requires creating and listing movies. The interactors would look something like this:</p><pre># app/interactors/create_movie_interactor.rb<br>class CreateMovieInteractor<br>  include Interactor<br><br>  around do |interactor|<br>    ActiveRecord::Base.transaction do<br>      interactor.call<br>    rescue StandardError =&gt; e<br>      context.fail!(error: e.message)<br>    end<br>  end<br><br>  def call<br>    title = context.title<br>    description = context.description<br><br>    if title.blank?<br>      context.fail!(error: &quot;Title cannot be blank&quot;)<br>      return<br>    end<br><br>    movie = Movie.create(title: title, description: description)<br>    context.movie = movie<br>  end<br>end</pre><pre># app/interactors/list_movies_interactor.rb<br>class ListMoviesInteractor<br>  include Interactor<br><br>  after do<br>    if context.failure?<br>      context.movies = []<br>    end<br>  end<br><br>  def call<br>    movies = Movie.all<br>    context.movies = movies<br>  end<br>end</pre><pre># app/interactors/movie_organizer.rb<br>class MovieOrganizer<br>  include Organizer<br><br>  organize CreateMovieInteractor, ListMoviesInteractor<br><br>  around do |organizer|<br>    ActiveRecord::Base.transaction do<br>      organizer.call<br>    rescue StandardError =&gt; e<br>      context.fail!(error: e.message)<br>    end<br>  end<br>end</pre><pre># app/controllers/movies_controller.rb<br>class MoviesController &lt; ApplicationController<br>  def index<br>    result = MovieOrganizer.call<br><br>    if result.success?<br>      @movies = result.movies<br>    else<br>      flash[:error] = result.error<br>      @movies = []<br>    end<br>  end<br>end</pre><p>In the above example, the around hook is added to the CreateMovieInteractor and MovieInteractorOrganizer to wrap the execution in a database transaction. This ensures that if any error occurs during the execution of the interactors, the transaction will be rolled back.</p><p>Additionally, the after hook is added to the ListMoviesInteractor to handle the scenario when the interactor fails. If the interactor fails, it sets an empty array for the context.movies to prevent any potential errors when accessing the movies in the controller.</p><p>By using interactor hooks, you can add additional behavior or wrap the execution in a transaction, providing better error handling and consistency in the application.</p><p>Then finally after creating the interactors, we will wrap them in an organizer to define the flow of execution.</p><p>Now, what was the motivation for refactoring such a small amount of code?</p><p>The motivation for refactoring such a small amount of code was to address the need for scalability and accommodate more complex use cases. Imagine a scenario where we have a more complex and large application, like a movie platform similar to Netflix. In addition to the existing functionality, we might want to send a free trial email after granting a free trial, provide recommended movies based on user interests upon registration, and incorporate various other features. As a result, the codebase would no longer remain small and straightforward. This represents the first point I mentioned earlier, emphasizing the necessity for refactoring.</p><p>Another point, as stated in the gem’s documentation, is that by looking at the interactors directory, we can quickly understand the complete functionality of the application. In simpler terms, examining this directory gives us a clear overview of what the application does and how it operates.</p><h3>Other Advantages</h3><p>Here are some key points about Organizers in Rails:</p><ol><li>Organizers allow you to define the sequence and dependencies of Interactors. You can specify the order in which Interactors should be executed and pass data between them as the workflow progresses.</li><li>Organizers are useful when you have use cases that involve multiple steps or require coordination between different Interactors. By composing Interactors within an Organizer, you can break down the complex use case into smaller, more manageable units of work.</li><li>Organizers provide a context object that serves as a container for data that needs to be shared between Interactors. As the Organizer progresses through the defined sequence of Interactors, the context object allows passing data and maintaining the state of the workflow.</li><li>Organizers typically provide mechanisms to handle errors and failure scenarios. If any Interactor within the Organizer fails, the Organizer can halt the execution and handle the failure gracefully, such as rolling back changes or returning appropriate error messages.</li><li>Organizers promote code reusability by allowing you to define common workflows and sequences of Interactors that can be used across different parts of your application. You can create Organizers for common use cases and invoke them wherever needed, enhancing the modularity and maintainability of your codebase.</li><li>Organizers can be tested by asserting the expected sequence of Interactors and their respective outputs. You can write tests to verify that the Organizer executes the Interactors in the correct order and that the data flow and context are handled as expected.</li></ol><h3>Conclusion</h3><p>We have explored the process of refactoring our code by implementing interactors, which allows us to achieve a clearer definition of our business rules and maintain a strict separation between controllers, models, and business logic. By using interactors, we can encapsulate specific actions and promote code reuse, resulting in cleaner and more organized code overall. This approach enhances the maintainability and readability of our application, making it easier to understand and modify as needed.</p><p>In a future article, we will be discussing other conventions we can use to make our application better and more scalable. So stay tuned and keep learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13f9fdcb4204" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails Service Objects — Reconstruct Your Application [ Part 1 ]]]></title>
            <link>https://medium.com/@hasnatraza.dev/rails-service-objects-reconstruct-your-application-part-1-f3d306cc6545?source=rss-810381c8c9a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3d306cc6545</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[service-object]]></category>
            <category><![CDATA[ror]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Hasnat Raza]]></dc:creator>
            <pubDate>Fri, 26 May 2023 18:35:24 GMT</pubDate>
            <atom:updated>2023-05-30T18:34:13.641Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rails Service Objects — Reconstruct Your Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*yQHMKuxDQUFjzJidiCok7g.jpeg" /></figure><p>In this article, I will provide you with a thorough understanding of Rails Service Objects. Whether you’re new to the concept and wondering, “What are service objects?” or looking for guidance on how to effectively implement them in your Rails applications.</p><p>When working on small Rails applications, it is a common practice to include the business logic in either Models or Controllers. The controllers and models start clean but before you know it, they’re filled with complex, lengthy and hard logic, which leads to scenarios where the conventional <strong>Fat Controller Slim Model</strong> mantra breaks. That is where the Rails Service Object architecture saves the day. To offload this load from controllers we use Rails Service Objects, which splits the complex business logic into small understandable pieces of code. We can say that a <strong>service object</strong> is simply a Ruby object that performs a single action. It encapsulates some business logic, and they are often called in controllers.</p><h3>Why Use Service Objects?</h3><p>Let’s consider the scenario where we need to implement a function that retrieves a list of movies from an external API. The code of the controller would look something like this:</p><pre>class MoviesController &lt; ApplicationController<br>  def index<br>    api_key = &#39;your_api_key&#39;<br>    api_url = &quot;https://api.movieapi.com/v1/movies&quot;<br><br>    @movies = HTTParty.get(api_url, query: { api_key: api_key })<br>  end<br>end</pre><p>Now, at first glance, this code doesn’t seem too shabby, does it? But imagine for a moment that we have to filter movies based on a specific string and also sort them by release date. Suddenly, things start to get a bit messy. Take a look at what our code would turn into:</p><pre>class MoviesController &lt; ApplicationController<br>  def index<br>    @movies = fetch_movies_from_api<br>    if @movies.nil?<br>      flash[:error] = &#39;Failed to fetch movies from the API.&#39;<br>      @movies = []<br>    else<br>      @movies = filter_movies_by_title(&#39;specific_string&#39;)<br>      @movies = sort_movies_by_date(@movies)<br>    end<br>  end<br><br>  private<br><br>  def fetch_movies_from_api<br>    api_key = &#39;your_api_key&#39;<br>    api_url = &#39;https://api.movieapi.com/v1/movies&#39;<br>    begin<br>      response = HTTParty.get(api_url, query: { api_key: api_key })<br>      return JSON.parse(response.body) if response.success?<br>    rescue StandardError =&gt; e<br>      Rails.logger.error(&quot;Error fetching movies from API: #{e}&quot;)<br>    end<br>    nil<br>  end<br><br>  def filter_movies_by_title(title)<br>    return [] if title.blank?<br>    @movies.select { |movie| movie[&#39;title&#39;].include?(title) }<br>  end<br><br>  def sort_movies_by_date(movies)<br>    movies.sort_by { |movie| Date.parse(movie[&#39;release_date&#39;]) }<br>  end<br>end</pre><p>As we examine the current implementation, it becomes apparent that even a single functionality requires multiple functions and some lines of code within the controller. Now, imagine a scenario where we have numerous controller action methods, each handling different functionalities, and each functionality demanding its own set of methods. The end result? The resulting controller would quickly become a complex, congested behemoth, reducing scalability and affecting maintainability.</p><p>So wouldn’t it be better if we could isolate the functionalities into separate classes within our application and simply call them from the controller whenever necessary? This is precisely where service objects come into play. By encapsulating the feature logic within a service object, we can significantly improve our code structure. Gone are the days of messed-up controllers!</p><p>With the help of Rails Service Objects, we were able to reduce the size of the controller drastically making it more manageable and readable. In the <strong>Creating Rails Service Objects</strong> section below, we will create a service that will implement the example given above.</p><h3>Other Advantages</h3><p>Many other benefits can be gained by using Rails Service Objects. Some of them are listed as follows:</p><ol><li><strong>Easy Controller Testing</strong>: With services handling the core logic, controllers become lean and easier to test. We can focus on verifying whether specific methods within the controller are called when certain actions occur.</li><li><strong>Slim Controllers</strong>: Controllers are responsible for interpreting requests and converting sessions, parameters, and cookies into arguments passed to the service object for action. The controller then handles the service’s response by redirecting or rendering. Even in larger applications, controllers using Rails services tend to have fewer lines of code.</li><li><strong>Separating Domain and Framework</strong>: Rails controllers interact with services, which in turn interact with domain objects. This decoupling makes scalability easier, especially when transitioning from a monolithic service to a microservice architecture. Services can be easily extracted and moved with minimal modifications.</li><li><strong>Reusability:</strong> Rails service objects can be utilized not only by controllers but also by other components like queued jobs and service objects. Controllers serve as the application’s central hub, facilitating interactions between users, models, and views. They host many essential ancillary services and handle the routing of external requests to internal objects.</li><li><strong>Isolation:</strong> Services are small Ruby objects separated from their environment, making them easier and faster to test. We can stub out collaborators and verify that all steps are performed correctly during the service’s execution.</li></ol><h3>Creating Rails Service Objects</h3><p>Unlike Controllers, Models, Helpers and Libs, provided in the scaffolded Rails application, the service objects are not provided by default, so we have to set them up manually. I will guide you through a simple step-by-step process to manually integrate service objects into your Rails projects.</p><p>Firstly, we will create a Rails Application. We will skip some of the goodies Rails comes bundled with since they are not required for this demo.</p><pre>rails new rails-service \<br>  --skip-action-text \<br>  --skip-active-storage \<br>  --skip-javascript \<br>  --skip-spring -T \<br>  --skip-turbolinks \<br>  --skip-sprockets \<br>  --skip-test \<br>  --api</pre><p>Once our application is all set, we will go into the app directory and will create a directory named services. And we will also be creating a file called application_service.rb, which will be responsible for the common service configurations. Now in this directory, we will be implementing our services.</p><pre>mkdir app/services &amp;&amp; touch app/services/application_service.rb</pre><p>In the Application Service file, we will be adding a method to make our service’s behavior more like a proc i.e it can be called as ExampleService.call(message) instead of ExampleService.new(message).call. Although, this is completely optional and is dependent on your requirements.</p><pre># app/services/application_service.rb<br>class ApplicationService<br>  def self.call(*args, &amp;block) <br>    new(*args, &amp;block).call<br>  end<br>end</pre><p>There is usually only one public method in a service which is responsible for the execution of the complete functionality provided by the service (in our case call and it can be replaced by names like perform or execute). There can be some private methods that can act as helpers.</p><p>Now going back to the Movies example mentioned above, let’s create a service that performs the functionality we implemented in the controller.</p><p>We will start by making a directory named movie_manger (the directory name can be referenced to the functionality or the controller for which the functionality is being implemented) followed by the creation of a file named get_movies.rb. This will introduce the concept of namespacing to our application and will make it more scaleable. The directory structure of an application with multiple services should look something like this:</p><pre>services<br>├── application_service.rb<br>└── movie_manager<br>      ├── get_movies_service.rb<br>      └── some_other_service.rb<br>└── anime_manager<br>      ├── get_anime_service.rb<br>      └── some_other_service.rb</pre><p>We will now move the code defined in the controller above to the get_movies.rb file. In the service we will have the following:</p><ol><li>The <strong>Initialize</strong> method will be acting as a constructor.</li><li>The <strong>Call</strong> method will be the executor of the service as it will be the method that can be called externally to invoke the service.</li><li>The <strong>Private</strong> methods will be acting as helper functions.</li></ol><pre># services/movie_manager/get_movies_service.rb<br>module MovieManager<br>  class GetMoviesService &lt; ApplicationService<br>    def initialize(filter_string)<br>        @filter_string = filter_string<br>    end<br>        <br>    def call<br>        movies = fetch_movies_from_api<br>        movies = filter_movies_by_title(@filter_string)<br>        movies = sort_movies_by_date(movies)<br>    end<br><br>    private<br><br>    def fetch_movies_from_api<br>        api_key = &#39;your_api_key&#39;<br>        api_url = &#39;https://api.movieapi.com/v1/movies&#39;<br>        response = HTTParty.get(api_url, query: { api_key: api_key })<br>        JSON.parse(response.body) if response.success?<br>        nil<br>    end<br><br>    def filter_movies_by_title(title)<br>        return [] if title.blank?<br>        @movies.select { |movie| movie[&#39;title&#39;].include?(title) }<br>    end<br><br>     def sort_movies_by_date(movies)<br>        movies.sort_by { |movie| Date.parse(movie[&#39;release_date&#39;]) }<br>     end<br>  end<br>end</pre><p>Finally, we’ll tie it all together by invoking this service within the controller, wrapping up the implementation of this very basic service object.</p><pre>class MoviesController &lt; ApplicationController<br>  def index<br>    @movies = MovieManager::GetMoviesService.call(params[:filter])<br>  end<br>end</pre><h3>Return Types</h3><p>We’ve covered the process of invoking our service object and returning an object, but what else can be the return value? When it comes to the return value of the service object, there are three common approaches to consider:</p><ol><li><strong>Boolean:</strong> In some cases, the service object’s purpose is to perform a specific action and determine whether it was successful or not. In such scenarios, the service object can simply return a boolean value of true or false to indicate the outcome.</li><li><strong>Value:</strong> For certain functionalities, the service object may need to compute and return a specific value or result. It could be a single object, an array, or any other relevant data structure. This approach allows the service object to provide the necessary information for further processing.</li><li><strong>Enum:</strong> In more complex scenarios, where there are multiple possible outcomes or states, the service object can make use of an Enum to define a set of predefined values. This allows the service object to convey different states or statuses, providing more detailed information about the operation.</li></ol><p>Choosing the appropriate return approach depends on the specific requirements of your application and the nature of the functionality being implemented.</p><h3>Good Practices:</h3><p>Some good practices that should be followed when creating a Service Object are listed below:</p><ol><li>Give clear names to services. A good practice is to include words ending with <strong>or, er</strong> or using <strong>_service</strong> as a suffix. For example, a service to create a movie can be <strong>MovieCreator</strong> or <strong>CreateMovieService</strong>.</li><li>To ensure clarity and simplicity, a service object should focus on performing a single business action. Therefore, it should have only one public method dedicated to that action. Other methods within the service object should be private and only known by the public method.</li><li>Each service object should have a single responsibility aligned with the business action mindset of Rails service objects. Avoid creating service objects that perform multiple unrelated actions. If code needs to be shared among service objects, consider creating a base or helper module and use mixins to include the shared functionality.</li><li>In larger applications, as you introduce more service objects, it’s beneficial to group related service objects into namespaces for improved code organization.</li></ol><h3>Conclusion</h3><p>Service objects play a crucial role in maintaining clean and organized code by keeping our business logic separate from controllers. By adopting this approach, we can significantly reduce complexity within our codebase. We can also create services using Gems like <strong>BusinessProcess</strong> gem which will be covered in future articles.</p><p>In a future article, we will dive deeper into the Interactor gem and explore how it can further streamline and optimize our application development process. So, stay tuned and keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3d306cc6545" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>