<?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 Nitesh Mishra on Medium]]></title>
        <description><![CDATA[Stories by Nitesh Mishra on Medium]]></description>
        <link>https://medium.com/@niteshVirus?source=rss-19610be4ff94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Msrq62mPSCpor540xV6CXg.jpeg</url>
            <title>Stories by Nitesh Mishra on Medium</title>
            <link>https://medium.com/@niteshVirus?source=rss-19610be4ff94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:31:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@niteshVirus/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[GraphQL in Elixir: Building Queries, Mutations and Real-Time Subscriptions with Absinthe]]></title>
            <link>https://medium.com/@niteshVirus/graphql-in-elixir-building-queries-mutations-and-real-time-subscriptions-with-absinthe-322c44e7aa52?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/322c44e7aa52</guid>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Thu, 13 Aug 2026 07:15:26 GMT</pubDate>
            <atom:updated>2026-08-13T07:15:26.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*17KWBNO97io5PtK_" /></figure><p><strong>A complete, readable Phoenix app — and the one thing about subscriptions that nobody tells you up front</strong></p><p>Most GraphQL tutorials stop at “here is a query, here is a resolver.” That part is genuinely easy in Elixir. The part that costs people an afternoon is everything after: how a schema stays readable once it has more than one domain, where business logic goes so it does not rot inside resolvers, and how subscriptions actually route a message from an HTTP mutation to a websocket client three tabs over.</p><p>I built <a href="https://github.com/niteshcode4u/LearnAbsinthe"><strong>LearnAbsinthe</strong></a> to answer those questions in one small app you can read end to end. It implements queries, mutations and real-time subscriptions over a single `Post` domain, with tests for all three. Deliberately, there is no database: the store is a GenServer, so nothing you read is Ecto — it is all GraphQL.</p><p>This article walks through how the pieces fit, and then spends most of its time on subscriptions, because that is where the surprises are.</p><h3><strong>Why Absinthe fits Elixir so well</strong></h3><p>GraphQL is a query language plus an execution engine. Given a document, the server parses it, validates it against a schema, and walks the resulting tree resolving one field at a time. That last part is the tell. Resolving a tree of independent fields is embarrassingly parallel, every resolver is a pure-ish function returning a tagged tuple, and real-time subscriptions need a process per subscriber with cheap message passing. Elixir was built for exactly this shape of problem, and Absinthe leans into it — resolvers are plain 3-arity functions, and subscriptions ride on Phoenix’s existing channel infrastructure rather than a bolted-on transport.</p><p>Here is the whole schema of the demo app:</p><pre>type RootQueryType {<br>  getPost(postId: ID!): Post<br>  getPosts: [Post]<br>}<br><br>type RootMutationType {<br>  createPost(post: PostCreateInput!): Post!<br>  updatePost(post: PostUpdateInput!): Post!<br>}<br><br>type RootSubscriptionType {<br>  postUpdated(postId: ID!): Post!<br>}<br><br>type Post {<br>  id: ID!<br>  title: String!<br>  description: String!<br>  author: Author!<br>  comments: [String]<br>}</pre><p>Small enough to hold in your head, big enough to hit every concept that matters.</p><h3><strong>Part 1: A schema that survives growth</strong></h3><p>The most common way an Absinthe schema goes bad is that it becomes one enormous file. Absinthe gives you two macros to prevent that, and the split between them is worth understanding rather than copying.</p><pre>defmodule LearnAbsintheWeb.Schema do<br>  use Absinthe.Schema<br><br>  import_types(LearnAbsintheWeb.Graphql.Posts.Queries)<br>  import_types(LearnAbsintheWeb.Graphql.Posts.Mutations)<br>  import_types(LearnAbsintheWeb.Graphql.Posts.Subscriptions)<br><br>  query do<br>    import_fields(:post_queries)<br>  end<br><br>  mutation do<br>    import_fields(:post_mutations)<br>  end<br><br>  subscription do<br>    import_fields(:post_subscriptions)<br>  end<br>end</pre><p>import_types/1 makes another module&#39;s type definitions <em>known</em> to the schema. Nothing becomes callable — the types just exist.</p><p>import_fields/1 takes an object that is already known and splices its fields into the block you are currently in. So import_fields(:post_queries) inside query do ... end means &quot;every field on the :post_queries object is now a root query field.&quot;</p><p>The nice thing is that :post_queries is not special. Absinthe has no concept of a &quot;queries object&quot; — it is an ordinary object that we only ever use as a bag of root fields:</p><pre>object :post_queries do<br>  field :get_post, :post do<br>    arg(:post_id, non_null(:id))<br>    resolve(&amp;Resolver.get_post/3)<br>  end<br><br>  field :get_posts, list_of(:post), resolve: &amp;Resolver.list_post/3<br>end</pre><p>Because it is just an object, the identical trick works for mutations and subscriptions with no new machinery. Adding a Comments domain means creating the same four files under graphql/comments/ and adding <strong>one</strong> import_types line and <strong>one</strong> import_fields line. Domain files grow. The schema file stays a page long, forever.</p><p><strong>A small thing that pays off daily:</strong> you write field :first_name and clients write firstName. Absinthe&#39;s default adapter translates snake_case to camelCase at the schema boundary. Elixir code stays idiomatic Elixir, the API stays idiomatic GraphQL, and you never type the camelCase form yourself.</p><h3><strong>Part 2: Resolvers should be boring</strong></h3><p>Every Absinthe resolver has the same signature:</p><pre>def get_post(parent, args, resolution) do<br>  # ...<br>end</pre><ul><li><strong>parent</strong> — the value resolved one level up. For a root field it is nil; on Post.author it would be the %Post{} struct.</li><li><strong>args</strong> — the field&#39;s arguments, already validated and converted to an atom-keyed map.</li><li><strong>resolution</strong> — an Absinthe.Resolution struct with the context, the selection set, and more. This is where context.current_user lives.</li></ul><p>Return {:ok, value} or {:error, reason}. That is the entire contract.</p><p>Here is the resolver module from the demo, in full:</p><pre>def create_post(_parent, %{post: post_params}, _resolution),<br>  do: LearnAbsinthe.create_post(post_params)<br><br>def update_post(_parent, %{post: post_params}, _resolution),<br>  do: LearnAbsinthe.update_post(post_params)<br><br>def get_post(_parent, %{post_id: post_id}, _resolution),<br>  do: LearnAbsinthe.get_post_by_id(post_id)<br><br>def list_post(_parent, _args, _resolution),<br>  do: LearnAbsinthe.list_post()</pre><p>That is not laziness, it is the point. A resolver’s job is argument shuffling. The business logic lives in LearnAbsinthe, the Phoenix context, where it can be called from IEx, a controller, a LiveView or a test — without constructing a GraphQL document. When a resolver starts sprouting case statements over domain rules, that logic has escaped into the wrong layer.</p><p>Two more things fall out of this design.</p><p><strong>Pattern matching directly on </strong><strong>%{post_id: post_id} is safe, not sloppy.</strong> The schema declares that argument non_null(:id), so a request missing it is rejected during validation, before any Elixir of yours runs. Absinthe does the defensive checking so you do not have to.</p><p><strong>Scalar fields need no resolver at all.</strong> Absinthe’s default resolver is Map.get(parent, field_name), so Post.title reads post.title off the struct. You write resolve/1 only where the default is wrong. In the demo, the only reason Post.author works without one is that the author struct is embedded at write time — more on that at the end.</p><h3><strong>Part 3: Subscriptions, and the string that connects everything</strong></h3><p>Now the interesting part.</p><p>A GraphQL subscription is a long-lived connection where the server pushes data as things change. In Absinthe, a subscription field looks like this — and note that it has <strong>no resolver</strong>:</p><pre>object :post_subscriptions do<br>  field :post_updated, non_null(:post) do<br>    arg(:post_id, non_null(:id))<br>    <br>    config(fn %{post_id: post_id}, _context -&gt;<br>      {:ok, topic: &quot;post:#{post_id}&quot;}<br>    end)<br>    <br>    trigger(:update_post, topic: fn post -&gt; &quot;post:#{post.id}&quot; end)<br>  end<br>end</pre><p>Two callbacks, and they run at completely different times, in response to completely different events.</p><h3>config/1 runs when a client subscribes</h3><p>It receives the subscriptions arguments and the context, and returns a topic string. Think of the topic as a bucket key.</p><p>A client subscribing with postId: 1 goes into the &quot;post:1&quot; bucket. Another subscribing with postId: 7 goes into &quot;post:7&quot;. They will never see each other&#39;s updates. Return a constant string instead and you have built a firehose that every subscriber shares — sometimes what you want, usually not.</p><p>config/1 is also where authorisation belongs. It can read context, so scoping a subscription to the connected user is a matter of building the topic from context.current_user.id, and refusing outright is a matter of returning {:error, reason}.</p><h3>trigger/2 runs when a mutation resolves</h3><p>It names a mutation — :update_post — and supplies a function that turns that mutation&#39;s return value into a topic. When the mutation succeeds, Absinthe computes the topic and pushes to everyone in that bucket.</p><p>And here is the thing I wish someone had put in bold for me:</p><blockquote><strong><em>Those two topic strings matching is the entire routing mechanism.</em></strong></blockquote><pre># built from the SUBSCRIBER&#39;S argument, at subscribe time<br>config(fn %{post_id: post_id}, _ctx -&gt; {:ok, topic: &quot;post:#{post_id}&quot;} end)<br><br># built from the MUTATION&#39;S result, at publish time<br>trigger(:update_post, topic: fn post -&gt; &quot;post:#{post.id}&quot; end)</pre><p>There is no type checking between them. No compile-time link. Nothing warns you. Typo one side — &quot;post:&quot; versus &quot;posts:&quot;, or an id that is an integer in one place and a string in the other — and every single piece still <em>appears</em> to work. The mutation returns 200. The subscription connects and reports a subscription id. The client just sits there, forever, receiving nothing.</p><p>When an Absinthe subscription “doesn’t fire,” print both strings before you debug anything else. It is nearly always this.</p><h3>What the mutation knows about all of it: nothing</h3><p>Worth stating plainly, because it is the elegant bit. Here is the mutation that fires the subscription:</p><pre>field :update_post, non_null(:post) do<br>  arg(:post, non_null(:post_update_input))<br>  resolve(&amp;Resolver.update_post/3)<br>end</pre><p>No publish call. No mention of subscriptions. No coupling in that direction at all. The subscription declares which mutation it cares about, and the mutation stays a plain mutation. Add ten subscriptions triggered by update_post and that field never changes.</p><p>The mutation’s return value also becomes the subscription field’s root value, which is why the subscription needs no resolver of its own. Absinthe re-runs each subscriber’s selection set against it — so a subscriber that asked for { id comments } gets exactly that, regardless of what the mutating client requested.</p><h3>The four pieces of wiring</h3><p>Subscriptions need four separate bits of setup, in four different files. Get three right and you get the silent-failure mode again:</p><pre># application.ex — the registry of who is subscribed to what.<br># MUST come after the endpoint in the child list; it is parameterised by it.<br>{Absinthe.Subscription, LearnAbsintheWeb.Endpoint}</pre><pre># endpoint.ex — the hook that lets mutation results be published<br>use Absinthe.Phoenix.Endpoint</pre><pre># user_socket.ex — the websocket transport<br>use Absinthe.Phoenix.Socket, schema: LearnAbsintheWeb.Schema</pre><pre># router.ex — tells the GraphiQL IDE which socket to open<br>forward &quot;/graphiql&quot;, Absinthe.Plug.GraphiQL,<br>  schema: LearnAbsintheWeb.Schema,<br>  socket: LearnAbsintheWeb.UserSocket</pre><p>Miss any one and mutations keep succeeding while nothing is ever pushed.</p><h3>Seeing it work</h3><p>Open two GraphiQL tabs. In tab A:</p><pre>subscription {<br>  postUpdated(postId: 1) { id comments }<br>}</pre><p>In tab B:</p><pre>mutation {<br>  updatePost(post: { id: 1, comment: &quot;Nice write-up!&quot; }) { id comments }<br>}</pre><p>Tab A updates instantly.</p><h3><strong>Part 4: Testing both transports</strong></h3><p>Queries and mutations are ordinary HTTP, so they test like ordinary HTTP:</p><pre>test &quot;returns post when found&quot; do<br>  {:ok, post} = LearnAbsinthe.create_post()<br><br>  query = &quot;&quot;&quot;<br>  { getPost(postId: #{post.id}) { title comments } }<br>  &quot;&quot;&quot;<br>  <br>  response = post_graph_query(%{query: query})[&quot;data&quot;][&quot;getPost&quot;]<br>  <br>  assert response[&quot;title&quot;] == post.title<br>end</pre><p>One trap worth internalising: <strong>GraphQL signals application errors in the body, not the status line.</strong> A resolver returning {:error, &quot;not_found&quot;} produces HTTP <strong>200</strong> with an errors list next to a partially-null data. Assert on the body:</p><pre>assert hd(post_graph_query(%{query: query})[&quot;errors&quot;])[&quot;message&quot;] == &quot;not_found&quot;</pre><p>Subscriptions are more fun, because a single test has to drive <strong>two transports at once</strong>: subscribe on the websocket, mutate over HTTP, then assert the socket received a push.</p><pre>test &quot;pushes to subscribers when a post is updated&quot; do<br>  {:ok, post} = LearnAbsinthe.create_post()<br>  socket = create_socket()<br><br>  subscription_id = subscribe(socket, &quot;&quot;&quot;<br>    subscription { postUpdated(postId: #{post.id}) { id comments } }<br>  &quot;&quot;&quot;)<br>  <br>  # different transport entirely - this goes over HTTP<br>  post_graph_query(%{query: &quot;&quot;&quot;<br>    mutation { updatePost(post: {id: #{post.id}, comment: &quot;hi&quot;}) { id comments } }<br>  &quot;&quot;&quot;})<br>  <br>  assert_push &quot;subscription:data&quot;, %{result: result, subscriptionId: ^subscription_id}<br>end</pre><p>The pin on ^subscription_id is doing real work. Without it the test passes as long as <em>something</em> was pushed to <em>anyone</em>. With it, the test proves the message was routed to this specific subscriber — which is precisely what the config/trigger topic pair is responsible for, and precisely what breaks when the two strings drift apart. It is the assertion that catches the bug this article has been warning about.</p><h3>What the demo deliberately leaves out</h3><p>Being explicit about this matters more for a learning repo than for a real one.</p><p><strong>Storage is a GenServer.</strong> No Ecto schemas, no changesets, no migrations. That keeps the GraphQL story uncluttered, and it is why the store is a pair of globally-named processes that force async: false in the tests.</p><p><strong>No authentication.</strong> Nothing reads resolution.context. The two places it would be wired — UserSocket.connect/3 for the socket and a plug for HTTP — are marked in the source. They are separate: wiring one does not wire the other, which surprises people.</p><p><strong>And a security note, because someone will fork this.</strong> The router’s non-dev branch forwards Absinthe.Plug.GraphiQL — the full interactive IDE — on /graphql. That is fine for a demo and wrong for anything public. Before a GraphQL endpoint faces real traffic:</p><ul><li>forward plain Absinthe.Plug, not the GraphiQL variant, and put it behind auth</li><li>gate introspection, unless you mean to publish your schema map</li><li><strong>set a </strong><strong>max_complexity budget.</strong> This is the one people skip. A GraphQL endpoint with no depth or complexity limit is a standing denial-of-service invitation: a document a few hundred bytes long can nest its way into something that costs the server orders of magnitude more, and no request-size limit will catch it</li><li>do not let raw internal errors through to clients</li></ul><h3>The exercise that teaches the most</h3><p>Work through the repo, then do this one:</p><p><strong>Replace the GenServers with real Ecto schemas.</strong> If the layering has done its job, nothing under lib/learn_absinthe_web/graphql/ should need to change — only LearnAbsinthe and the workers underneath it. That is the real test of whether your resolvers were thin enough.</p><p>Then notice what you have just broken.</p><p>In the demo, Post.author needs no resolver because the author struct is embedded into the post at write time. With Ecto behind it, that field becomes a database query <em>per post</em> — request 50 posts and you have issued 51 queries. You have just built yourself an N+1, which is the problem <a href="https://hexdocs.pm/dataloader">Dataloader</a> and Absinthe.Middleware.Batch exist to solve, and which most real-world GraphQL engineering turns out to be about.</p><p>Meeting that problem by causing it is a considerably better way to learn it than reading about it.</p><h3>Get the code</h3><p><a href="https://github.com/niteshcode4u/LearnAbsinthe"><strong>github.com/niteshcode4u/LearnAbsinthe</strong></a></p><pre>git clone https://github.com/niteshcode4u/LearnAbsinthe.git<br>cd LearnAbsinthe<br>mix setup<br>mix phx.server<br># → http://localhost:4000/graphiql</pre><p>Every module carries a moduledoc explaining what it does and why, and the README has sequence diagrams for all three flows plus a suggested reading order. Issues and PRs welcome — especially if something in it confused you, because that is a documentation bug.</p><p><em>If this was useful, the repo is the better artifact — clone it and break something.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=322c44e7aa52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trunk-Based Development: The Backbone for High-Performing Large Teams]]></title>
            <link>https://medium.com/@niteshVirus/trunk-based-development-the-backbone-for-high-performing-large-teams-fd5afe10b5ff?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd5afe10b5ff</guid>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 14:39:07 GMT</pubDate>
            <atom:updated>2025-07-02T14:40:17.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*ZIvQG07ivZWvtzjJXNalYA.png" /></figure><p>In the fast-paced world of software engineering, <strong>large teams often juggle complex codebases, frequent changes, and multiple simultaneous features</strong>. Add in the urgency of production bug fixes, and chaos can quickly creep in.</p><p>This is where <strong>Trunk-Based Development (TBD)</strong> emerges — not just as a methodology, but as a critical enabler for <strong>efficiency, stability, and speed</strong>.</p><h3>What is Trunk-Based Development?</h3><p>TBD is a development strategy where all engineers <strong>commit their code directly to a shared branch (typically </strong><strong>main or </strong><strong>master) frequently</strong>, avoiding long-lived feature branches.</p><p>Instead of developers working in silos, everyone integrates small, incremental changes regularly, ensuring the trunk is always in a <strong>deployable state</strong>.</p><h3>Why Trunk-Based Development for Large Teams?</h3><p>Traditional branching models like Git-Flow can <strong>become bottlenecks</strong>:</p><ul><li><strong>Merge Hell:</strong> Long-lived feature branches accumulate massive conflicts.</li><li><strong>Delayed Feedback:</strong> Code sits unmerged for days or weeks.</li><li><strong>Reduced Visibility:</strong> Work is scattered across branches.</li><li><strong>Slow Deployment Cycles:</strong> Integration overhead delays delivery.</li></ul><p><strong>TBD flips this on its head</strong> by advocating a <strong>single, shared trunk (</strong><strong>main)</strong> where all developers commit <strong>directly and frequently</strong>.</p><h3>Key Benefits</h3><p>✅ <strong>Continuous Integration:</strong> Frequent merges catch conflicts early, reducing risk.<br>✅ <strong>Fast Feedback Loops:</strong> Developers get immediate validation on their changes.<br>✅ <strong>Increased Collaboration:</strong> Everyone works on the same source of truth.<br>✅ <strong>Rapid Deployment:</strong> A clean, integrated trunk is always deployable.</p><h3>Core Principles for Large Teams</h3><h4>1. A Single, Shared Trunk</h4><p>All development happens <strong>directly on trunk</strong> or <strong>very short-lived branches (hours, not days)</strong>. Feature branches are ephemeral, used only for PR reviews if necessary.</p><h4>2. Small, Frequent Commits</h4><p>Engineers commit <strong>multiple times daily</strong>, keeping changes atomic and easy to test.</p><h4>3. Feature Flags</h4><p>Feature flags <strong>decouple deployment from release</strong>, allowing incomplete features to be merged without affecting users until activated.</p><h4>4. Robust CI/CD Pipelines</h4><p>Automated pipelines ensure every commit:</p><ul><li>Triggers builds and tests.</li><li>Validates stability.</li><li>Deploys to staging automatically.</li></ul><h4>5. Comprehensive Automated Testing</h4><p>Fast, reliable <strong>unit, integration, and end-to-end tests</strong> provide safety for continuous merging.</p><h4>6. Pair and Mob Programming</h4><p>For large teams, pair/mob programming <strong>enhances code quality and shared understanding</strong>, reducing the risk of breakages on trunk.</p><h3>Managing Frequent Changes and Multiple Features</h3><p>TBD thrives in <strong>high-velocity environments</strong>:</p><ul><li><strong>Feature Flags De-Risk Releases:</strong> Teams can work on features concurrently without fear of unfinished work affecting production. Dark launches and A/B testing become easy.</li><li><strong>Continuous Integration Catches Issues Early:</strong> Small changes are integrated and tested immediately, avoiding painful “big bang” integrations.</li><li><strong>Small Changes Reduce Blast Radius:</strong> Any introduced bug is easier to detect, fix, or revert quickly.</li></ul><h3>Handling Production Bug Fixes with TBD</h3><p>When production issues arise, TBD <strong>accelerates recovery</strong>:</p><p>✅ <strong>Direct Hotfixes to Trunk:</strong> No need for complex hotfix branches or back-merges.<br>✅ <strong>Immediate Deployments:</strong> Trunk’s deployable state allows rapid push to production post-tests.<br>✅ <strong>Feature Flags as Kill Switches:</strong> If a flagged feature causes issues, toggling it off instantly mitigates user impact without redeployment.</p><h3>Challenges and How to Overcome Them</h3><p>⚠️ <strong>Discipline and Trust:</strong> Developers must commit tested, small changes frequently.<br>✅ <em>Foster collective ownership and automate tests to build trust.</em></p><p>⚠️ <strong>CI/CD Investment:</strong> Robust pipelines require upfront effort.<br>✅ <em>Treat CI/CD infrastructure as a first-class product.</em></p><p>⚠️ <strong>Cultural Shift:</strong> Moving from Git-Flow to TBD demands unlearning old practices.<br>✅ <em>Start small, educate teams, and lead by example.</em></p><h3>Real-World Application: Supporting Production Bugs</h3><p>In large teams:</p><ul><li>A <strong>production bug can be fixed directly on trunk</strong> and shipped quickly.</li><li>Other teams can continue feature work without disruption.</li><li>The fix, tested automatically, reaches production without waiting for long merge cycles.</li></ul><h3>Conclusion</h3><p>For large, fast-moving engineering teams, <strong>Trunk-Based Development</strong> offers a <strong>clear path to agility, reduced risk, and rapid delivery</strong>.</p><p>By focusing on:<br> ✅ A single source of truth,<br> ✅ Small and frequent commits,<br> ✅ Feature flags for safe releases,<br> ✅ Robust CI/CD automation,</p><p>TBD enables teams to ship <strong>high-quality software continuously</strong> while keeping their sanity intact.</p><h3>Ready to Adopt TBD?</h3><blockquote>If your team frequently battles merge conflicts, delayed releases, or production patching chaos, TBD may be the <strong>mindset and strategy shift you need</strong>.<br><em>Start small, automate tests, and commit frequently.<br>You’ll see your delivery speed and team confidence soar.</em></blockquote><p>✍️ <em>If this resonates, follow me for more practical software delivery insights for scaling engineering teams efficiently.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd5afe10b5ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Architecture]]></title>
            <link>https://medium.com/@niteshVirus/serverless-architecture-687a33e57f85?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/687a33e57f85</guid>
            <category><![CDATA[serverless-architecture]]></category>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 11:26:22 GMT</pubDate>
            <atom:updated>2024-11-20T11:26:22.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*Fu6y546DZ2HIzLQkDBOLfQ.png" /><figcaption>OMG No server now</figcaption></figure><blockquote>No server means: You yon’t worry about server. there are servers, but don’t have worry</blockquote><p><strong>Serverless architecture</strong> is a cloud computing model in which developers can build and run applications without managing the underlying server infrastructure. Despite the term “serverless,” servers still run the code; however, their management and provisioning are handled by a cloud provider, allowing developers to focus solely on writing application code.</p><h3>Key Features of Serverless Architecture:</h3><ol><li><strong>No Server Management</strong>: The cloud provider automatically handles server provisioning, scaling, and maintenance. Developers don’t need to worry about operating systems, server configurations, or patching.</li><li><strong>Event-Driven Execution</strong>: Specific events, such as an HTTP request, a database update, or a file upload trigger serverless functions.</li><li><strong>Auto-Scaling</strong>: Resources scale automatically based on the application’s demand. The provider adjusts infrastructure accordingly if a function is invoked 1 or 1 million times.</li><li><strong>Pay-Per-Use Model</strong>: You pay only for the compute time your code runs, rather than for pre-allocated resources, which can result in significant cost savings.</li><li><strong>Stateless Functions</strong>: Serverless applications are typically composed of <strong>stateless functions</strong> that run independently and don’t retain state between executions. Persistent data is stored in databases or other storage solutions.</li></ol><h3>Advantages of Serverless Architecture:</h3><ul><li><strong>Reduced Operational Overhead</strong>: Developers focus on writing code, while the cloud provider handles infrastructure.</li><li><strong>Cost Efficiency</strong>: You’re billed only for actual usage rather than idle time.</li><li><strong>Scalability</strong>: Applications can handle variable loads without additional configuration.</li><li><strong>Faster Development</strong>: Built-in integrations and simplified deployment processes speed up development.</li></ul><h3>Challenges of Serverless Architecture:</h3><ol><li><strong>Cold Start Latency</strong>: Serverless functions may take longer to respond initially due to the time it takes to spin up a new instance (cold start).</li><li><strong>Vendor Lock-In</strong>: Applications can become tightly coupled to the specific cloud provider’s services and APIs.</li><li><strong>Debugging Complexity</strong>: It can be harder to debug and trace issues in a distributed event-driven system.</li><li><strong>Statelessness</strong>: Stateless functions require external solutions for state management, which can increase complexity.</li></ol><h3>Common Use Cases for Serverless:</h3><ul><li><strong>API Gateways</strong>: Creating RESTful APIs using serverless functions.</li><li><strong>Data Processing</strong>: Processing streams of data or running periodic jobs.</li><li><strong>IoT Applications</strong>: Handling large-scale, event-driven data from IoT devices.</li><li><strong>Backend for Web or Mobile Apps</strong>: Building scalable backends with minimal overhead.</li></ul><h3>Popular Serverless Platforms:</h3><ul><li><strong>AWS Lambda</strong> (Amazon)</li><li><strong>Google Cloud Functions</strong> (Google)</li><li><strong>Azure Functions</strong> (Microsoft)</li><li><strong>Cloudflare Workers</strong></li><li><strong>Netlify Functions</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=687a33e57f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker hacks]]></title>
            <link>https://medium.com/@niteshVirus/docker-hacks-82925098edf4?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/82925098edf4</guid>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 04:41:52 GMT</pubDate>
            <atom:updated>2023-04-28T04:41:52.133Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Here the hacks are for macOS in case you are running in Linux please use </em><em>sudo before docker in every command also you may check </em><em>docker --help</em></p><ol><li>$ docker version — the verified client can talk to the engine</li><li>$ docker info — most config value of the engine</li><li>$ docker run --publish 80:80 nginx — to run nginx locally if not available locally it will pull from docker-hub</li><li>$ docker container ls — to check running containers</li><li>$ docker container ls -a — to check all existing containers</li><li>$ docker container run publish 80:80 --detach nginx — to run the docker container in detached mode means in the background</li><li>$ docker container run publish 80:80 --detach --name webhost nginx — in case you want to define the container name. By default, it will take some random container name.</li><li>$ docker container stop [container_id] to stop running the container. you can get the container id by using the above command docker container ls</li><li>$ docker container rm [container_id] — to remove from the list</li><li>$ docker container rm -f [container_id] — will remove the running container forcefully. (<em>not recommended</em>)</li><li>$ docker container run -d --name database -p 3306:3306 -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql — run MySQL database with the environment<br>{-d: detach, -e: add env variables</li><li>To get a list of images running: $ docker ps &amp; $ docker container ls</li><li>$ docker images to get docker images</li><li>$ docker container stats — to get stats for live running containers</li><li>$ docker container inspect [container_id] — Get containers network details</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8xFp1LIsHEN1QXZCEZBxA.png" /></figure><p>Software to use in local machine Docker desktop (Free for learning — Window user) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*rziwmnuv8_j5EYK7jWBUAA.png" /></figure><p>$ docker container port [image_name] — to get an open port for the image</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82925098edf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ubuntu: Installing a specific version of a package]]></title>
            <link>https://medium.com/@niteshVirus/ubuntu-installing-a-specific-version-of-a-package-ab841f0093d7?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab841f0093d7</guid>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Tue, 07 Apr 2020 12:35:16 GMT</pubDate>
            <atom:updated>2020-04-07T12:35:16.896Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will learn the command to install the specific version of a package and we will stop future upgrades to that package. So let’s start.</p><p>Let’s find out the version we want to install on our Ubuntu machine.<br>For this, we can use policy option in the apt command<br>apt policy &lt;package name&gt;<br>For example:<br>apt policy elixir</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*rAs1oxRz2w-b_q0M.png" /></figure><p>To install a particular version of a package we need to pass its version number as:<br> sudo apt install elixir=&lt;version number&gt;</p><p>We will now move ahead to install elixir v1.4.5–1.<br>sudo apt install elixir=1.4.5-1</p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*W1tqbp-HLczPbp7k.png" /></figure><p>As you can see in the above image it is saying that the package will be downgraded.<br>So till now, we are able to download our specific package. Yipeee!!!</p><p>Now we will hold our packages so that it won’t upgrade automatically while system upgrades.</p><p>We will use the following command for that:<br>sudo apt-mark hold &lt;package name&gt;</p><blockquote><em>$ sudo apt-mark hold elixir<br>elixir set on hold.</em></blockquote><p>We can check hold packages by using the following command:<br>apt-mark showhold<br>Output:</p><blockquote><em>$ apt-mark showhold<br>elixir</em></blockquote><p>Now to remove a package from hold:<br>sudo apt-mark unhold &lt;package name&gt;</p><p>Yipee!! all set. Now our elixir package will not be upgraded on running system upgrades. 😀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab841f0093d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elixir: Adding serials in an existing column referenced as a foreign key]]></title>
            <link>https://medium.com/@niteshVirus/elixir-adding-serials-in-an-existing-column-referenced-as-a-foreign-key-ed7c44d69d9a?source=rss-19610be4ff94------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed7c44d69d9a</guid>
            <dc:creator><![CDATA[Nitesh Mishra]]></dc:creator>
            <pubDate>Tue, 07 Apr 2020 09:51:32 GMT</pubDate>
            <atom:updated>2020-04-07T10:27:08.061Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I needed to change the data type of primary key which was defined as a string but needed as a sequence on an existing database table in a Phoenix project. Let’s check how I went through it.</p><p>Thank you @sridhar_yenugudhati for your suggestion</p><blockquote>Let’s have an example of a user table which looks like below. here</blockquote><blockquote>the id is a string and referenced by some snaps table</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*Evb-vcsdYfSIJ15yFIhd-w.png" /><figcaption>What we have in the user table</figcaption></figure><blockquote>Below are the steps I followed to make changes:</blockquote><ol><li><strong>mix ecto.gen.migration “ChangeUserIdToSerial”</strong>: This will create a module for your changes to perform migrations</li><li><strong>Go to:- your_app\priv\repo\migrations\20180620172913_ChangeUserIdToSerial</strong></li><li><strong>Update your module like below:</strong></li></ol><pre>defmodule MyApp.Repo.Migrations.ChangeUserIdToSerial do</pre><pre>use Ecto.Migration</pre><pre>def up do<br># NOTE: you can delink instead of remove this may cause loss of your existing data</pre><pre>    alter table(&quot;snaps&quot;) do</pre><pre>      remove :user_id </pre><pre>    end<br><br>    #NOTE: Altering user id from strign to integer</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      ALTER TABLE users ALTER COLUMN id type integer  using (id::integer);</pre><pre>    &quot;&quot;&quot;<br>    # NOTE: creating sequence id to define next value for user id</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      CREATE SEQUENCE users_id_seq;</pre><pre>    &quot;&quot;&quot;</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      ALTER TABLE users ALTER COLUMN id SET DEFAULT  nextval(&#39;users_id_seq&#39;);</pre><pre>    &quot;&quot;&quot;</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      ALTER TABLE users ALTER COLUMN id SET NOT NULL;</pre><pre>    &quot;&quot;&quot;</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      ALTER SEQUENCE users_id_seq OWNED BY users.id;</pre><pre>    &quot;&quot;&quot;<br>    <br>    #NOTE: setting up id value 1000 to start with.</pre><pre>    execute &quot;&quot;&quot;</pre><pre>      SELECT setval(&#39;users_id_seq&#39;, 1000);</pre><pre>    &quot;&quot;&quot;</pre><pre>    alter table(&quot;snaps&quot;) do</pre><pre>      add :user_id, references(:users, type: :integer)</pre><pre>    end</pre><pre>  end</pre><pre>  def down do</pre><pre>    execute &quot;&quot;&quot;</pre><pre>       alter table users alter column id type character varying(255);</pre><pre>    &quot;&quot;&quot;</pre><pre>  end<br>end</pre><blockquote>paste the above snippet by changing with your appropriate data and perform <strong>mix ecto.migrate</strong> your table will get migrated and will look like below:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*k--ih0mBUY26s_Lw-0yr-w.png" /></figure><p>Thank you for reading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed7c44d69d9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>