<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Elixir on Nitin Gupta</title>
    <link>https://nitingupta.dev/tags/elixir/</link>
    <description>Recent content in Elixir on Nitin Gupta</description>
    <generator>Hugo</generator>
    <language>en</language>
    <managingEditor>ngupta@nitingupta.dev (Nitin Gupta)</managingEditor>
    <webMaster>ngupta@nitingupta.dev (Nitin Gupta)</webMaster>
    <lastBuildDate>Fri, 24 Jan 2020 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://nitingupta.dev/tags/elixir/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A layered object store design in Elixir (Part VI)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part6/</link>
      <pubDate>Fri, 24 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part6/</guid>
      <description>&lt;p&gt;We built an object store from scratch in Elixir using a layered design approach. The overall theme has been to avoid generalizing the design too much which kept implementation of each layer/module simple. We were also careful when adding any third-party dependencies which has multiple advantages: deeper understanding of your codebase, easier debugging (I hate unknown code-paths in backtraces).&lt;/p&gt;&#xA;&lt;p&gt;For reference, here are links for all five parts along with their summaries:&lt;/p&gt;</description>
    </item>
    <item>
      <title>A layered object store design in Elixir (Part V)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part5/</link>
      <pubDate>Thu, 23 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part5/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part1/&#34;&gt;Part I&lt;/a&gt;, introduces the overall design of our object store. In this post we focus on the Web layer. This is the final layer for our object store responsible for exposing it over the web. It will expose endpoints: &lt;code&gt;/upload&lt;/code&gt; for uploading a file and &lt;code&gt;/file/:file_id&lt;/code&gt; for getting a file by ID. A typical GraphQL application with also expose endpoint &lt;code&gt;/graphql&lt;/code&gt; which directly plugs into your API layer, however I will not discuss this part and stay focused on the object store side of things.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A layered object store design in Elixir (Part IV)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part4/</link>
      <pubDate>Wed, 22 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part4/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part1/&#34;&gt;Part I&lt;/a&gt;, introduces the overall design of our object store. In this post we focus on the API layer. All layers till now were just concerned about storing the input file together with some file-format specific transforms (like thumbnails). It is at the API layer where we will be storing per-file system and user metadata. This metadata can be used to support application specific business logic and security policies.&lt;/p&gt;&#xA;&lt;p&gt;This layer will depend on all per-file-format modules: &lt;code&gt;ImageStore&lt;/code&gt;, &lt;code&gt;VideoStore&lt;/code&gt;, etc. We will use Postgres for storing per-file metadata, so we also depend on the &lt;a href=&#34;https://hex.pm/packages/postgrex&#34;&gt;postgrex&lt;/a&gt; package. A typical API layer will also be exposing a GraphQL interface which forms the core of application specific business logic. I am not going to include an example GraphQL interface here but &lt;a href=&#34;https://hex.pm/packages/absinthe&#34;&gt;absinthe&lt;/a&gt; would be my preferred way of doing it, anytime.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A layered object store design in Elixir (Part III)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part3/</link>
      <pubDate>Mon, 20 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part3/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part2/&#34;&gt;Part I&lt;/a&gt; layer.&lt;/p&gt;&#xA;&lt;h1 id=&#34;imagestore&#34;&gt;ImageStore&lt;/h1&gt;&#xA;&lt;p&gt;The ImageStore module is responsible for storing images along with their thumbnail. It will use the FileStore layer to actually store files on disk. Before we define module interfaces, lets see our application requirements:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All images must be stored in the &lt;code&gt;jpg&lt;/code&gt; format.&lt;/li&gt;&#xA;&lt;li&gt;Images cannot be larger than 1920x1080. We do not want to store user provided version at all.&lt;/li&gt;&#xA;&lt;li&gt;Thumbnails should use the same &lt;code&gt;jpg&lt;/code&gt; format.&lt;/li&gt;&#xA;&lt;li&gt;All thumbnails must have the same size of 256x256.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that we are going for highly application specific requirements rather than a more general, configurable design. I have seen most of the complexity in software stacks is due to the temptation of making them &amp;ldquo;reusable&amp;rdquo;. As you will see, the implementation is going to be so simple, with clearly defined interfaces, that it would be much easier for you to create such a module for each of your applications, with its specific requirements baked in.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A layered object store design in Elixir (Part II)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part2/</link>
      <pubDate>Mon, 13 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part2/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part1/&#34;&gt;Part I&lt;/a&gt;, introduces the overall design of our object store. In this post we focus on its first layer, the &lt;code&gt;FileStore&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The FileStore layer is responsible for actually storing the file in our object store. At this level, we are not concerned about what kind of file it is (image, video, document, or whatever else), nor do we have any notion of security. We just store whatever input path is given to us.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A layered object store design in Elixir (Part I)</title>
      <link>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part1/</link>
      <pubDate>Sun, 12 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/a-layered-object-store-design-in-elixir-part1/</guid>
      <description>&lt;p&gt;I recently designed an object store from scratch in Elixir. It has been serving me well as a backend for an app which needs to store all kinds of files: images, videos, documents. I wanted something simple to avoid dealing with off-the-shelf object stores which require complex configurations and to avoid cloud storage which is dead simple to use but can get very expensive, very quickly. For this project, simplicity was the key to make sure I can debug any failures quickly.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Elixir collections</title>
      <link>https://nitingupta.dev/post/elixir-collections/</link>
      <pubDate>Thu, 02 Jan 2020 00:00:00 +0000</pubDate><author>ngupta@nitingupta.dev (Nitin Gupta)</author>
      <guid>https://nitingupta.dev/post/elixir-collections/</guid>
      <description>&lt;p&gt;Elixir is a function programming language that I have been using a lot in recent months to build all kinds of applications. Understanding of built-in collection types is essential to use any language effectively and Elixir is no different.&lt;/p&gt;&#xA;&lt;p&gt;This posts summarizes all collection type along with pros/cons/gotchas for each one of them.&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;&lt;strong&gt;Collection&lt;/strong&gt;&lt;/th&gt;&#xA;          &lt;th&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/th&gt;&#xA;          &lt;th&gt;&lt;strong&gt;When&lt;/strong&gt;&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Tuples&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;{:ok, &amp;quot;All good&amp;quot;}&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Returning data from a function&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Lists&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;[1, &amp;quot;two&amp;quot;, :three]&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;For a collection of items&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Keyword lists&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;[one: 1, two: 2]&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Passing options to a function&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Maps&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;%{one: 1, two: 2}&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Flexible key/value store&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Structs&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;%User{name: &amp;quot;John&amp;quot;, age: 32}&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Typed/fixed key/value store&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h1 id=&#34;tuples&#34;&gt;Tuples&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;{:ok, foo}&lt;/code&gt; &amp;ldquo;tagged&amp;rdquo; tuple since begins with an atom like &lt;code&gt;:ok&lt;/code&gt; or &lt;code&gt;:error&lt;/code&gt; like &lt;code&gt;{:error, 543, &amp;quot;some error&amp;quot;}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Examples:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
