<?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 Helpshift Engineering Team on Medium]]></title>
        <description><![CDATA[Stories by Helpshift Engineering Team on Medium]]></description>
        <link>https://medium.com/@helpshift_tech?source=rss-1a0cf73de31c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2sxYrBv-4l35Bz6tfUzH1w.png</url>
            <title>Stories by Helpshift Engineering Team on Medium</title>
            <link>https://medium.com/@helpshift_tech?source=rss-1a0cf73de31c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:14:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@helpshift_tech/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[Saving inter-zone transfer costs in EC2 with HAProxy]]></title>
            <link>https://medium.com/helpshift-engineering/saving-inter-zone-transfer-costs-in-ec2-with-haproxy-c4217ac2ca04?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4217ac2ca04</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[high-availability]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Tue, 24 Apr 2018 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-05T07:42:50.293Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/perfect_ayush">Ayush Goyal</a></h4><p>TL;DR: We saved tens of thousands of dollars in ec2 inter-zone transfer costs by smartly routing traffic using haproxy.</p><p>At Helpshift, our infrastructure is hosted in EC2. Like any sensible infrastructure in EC2, we utilize multiple Availability Zones for high availability of services. A caveat of hosting services in this setup is the costly charges for inter-zone network transfers.</p><p>A couple of years back, we realized that our inter-zone transfer costs were a significant chunk of our monthly AWS costs. Upon further digging, we found out that most of this transfer was from our redis cache cluster.</p><p>The redis cluster had few slaves distributed in multiple availability zones. Clients were accessing one of the healthy slaves, discovered via Route53 health checked dns. The clients were dumb and making calls to slaves in other zones. We required a solution where clients will make calls to healthy slaves within same zone to avoid inter-zone transfer costs, but could access slaves in other zone in case of any unavailability in the same zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJX6rLKVNGPFKcUlf_LraQ.png" /></figure><p>An idea that popped to us was if clients could somehow achieve this with haproxy, a service we have come to rely on for nifty solutions. A quick look at the haproxy documentation pointed us to the <strong>backup</strong> config parameter for the server line. The <a href="http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.2-backup">haproxy docs</a> for this param reads:</p><blockquote>When “backup” is present on a server line, the server is only used in load balancing when all other non-backup servers are unavailable. Requests coming with a persistence cookie referencing the server will always be served though. By default, only the first operational backup server is used, unless the “allbackups” option is set in the backend.</blockquote><p>Another important configuration to lookout for when using <strong>backup</strong> parameter is <strong>option allbackups</strong> for the backend. <a href="http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-option%20allbackups">Haproxy documentation</a> explains it as follows:</p><blockquote>By default, the first operational backup server gets all traffic when normal servers are all down. Sometimes, it may be preferred to use multiple backups at once, because one will not be enough. When “option allbackups” is enabled, the load balancing will be performed among all backup servers when all normal ones are unavailable.</blockquote><p>All we had to do was setup haproxy on clients to access redis slaves with a configuration that takes availability zones of the client and redis slaves into account and mark slaves in other availability zones with <strong>backup</strong> parameter. This was easily achieved with an ansible template for haproxy configuration which used our ec2 inventory. So for a client node hosted in AZ1, the following configuration would be generated by ansible:</p><pre>frontend redisslave<br>    bind 127.0.0.1:6379<br>    mode tcp<br>    option tcp-smart-accept<br>    option splice-request<br>    option splice-response<br>    timeout client-fin 5s<br>    default_backend redis-slave-servers</pre><pre>backend redis-slave-servers<br>    mode tcp<br>    option tcp-smart-connect<br>    option splice-request<br>    option splice-response<br>    option allbackups<br>    timeout tunnel 70s<br>    server S1 10.0.0.1:6379 check        # S1 is in AZ1<br>    server S2 10.0.0.2:6379 check backup # S2 is in AZ2<br>    server S3 10.0.0.3:6379 check        # S3 is in AZ1<br>    server S4 10.0.0.4:6379 check backup # S4 is in AZ2</pre><p>With this config, the client can connect to redis slaves in it’s own availability zone via haproxy and will switch to redis slaves in other zone only if all slaves of the same zone are down. This solution was tested and deployed in production within couple of days and we observed significant reduction in the next month’s bill.</p><p>This also solved the issue of adding/removing new slave in the redis clusters without restarting the client service as each time a new slave was added to redis cluster all we had to do was update haproxy configuration via ansible on the client nodes. This solution has been working flawlessly in production for last couple of years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4217ac2ca04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/saving-inter-zone-transfer-costs-in-ec2-with-haproxy-c4217ac2ca04">Saving inter-zone transfer costs in EC2 with HAProxy</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tale of Timezones and how FP is the Easy Way]]></title>
            <link>https://medium.com/helpshift-engineering/tale-of-timezones-and-how-fp-is-the-easy-way-c4940f66d355?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4940f66d355</guid>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Thu, 08 Dec 2016 08:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:54:55.236Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://github.com/moizsj">Moiz Jinia</a></h4><h4>Business hours check for a global business: The problem statement</h4><p>Customer support teams of large global organizations have teams working in multiple geographies across multiple time zones. Each of these teams usually have their own set of business days and hours (in their respective time zones). Below is a Clojure map that represents an example business hours and days configuration for an org -</p><pre>(def test-business-timings<br>  {:business-days [true true false true true false true] ;; Mon-Sun<br>   :business-hours [;; Monday<br>                    [{:from {:hours 16 :minutes 0}<br>                      :to {:hours 17 :minutes 0}<br>                      :timezone &quot;Asia/Kolkata&quot;}<br>                     {:from {:hours 13 :minutes 0}<br>                      :to {:hours 18 :minutes 0}<br>                      :timezone &quot;America/Los_Angeles&quot;}]<br>                    ;; Tuesday<br>                    [{:from {:hours 8 :minutes 0}<br>                      :to {:hours 18 :minutes 0}<br>                      :timezone &quot;Pacific/Kiritimati&quot;}]<br>                    ;; Wednesday<br>                    []<br>                    ;; Thursday<br>                    [{:from {:hours 1 :minutes 0}<br>                      :to {:hours 3 :minutes 0}<br>                      :timezone &quot;UTC&quot;}<br>                     {:from {:hours 10 :minutes 0}<br>                      :to {:hours 18 :minutes 0}<br>                      :timezone &quot;Asia/Kolkata&quot;}]<br>                    ;; Friday<br>                    [{:from {:hours 0 :minutes 0} ;;all day<br>                      :to {:hours 0 :minutes 0}<br>                      :timezone &quot;US/Hawaii&quot;}]<br>                    ;; Saturday<br>                    []<br>                    ;; Sunday<br>                    [{:from {:hours 9 :minutes 0}<br>                      :to {:hours 17 :minutes 0}<br>                      :timezone &quot;US/Hawaii&quot;}]]})</pre><p>When a support ticket from a customer comes in, we need an automated way to check whether any of the global support teams are within business hours.</p><h4>Approaching the problem</h4><h4>Which day of the week is it for the support teams?</h4><p>Before making the check for business days, you need to determine what the current day of the week is (‘today’). You need to account for the possibilities that it might still be ‘yesterday’ in some timezone or may already be ‘tomorrow’ in some timezone. And a team in some timezone behind or ahead of the server time may be in business hours.</p><h4>On this day and at this time, do I have an actively working support team somewhere or not?</h4><p>When making a check for a specific business day, building the time interval for the specified business hours (for that day) needs to take into account both timezone and the notion of what is the current day.</p><h4>Solution</h4><h4>An approach that didn’t fly</h4><p>Convert all the input business hours to UTC before making the check. There are 2 problems with that approach -</p><ul><li>Shifting the business hours to UTC could mean crossing the day boundary (ahead or behind). And this gets complicated by the fact that we need to factor in business days (not just hours). We’d have to also build a transformed list of UTC business days.</li><li>We can’t store the business hours and days configuration in UTC format because the next time the user edits them, they’ll need to see it in the time zones they originally used.</li></ul><h4>The one that did</h4><p>The solution relies on the fact that no time zone in the world is more than a day apart from UTC. In other words, no matter what timezone you’re in, relative to the UTC day it could never be ‘day after tomorrow’ nor could it still be ‘day before yesterday’.</p><p>In order to solve this problem, we assume whatever is the current day of week per UTC to be our current day of week. And then we need to make the following 3 checks -</p><ul><li>whether ‘today’ is a business day, and whether ‘right now’ falls in ‘today’s’ business hours</li><li>whether ‘tomorrow’ is a business day, and whether ‘right now’ falls in ‘tomorrow’s’ business hours</li><li>whether ‘yesterday’ is a business day, and whether ‘right now’ falls in ‘yesterday’s’ business hours</li></ul><h4>Code</h4><p>Before I dive into the actual code, I’d like to side step a bit and dwell on how using Clojure (and FP in general) makes the solution intuitive.</p><h4>Functions are Fun. And natural.</h4><p>I started out as a Java programmer and I clearly remember that in my first few months at my first job, my natural tendency was to write a lot of C-style functions. And the way to do that in Java is to use static methods and classes. And this immediately stands out as a code smell or bad practice in the object oriented Java world. You need to think about modeling things as ‘real world objects’ I was told. Whatever that meant. Of course I adapted, moved on and eventually became a ‘good’ Java programmer. Working with Clojure now has made me rediscover that long lost natural tendency. I now write code in the style that is most obvious from a logic perspective. Little functions that each do one thing. I’ve come full circle — from instinctively thinking that functions are good, to being told that functions are bad, to finally understanding that functions are good. Java 8 now has functions you may say. But the truth is that just ‘supporting’ or ‘allowing’ functions as first class citizens is very different from a being a functional language at the heart. Which Java 8 certainly isn’t.</p><p>IMHO — an important characteristic of good code is that it makes the code look simple or easy. Its like a good batsman (in cricket) makes batting look easy. And this is something that I find in abundance in the Clojure ecosystem.</p><h4>Clojure’s awesome date time lib : <a href="https://github.com/clj-time/clj-time">clj-time</a></h4><p>Clojure has a feature rich, intuitive, and expressive date time library called clj-time. It’s an excellent example of what an easy-to-use API should look like. And using such a lib adds to the simplicity and elegance of your code.</p><h4>Lets write the code</h4><p>We’ll walk through and build the solution from the bottom up. The intent is to highlight how functional programming is the most natural way of building a solution with small, coherent, re-usable and composable functions.</p><p>We first create a Clojure NS for the solution. The only external lib we need is the above mentioned date time lib.</p><pre>(ns business-timings.core<br>  (:require [clj-time.core :as t]))</pre><p>First off, three simple functions that tell us ‘today’, ‘tomorrow’, and ‘yesterday’ for a specific UTC date time instance. Each of these return a number in the range of 1–7 representing the day of the week.</p><pre>(defn- today<br>  [dt]<br>  (t/day-of-week dt))</pre><pre>(defn- tomorrow<br>  [dt]<br>  (t/day-of-week (t/plus dt (t/days 1))))</pre><pre>(defn- yesterday<br>  [dt]<br>  (t/day-of-week (t/minus dt (t/days 1))))</pre><pre>Now, a couple of functions that allows us to read the business hours for a specified day of week, and tell us whether a given day is a business day or not.</pre><pre>(defn- business-day?<br>  [day business-timings]<br>  ;; decerement day for zero based index<br>  (get (:business-days business-timings) (dec day)))</pre><pre>(defn- timings-for-day<br>  [day business-timings]<br>  ;; decerement day for zero based index<br>  (get (:business-hours business-timings) (dec day)))</pre><pre>Lets now use all the above to create functions that can tell us the corresponding timings for today, tomorrow, and yesterday. And whether they are business days.</pre><pre>(defn- timings-today<br>  [business-timings dt]<br>  (timings-for-day (today dt) business-timings))</pre><pre>(defn- timings-tomorrow<br>  [business-timings dt]<br>  (timings-for-day (tomorrow dt) business-timings))</pre><pre>(defn- timings-yesterday<br>  [business-timings dt]<br>  (timings-for-day (yesterday dt) business-timings))</pre><pre>(defn- business-day-today?<br>  [business-timings dt]<br>  (business-day? (today dt) business-timings))</pre><pre>(defn- business-day-tomorrow?<br>  [business-timings dt]<br>  (business-day? (tomorrow dt) business-timings))</pre><pre>(defn- business-day-yesterday?<br>  [business-timings dt]<br>  (business-day? (yesterday dt) business-timings))</pre><pre>Next, once we’ve read the business hours for a day, we’ll need some functions to help us build the actual time intervals for those business hours. In other words, the date time instances corresponding to the start time and end time of the business hours (on a given day). Note - these start and end date-time instances will need to be created in the timezone used in the configuration.</pre><pre>(defn- business-hours-start-today<br>  [time-slot dt]<br>  (t/from-time-zone<br>    (t/date-time (t/year dt) (t/month dt) (t/day dt)<br>                 (get-in time-slot [:from :hours])<br>                 (get-in time-slot [:from :minutes]))<br>    (t/time-zone-for-id (:timezone time-slot))))</pre><pre>(defn- business-hours-end-today<br>  [time-slot dt]<br>  (let [end-hour (get-in time-slot [:to :hours])<br>        end-minute (get-in time-slot [:to :minutes])]<br>    (t/from-time-zone<br>      (if (every? zero? [end-hour end-minute])<br>        (t/date-time (t/year dt) (t/month dt) (t/day dt) 23 59 59 999)<br>        (t/date-time (t/year dt) (t/month dt) (t/day dt) end-hour end-minute))<br>      (t/time-zone-for-id (:timezone time-slot)))))</pre><pre>(defn- busines-hours-start-yesterday<br>  [time-slot dt]<br>  (t/minus (business-hours-start-today time-slot dt) (t/days 1)))</pre><pre>(defn- business-hours-end-yesterday<br>  [time-slot dt]<br>  (t/minus (business-hours-end-today time-slot dt) (t/days 1)))</pre><pre>(defn- business-hours-start-tomorrow<br>  [time-slot dt]<br>  (t/plus (business-hours-start-today time-slot dt) (t/days 1)))</pre><pre>(defn- business-hours-end-tomorrow<br>  [time-slot dt]<br>  (t/plus (business-hours-end-today time-slot dt) (t/days 1)))</pre><pre>Lets now use the above to create check functions for today, tomorrow, and yesterday. The check passes if the specified date time instance falls in any of the time slots configured for a particular day. As you may remember, the problem statement requires allowing multiple different time slots for the same day (each with its own timezone). We use clj-time’s <a href="https://github.com/clj-time/clj-time/blob/master/src/clj_time/core.clj#L619">within?</a> function (which is timezone aware) to make this check. Hence we don’t need to shift the specified date time instance to the timezone used for the business hours.</pre><pre>(defn within-todays-business-timings?<br>  [business-timings dt]<br>  (when (business-day-today? business-timings dt)<br>    (let [time-slots (timings-today business-timings dt)]<br>      (some (fn [time-slot]<br>              (t/within? (business-hours-start-today time-slot dt)<br>                         (business-hours-end-today time-slot dt)<br>                         dt))<br>            time-slots))))</pre><pre>(defn within-tomorrows-business-timings?<br>  [business-timings dt]<br>  (when (business-day-tomorrow? business-timings dt)<br>    (let [time-slots (timings-tomorrow business-timings dt)]<br>      (some (fn [time-slot]<br>              (t/within? (business-hours-start-tomorrow time-slot dt)<br>                         (business-hours-end-tomorrow time-slot dt)<br>                         dt))<br>            time-slots))))</pre><pre>(defn within-yesterdays-business-timings?<br>  [business-timings dt]<br>  (when (business-day-yesterday? business-timings dt)<br>    (let [time-slots (timings-yesterday business-timings dt)]<br>      (some (fn [time-slot]<br>              (t/within? (busines-hours-start-yesterday time-slot dt)<br>                         (business-hours-end-yesterday time-slot dt)<br>                         dt))<br>            time-slots))))</pre><pre>And now the final check function that will essentially be the API for this NS. And it’ll use all the functions we have defined so far. The check passes if the specified date time instance falls in either today, tomorrow, or yesterday’s business hours.</pre><pre>(defn within-business-timings?<br>  [business-timings dt]<br>  (or (within-todays-business-timings? business-timings dt)<br>      (within-tomorrows-business-timings? business-timings dt)<br>      (within-yesterdays-business-timings? business-timings dt)))</pre><pre>(comment (within-business-timings? test-business-timings (t/now)))</pre><pre>Summary</pre><pre>Functional programming is not about coolness or the bleeding edge. Rather it is - in my humble opinion - the most natural and easy way to solve a problem. With the side benefit that its also cool, and the bleeding edge. For full code and tests, see here <a href="https://github.com/moizsj/business-timings/">https://github.com/moizsj/business-timings/</a>.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4940f66d355" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/tale-of-timezones-and-how-fp-is-the-easy-way-c4940f66d355">Tale of Timezones and how FP is the Easy Way</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Herald — Haproxy load feedback and check agent]]></title>
            <link>https://medium.com/helpshift-engineering/herald-haproxy-load-feedback-and-check-agent-1b8749a13f02?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b8749a13f02</guid>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[load-balancing]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Mon, 10 Oct 2016 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:53:36.885Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/rag_s">Raghu Udiyar</a></h4><p>Today we are excited to to open source <a href="https://github.com/helpshift/herald">Herald</a> — a load feedback and check agent for <a href="http://haproxy.org/">Haproxy</a>.</p><p>Herald is the agent service for the agent-check feature in Haproxy. This feature allows a backend server to issue commands and control its state in Haproxy. This can be used for out of band health checks, or load feedback (which we explain below), and many other use cases.</p><h3>Background</h3><p>At Helpshift we swear by Haproxy, which is an extremely powerful and versatile load balancer.</p><p>Haproxy is used to balance requests from a frontend (client facing interface) to a pool of backend servers. For simple http requests the roundrobin balancing algorithm works well. But for long lived connections, an even balancing is not achieved. The leastconn balancing method helps to a certain extent - here the requests are sent to the backend with least connections - but in a cluster of Haproxy nodes, this doesn’t work, as no state regarding the connections is shared between the clustered haproxy nodes.</p><p>To solve this, we need a mechanism to regulate traffic sent by haproxy, depending on the load condition of the respective backend server in realtime. We built Herald to solve this load feedback use case.</p><h4>Load feedback</h4><p>As the name suggests, the backend servers can send feedback to Haproxy and regulate its incoming traffic. The application on the backends must expose its load status (a metric such as rps) over some interface, such as http.</p><p>When agent-check is enabled, Haproxy periodically opens a tcp connection to herald running on the backend servers. The agent on the server queries the application via the load status interface, and replies back with a weight percentage, say 75%. This directs haproxy to reduce the traffic sent to this node by that percent difference. This percentage can keep changing as per the current traffic condition.</p><p>Besides regulating load percentage, the reponse can also be an Haproxy action, such as MAINT, DOWN, READY, UP etc. The Haproxy documentation <a href="https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#5.2-agent-check">here</a> has more details on agent-check.</p><h3>Herald</h3><p>Herald is the Haproxy agent that runs on the backends. It has been designed to be generic, with a plugin architecture that along with load feedback can be used for other use cases as well.</p><p>The agent has two responsibilities:</p><ol><li>Respond to Haproxy agent requests, and</li><li>Query backend application, and calculate the haproxy agent response</li></ol><p>The following illustrates this simple architecture :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*EeoH9bmIRabRZSx_91_UhA.png" /></figure><h4>Plugins</h4><p>Herald plugins do the job of querying the application and interpreting the result. Plugins for file and http are available, others can be easily added.</p><p>Following features are provided out of the box by the plugin framework:</p><ul><li>Response result cacheing</li><li>Json parsing and processing parsed data using python dict expressions</li><li>Arthmetic expressions on the result</li><li>Regex pattern matching on the result</li><li>Fallback in case of failures</li></ul><h4>Performance</h4><p>Being entirely network and IO driven, we chose to use <a href="http://www.gevent.org/">gevent</a>, a coroutine based python networking library. Gevent uses <a href="https://pypi.python.org/pypi/greenlet">greenlets</a>, to spawn cooperatively scheduled tasks, which yield when blocked, such as when waiting for IO. The resulting code is very simple, and highly performant.</p><p>We have been using Herald in production for almost a year with no issues, on a cluster with 100+ instances (depending on autoscaling), serving requests from a cluster of 10+ load balancers. We have had 100% uptime on our load feedback and agent check system.</p><h3>Code and Documentation</h3><p>The source code is on Helpshift <a href="https://github.com/helpshift/herald">github</a> page. Please follow the README for installation and configuration instructions. We hope Herald is useful to others. Feature and pull requests are most welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b8749a13f02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/herald-haproxy-load-feedback-and-check-agent-1b8749a13f02">Herald — Haproxy load feedback and check agent</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing business logic using DSLs in Clojure]]></title>
            <link>https://medium.com/helpshift-engineering/testing-business-logic-using-dsls-in-clojure-bb7d6235f562?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb7d6235f562</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[dsl]]></category>
            <category><![CDATA[clojure]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Fri, 20 Nov 2015 08:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:51:54.085Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/firesofmay">Mayank Jain</a></h4><h3>Background</h3><p>Testing business logic quickly becomes tricky, as applications grow and scale. Example based unit and integration tests, and exploratory tests become poor choices to check and verify a large state space. Also such methods are not well-suited to clearly describe the state space / transitions we want to test.</p><p>For quite some time I have been experimenting with DSLs to write our tests at Helpshift. I recently gave a talk on “Testing business logic using DSLs in Clojure” at Functional Conf this year. I have shared my learning in the talk. Hope you enjoy it. Feel free to ask me any questions if you have.</p><h3>Talk</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYOsfPrgNY_M%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYOsfPrgNY_M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYOsfPrgNY_M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c9eff53fe5a24c610ef3293fe84f25b/href">https://medium.com/media/6c9eff53fe5a24c610ef3293fe84f25b/href</a></iframe><h3>Slides</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F8bea2a3d4e814f19afe0f2369df2d36b&amp;url=https%3A%2F%2Fspeakerdeck.com%2Ffiresofmay%2Ftesting-business-logic-using-domain-specific-languages-dsls-in-clojure&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F8bea2a3d4e814f19afe0f2369df2d36b%2Fslide_0.jpg%3F319756&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdc7d981d2cc576100fdbd45eacb687f/href">https://medium.com/media/fdc7d981d2cc576100fdbd45eacb687f/href</a></iframe><p>If this sounds interesting to you, <a href="https://www.helpshift.com/about/careers/">we are hiring, join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb7d6235f562" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/testing-business-logic-using-dsls-in-clojure-bb7d6235f562">Testing business logic using DSLs in Clojure</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating Gerrit from Google OpenID to Oauth]]></title>
            <link>https://medium.com/helpshift-engineering/migrating-gerrit-from-google-openid-to-oauth-c9aeb32078e?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9aeb32078e</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[openid]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Fri, 10 Apr 2015 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:49:43.199Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/rag_s">Raghu Udiyar</a></h4><p>Google is phasing out <a href="https://developers.google.com/+/api/auth-migration">OpenID in favour of Oauth 2.0</a> with a deadline on 20th April, 2015 — just 10 days from today. A lot of projects depend on google auth, and can’t easily move to another OpenID provider. I recently had to fix this issue with Jenkins and Gerrit.</p><p>Jenkins has a great <a href="https://wiki.jenkins-ci.org/display/JENKINS/Google+Login+Plugin">plugin</a> available for this, which was a piece of cake to install and configure. But it wasn’t so easy with Gerrit. Lot of gerrit users have been asking for <a href="https://code.google.com/p/gerrit/issues/detail?id=2677">Oauth support</a> since May last year; we got that finally when <a href="https://github.com/davido">David Ostrovsky</a> wrote <a href="https://github.com/davido/gerrit-oauth-provider">gerrit-oauth-provider</a> plugin.</p><p>I’ve listed the steps I followed below :</p><ol><li>Oauth2 credentials. <br>Get these from <a href="https://console.developers.google.com/">Google Developers Console</a>, note down the client id and client secret. Ensure the redirect url is set to /oauth i.e. <a href="http://gerrit.yoursite.com/oauth.">http://gerrit.yoursite.com/oauth.</a></li><li>Get the custom gerrit war file. There are a few gerrit <a href="https://gerrit-review.googlesource.com/#/q/topic:hybrid-openid-oauth-authentication-provider">changes</a> the plugin needs that haven’t been merged yet. A custom war is available <a href="https://github.com/davido/gerrit-oauth-provider/releases/tag/v0.2">here</a> with the plugin. Download this gerrit-2.10.2-18-gc6c5e0b.war file to the new gerrit server.</li><li>Backup current gerrit data. Create tarballs of the data directories and dump postgres data (if postgres is being used)<br>old-gerrit~$ tar czpf gerrit.tar.gz /srv/gerrit/gerrit<br> old-gerrit~$ tar czpf repositories.tar.gz /srv/gerrit/repositories<br> old-gerrit~$ pg_dump -xO -Fc reviewdb &gt; reviewdb-$(date +%d-%m-%Y).pdump</li><li>Restore data to new gerrit server<br>gerrit:/srv/gerrit$ tar xzpf repositories.tar.gz<br> gerrit:/srv/gerrit$ tar xzpf gerrit.tar.gz</li><li>Restore pg data<br>psql : ALTER USER gerrit WITH SUPERUSER;<br>$ dropdb reviewdb<br>$ createdb reviewdb -O gerrit<br>$ pg_restore -O -d reviewdb --role=gerrit reviewdb-20-03-2015.pdump<br>psql: ALTER USER gerrit WITH NOSUPERUSER;</li><li>Run migrations<br>Gerrit requires cascading migrations to be run for every major version released. For e.g to update from 2.5 to 2.10, we have to run the following<br>$ sudo su - gerrit -s /bin/bash<br>$ java -jar gerrit-2.8.6.1.war init -d gerrit<br>$ java -jar gerrit-2.9.4.war init -d gerrit<br>$ java -jar gerrit-2.9.4.war reindex --recheck-mergeable -d gerrit<br><br>For the custom jar migration be sure to configure the Oauth plugin<br>$ java -jar gerrit-2.10.1–4-a83387b.war init -d gerrit<br> […]<br> OAuth Authentication Provider Use Google OAuth provider for Gerrit login ? [Y/n]?<br> Application client id : <br> Application client secret : <br> confirm password :<br> Link to OpenID accounts? [true]:<br> Use GitHub OAuth provider for Gerrit login ? [Y/n]? n<br>$ java -jar gerrit-2.10.1–4-a83387b.war reindex -d gerrit</li><li>Switch old gerrit domain name to the new server<br>For automatic acount linking to work, the domain name must match the old server. Otherwise the OpenID accounts will not be linked with the new Oauth2 account.</li><li>Start gerrit server and confirm everything works<br>gerrit:/srv/gerrit$ ./bin/gerrit.sh start</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9aeb32078e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/migrating-gerrit-from-google-openid-to-oauth-c9aeb32078e">Migrating Gerrit from Google OpenID to Oauth</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolution of the Helpshift Unity plugin]]></title>
            <link>https://medium.com/helpshift-engineering/evolution-of-the-helpshift-unity-plugin-19a5ab28dfef?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/19a5ab28dfef</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Mon, 16 Mar 2015 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:47:08.144Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/rhishikeshj">Rhishikesh Joshi</a></h4><h4>Background</h4><p><strong>“Make integration easier. No this is too much work for the devs, make it even easier”</strong></p><p>This has been a line which is constantly heard if you wander over to the Mobile SDK team here at Helpshift. This is something that we have tried to strictly adhere to. We have made rapid strides in that direction for both our iOS and Android native SDKs.<br>Gradle and Maven support has made our Android integration as simple as adding a single line.<br>The <a href="http://hlp.bz/HelpshiftIntegrationAssistant">Helpshift Integration Assistant</a> has turned the Helpshift iOS integration as easy as installing any software on your Mac.</p><p>But sadly, we have lacked that kind of sophistication with our Unity plugins. The Helpshift Unity integration is still tedious, confusing and fraught with errors when interacting with other Unity plugins.<br>So we had to fix this situation.</p><h4>Why it is important</h4><p>Gaming has been one of our champion verticals when it comes to the Helpshift CRM solution. We have made quite a foray into the Gaming market and many of the top game companies, including Supercell, have been using our product for some time now. And a majority of the Game studios today use Unity for developing their games.</p><p>With a lot of adoption, comes a lot of different scenarios. We have had a ton of feedback from our customers about our Unity plugin.<br>Customers didn’t like the fact that we had 2 separate plugins for iOS and Android. They ran into issues due to conflicts with other plugins.<br>The variety of folder structures that game devs follow complicated matters for us even further.<br>This meant a big roadblock for all important customers and too much time spent in integration which undermined the core philosophy of the SDK team.</p><h4>Humble beginnings</h4><p>A bit of history is always good to set things in the right context.<br>About a year and a half back, when we had just released the 1.0 version of the Helpshift SDK, our CTO, <a href="http://www.twitter.com/ghoseb">bg</a> came to me and gave me a challenge.<br>“There’s this game development engine, Unity or something. Go and see if you can make our SDK work with a Unity game!”<br>That led to a frantic 4 hour hack into making a Unity app and integrating our iOS SDK with it. The C# API was basically a single function back then which would launch the FAQs screen from our SDK.<br>And integrating the plugin meant manually copying files over from one location to another.<br>Since then, we kept making improvements piece-meal to the Unity plugin and the integration process too. But there were still gaping holes in the whole thing.</p><h4>The improvements</h4><h4>One plugin to rule them all</h4><p>As we found out to our woe, distributing 2 separate plugins for iOS and Android was not ideal. We had to unify the packaging as well as the Helpshift API. This was fairly easy to achieve by creating a common API wrapper and adding <em>UNITY_IOS</em> and <em>UNITY_ANDROID</em> conditionals in there.</p><h4>The plugin should be a <em>Unitypackage</em></h4><p>This was one of the most frequent feedbacks that we kept getting. Unity offers an easy way to add files to the project -&gt; the <em>.unitypackage</em>. We needed to distribute our plugin in the same way to make it easier for developers to add the Helpshift SDK.<br>Turned out, it was easy to create a <em>.unitypackage</em> from the Unity Studio UI but we wanted to make it part of the release process which meant we had to do it via the command line.<br>Fortunately for us, some google searching led us to a good starting point.<br>Given below is the shell script that we use to create a <em>.unitypackage</em> from an existing Unity project.</p><pre>#!/bin/bash<br># Exports the Helpshift unitypackage from given Unity project<br># arg-1 : path of the Unity project where Helpshift is integrated<br># arg-2 : path where file needs to be exported<br># arg-3 : version number<br>if [ &quot;$#&quot; -ne 3 ] || ! [ -d &quot;$1&quot; ]; then<br>    echo &quot;Usage: $0 &lt;path_to_Unity_project&gt; &lt;output_path&gt; &lt;version_number&gt;&quot; &gt;&amp;2<br>exit 1<br>fi</pre><pre>BIN_PATH=/Applications/Unity/Unity.app/Contents/MacOS<br>BIN_FILE=Unity</pre><pre>PROJECT_PATH=$1<br>EXPORT_PATH=$2<br>EXPORT_FILE=plugin-name.unitypackage<br>DIR_1=Assets/&lt;dir containing your plugin files&gt;<br>DIR_2=Assets/Plugins/Android # for android plugin related files<br>&quot;$BIN_PATH/$BIN_FILE&quot; -batchmode -projectPath &quot;$PROJECT_PATH&quot; -logFile export.log -exportPackage &quot;$DIR_1&quot; &quot;$DIR_2&quot; &quot;$EXPORT_PATH/$EXPORT_FILE&quot; -quit</pre><h4>Remove conflicts with other Unity plugins</h4><p>One of the things that was a constant pain for us was the conflicts with Unity plugins like Facebook which used the <a href="https://github.com/dcariola/XCodeEditor-for-Unity">XCode Editor for Unity</a> project to modify the XCode project generated by Unity. We internally used the more humble <em>mod_pbxproj</em> python file which did everything we wanted to do and did it well.<br>But the XCodeEditor project unfortunately messed around with the XCode project after we were done adding our files to it. Specifically, it removed any <strong>PBXVariantGroups</strong> which were present in the project. This meant our Localization files went for a toss and app could not see any strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*939qV85ELecrAuQeOaGa5g.jpeg" /></figure><p>To get around this issue, we had to make sure that our integration ran after any conflicting plugins and that we adopted this integration method right from the start.<br>To achieve this, we had to add the <em>HelpshiftPostProcess.cs</em> file which could take a <em>PostProcessBuild</em> attribute which could be set to a high value. The higher the value, the later in the process it would be run.<br>This file should be a <em>Monobehaviour</em> type of script which lies in the Editor folder of your plugins subfolder.<br>For example, <em>Assets/Helpshift/Editor/HelpshiftPostProcess.cs</em></p><pre>using System;<br>using UnityEngine;<br>using UnityEditor;<br>using UnityEditor.Callbacks;</pre><pre>using System.Diagnostics;<br>using System.Collections;<br>#if UNITY_IOS || UNITY_ANDROID<br>using Helpshift;<br>#endif<br>public class HelpshiftPostProcess : MonoBehaviour<br>{<br>  // Set PostProcess priority to a high number to ensure that the this is started last.<br>  [PostProcessBuild(900)]<br>  public static void OnPostprocessBuild(BuildTarget target, string pathToBuildProject)<br>  {<br>    HelpshiftConfig.Instance.SaveConfig();<br>    const string helpshift_plugin_path = &quot;Assets/Helpshift&quot;;<br>    // Current path while executing the script is<br>    // the project root folder.<br>    Process myCustomProcess = new Process();<br>    myCustomProcess.StartInfo.FileName = &quot;python&quot;;<br>    myCustomProcess.StartInfo.Arguments = string.Format(helpshift_plugin_path + &quot;/Editor/HSPostprocessBuildPlayer &quot; + pathToBuildProject + &quot; &quot; + target);<br>    myCustomProcess.StartInfo.UseShellExecute = false;<br>    myCustomProcess.StartInfo.RedirectStandardOutput = false;<br>    myCustomProcess.Start();<br>    myCustomProcess.WaitForExit();<br>  }<br>}</pre><h4>Make the Unity Android plugin integration easier</h4><p>The current Unity android plugin involves manually adding entries to an existing <em>AndroidManifest.xml</em> file, combining our <em>res</em> folder with the existing <em>res</em> folders. It was all a pain and there was minimal isolation of the Helpshift files. Recently, Unity added support for integrating Android library projects present in the <em>Assets/Plugins/Android</em> folder. We decided to take advantage of this fact and distribute our plugin the same way. Now our Android integration just involves the <em>Helpshift</em> library project to the <em>Assets/Plugins/Android</em> folder and letting Unity take care of the rest.</p><h4>Add Push notifications support</h4><p>One of the difficult to achieve features for us was Push notification integration with Helpshift. There seemed to be too many different push plugins which each did things their own way. This led to many problems for our users to effectively use the excellent Push support which our backend systems provide.<br>To get around this problem, we basically had to develop our own Unity push plugins which were built in to the SDKs. This was comparitively easy to do on the Android platform, but for iOS we had to resort to the black art of <em>Method swizzling</em>.<br>But we had to make sure that there was a way for the app developers to switch this support off in the off-chance that the App store rejects the app. (We have contacted Apple support and made sure that the way we use swizzling is not something that is cause for rejection.)</p><p>To use the in-built push support, developers can simply add the below API:</p><pre>HelpshiftSdk.registerForPush(&lt;gcm-key-for-android/ignored-for-ios&gt;)</pre><h4>Make the SDK configuration easy for developers</h4><p>This was actually one of the interesting snippets of feedback that we got from our awesome customers. To quote - “If you could add like a GUI inspector to configure the Helpshift SDK, that would be really hot!”<br>We figured, let’s give that a try. We had to go through some pretty unclear documentation about how to create a <em>CustomEditor</em> in Unity.<br>Basically it involves creating an Object which derives from the <em>Editor</em> class and overriding the <strong>OnInspectorGUI</strong> method inside it.<br>Then all we had to do was create the UI using the widgets in the <em>EditorGUILayout</em> class.<br>To store the configuration values, we wrote a <em>Scriptableobject</em> which would hold all the values returned from the GUI. Saving the values could be done when the build was about to be created.<br>We used the <em>AssetDatabase</em> class and it’s methods to achieve this result.</p><pre>AssetDatabase.CreateAsset(instance, fullPath);</pre><p>Just a footnote, make sure all your instance members are Serializable by adding the <em>[SerializeField]</em> annotation. If you want to add some MenuItems to the Unity editor, you can do so by adding code snippets like below to the <em>Editor</em> class.</p><pre>[MenuItem(&quot;Helpshift/Edit Config&quot;)]<br>public static void Edit()<br>{<br>	Selection.activeObject = Instance;<br>}</pre><pre>[MenuItem(&quot;Helpshift/Developers Page&quot;)]<br>public static void OpenAppPage()<br>{<br>	string url = &quot;https://developers.helpshift.com/unity/&quot;;<br>	Application.OpenURL(url);<br>}</pre><p>The next step for us was actually passing along this configuration information to the XCode and Android projects. To do that we resorted to using JSON. The class which hold the config values would spit out the json representation of the configuration. These JSON files would then be added to the XCode project as simple data files and to the Android project as raw resources placed in the <em>res/raw</em> folder. Some wiring code to read them from the native SDKs and we were ready to roll.</p><p>The result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTMUddV8GbUEx-QOHrENIA.png" /><figcaption>Unity Config Editor</figcaption></figure><h3>Conclusion</h3><p><strong>Always listen to your customers</strong></p><p>In conclusion, I would really love to thank all of our existing customers who gave us awesome constructive feedback and spurred us on to better our own standards.<br>Hopefully all of you will love the changes that we have made, and also come up with even better suggestions to help us keep improving ourselves.</p><p><em>Exciting times ahead.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19a5ab28dfef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/evolution-of-the-helpshift-unity-plugin-19a5ab28dfef">Evolution of the Helpshift Unity plugin</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Data Stack from Scratch]]></title>
            <link>https://medium.com/helpshift-engineering/building-a-data-stack-from-scratch-6a575983fabd?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a575983fabd</guid>
            <category><![CDATA[tech-stack]]></category>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Fri, 24 Oct 2014 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:44:05.699Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/vinayakh">Vinayak Hegde</a></h4><h4>Background</h4><p><a href="https://fifthelephant.in/2014/">Fifth Elephant</a> (organised by <a href="https://hasgeek.com/">hasgeek</a>) is probably one of the best conferences focussed on Data in India (I am biased though as I am on the Editorial Panel that curates the talks :) I gave a talk on “How to build a Data Stack” at this years edition. It was well-received as many people came up to me after my talk and asked quite a few interesting questions about their stack. I build a Data stack at <a href="http://www.akamai.com/">Akamai</a> and then <a href="http://www.inmobi.com/">Inmobi</a>. Now I am doing the same at <a href="http://www.helpshift.com/">Helpshift</a>. Each time, the same questions were asked but the answers were different due to context and the maturity of the data ecosystem. I have refined these learnings in the talk. Hope you enjoy it. Send me any questions you have, as I am always curious of how people build their stack and the learnings from them.</p><h4>Talk</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjL1M_laCXj8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjL1M_laCXj8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjL1M_laCXj8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b355660b0f1f188d3b0e28f1f1ac5481/href">https://medium.com/media/b355660b0f1f188d3b0e28f1f1ac5481/href</a></iframe><h4>Slides</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F9e397700f5930131a07a7e9876799a8f&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fhelpshift%2Fhow-to-build-a-data-stack-from-scratch&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F9e397700f5930131a07a7e9876799a8f%2Fslide_0.jpg%3F110914&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/3385dfffea105ad2ec233ade51895ec9/href">https://medium.com/media/3385dfffea105ad2ec233ade51895ec9/href</a></iframe><p>If you’re interested in working in a fast paced team, <a href="https://www.helpshift.com/about/careers/">we are hiring, join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a575983fabd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/building-a-data-stack-from-scratch-6a575983fabd">Building a Data Stack from Scratch</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data layer Architectures for Mobile applications]]></title>
            <link>https://medium.com/helpshift-engineering/data-layer-architectures-for-mobile-applications-b5fa275e64b?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5fa275e64b</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Tue, 07 Oct 2014 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:42:52.381Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/rhishikeshj">Rhishikesh Joshi</a></h4><h4>Background</h4><p>Mobile applications are becoming ubiquitous in our day to day lives. They are capable of performing a wide range of tasks. They can wake us up in the morning, help us with our work out, track the calories we eat, help us stay on top of work and stay in touch with friends. They can even <a href="https://play.google.com/store/search?q=drink+water+reminder&amp;c=apps">remind us to drink water</a> on time !</p><p>Admittedly there are a lot of below average apps out there. But let’s not focus on them for now.<br>Let’s talk about the really great ones. What factors make them great ?<br>There are many factors that go into making a great app. Features, functionality, stability. But most people would agree it has to do with the design language of the app. The way the app engages its user is of highest priority.</p><p>But there is another important factor which gets overlooked; the efficiency of the Data layer of the application. In today’s age of ultra connected, thin-client design style of writing apps, the design of the Data layer is of utmost importance too.</p><p>At <a href="http://www.helpshift.com/">Helpshift</a>, due to the nature of the product, our mobile SDK is highly data intensive. Sending data to our servers reliably and fetching updates periodically and efficiently are the two main goals of our design.</p><p>In this post, I will try and share the knowledge that we have gathered in the process of designing such a model.</p><h4>Challenges</h4><p>There are some unique challenges in creating data-centric thin-client apps for mobiles.</p><ol><li>Restrictions on bandwidth usage : Mobile data is a valuable commodity and mobile developers should try and minimize the data exchange on the network.</li><li>Restrictions on battery and resource usage : If an app is using the network too much or too frequently, it will eat up device resources very fast. The user will very quickly get rid of such an app.</li><li>Accounting for fault tolerance and network errors : Mobile networks are inherently flaky and prone of glitches. A good application should take these glitches in its stride.</li><li>Being responsive and fast with data transactions : All said and done, being fast with data is the most important challenge of good data layer design.</li></ol><p>All of the above challenges need to be accounted for from the start when designing a mobile application.<br>We have faced a similar set of challenges at Helpshift and described below is our attempt at overcoming them.</p><h4>High level design</h4><p>We have gone through many iterations of our SDK design, especially the data layer. As we keep adding capabilities and features, the design continues to evolve.<br>Described below is just the current state of the data architecture.</p><p>These are the key guidelines which we try to adhere to:</p><ol><li>Loosely coupled components which interact with each other through a well defined interface.</li><li>Single responsibility assigned to each component.</li><li>Keep statefulness isolated and minimized.</li></ol><h4>Brief description of each component</h4><h4>Data model</h4><p>This layer holds all the business logic of the Helpshift API.</p><p>The main responsibilities of the <strong>Data model</strong> are :</p><ol><li>Providing interfaces to the <strong>UI layer</strong> for getting data such a FAQs, all the messages for a conversation etc.</li><li>Polling in the background to fetch the latest updates to a conversation and its state (In-Progress, Resolve-Requested etc)</li><li>Creating stub objects for the data before forwarding the request to the API layer. This ensures that the UI gets the newly created data as soon as possible.</li><li>Interacting with the <strong>Storage</strong> layer and updating the database in response to add actions from the UI and updates coming from the Servers.</li></ol><p>A typical <strong>Data Model</strong> API will look like this :</p><pre>[HSIssueModel createIssue:issueText<br>                onSuccess:^(id newIssue) {<br>                    issue = [HSIssueModel getIssue:[newIssue objectForKey:@&quot;id&quot;]];<br>                    STAssertNotNil(issue, @&quot;Could not add the issue in Db&quot;);<br>                }<br>                onFailure:^() {<br>                    STFail(@&quot;Failed to create an issue&quot;);}];</pre><h4>Storage</h4><p>This layer forms the main data store of the SDK.<br>At Helpshift, we use the <strong>sqlite</strong> database and raw sqlite queries. We prefer the flexibility and clarity provided by raw SQL as opposed to any ORM.</p><p>The main responsibilites of this layer are :</p><ol><li>Storage and retrieval of data related to FAQs and Conversations.</li></ol><p>A typical <strong>Storage</strong> API will look like this :</p><pre>[HSIssuesDb createIssue:issue forProfile:PROFILE_ID];</pre><h4>API layer</h4><p>This layer serves as the client for the REST API exposed by the Helpshift servers.<br>Every request will spawn a new thread of execution so as not to interfere with the UI thread.</p><p>The main responsibilities of this layer are :</p><ol><li>Making GET/POST requests to the backend servers in response to <strong>Data model</strong> requests.</li><li>Handling responses from the servers and forwarding them to the <strong>Retry Queue</strong>.</li></ol><p>A typical <strong>API layer</strong> API will look like this :</p><pre>[HSIssueCalls createIssue:[NSString stringWithFormat:@&quot;This is a not so random issue created at : %.2f, [[NSDate date] timeIntervalSince1970]]<br>               forProfile:PROFILE_ID<br>                onSuccess:^(id jsonData) {<br>                    STAssertNotNil(jsonData, @&quot;We could not create an issue.&quot;);<br>                }<br>                onFailure:^(void) {<br>                    NSLog(@&quot;Royal failure&quot;);<br>}];</pre><h4>Retry Queue</h4><p>This is the fault tolerance layer of the SDK. The <strong>API layer</strong> will forward all the failed request packets to this layer. This can be a continuous thread running in the background which flushes the Queue periodically. The <strong>API layer</strong> will forward the SuccessHandler received from the <strong>Model</strong> layer which will be triggered on successful completion of a request packet in the <strong>Retry Queue</strong></p><p>The main responsibilities of this layer are :</p><ol><li>Accepting failed request packets from the <strong>API layer</strong>.</li><li>Periodically flushing the Queue to make sure all the failed requests are completed successfully.</li><li>Informing the <strong>Data model</strong> of the successful completion.</li></ol><p>A typical <strong>Retry</strong> API will look like this :</p><pre>[HSRetryQueue addFailedRequest : failedRequest<br>            withSuccessHandler : dataModelSuccessHandler<br>                     onFailure : ^(void) {<br>                         NSLog(@&quot;Royal failure&quot;);<br>}];</pre><p>If you’re interested in working in a fast paced team, <a href="https://www.helpshift.com/about/careers/">we are hiring, join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5fa275e64b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/data-layer-architectures-for-mobile-applications-b5fa275e64b">Data layer Architectures for Mobile applications</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interact with us at Tech events]]></title>
            <link>https://medium.com/helpshift-engineering/interact-with-us-at-tech-events-fb2e075a5c22?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb2e075a5c22</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[tech-stack]]></category>
            <category><![CDATA[events]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Fri, 26 Sep 2014 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:41:29.936Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/vinayakh">Vinayak Hegde</a></h4><p>We have a busy next few weeks at <a href="http://www.helpshift.com/">Helpshift</a>. In the upcoming few weeks, a bunch of Helpshift team members are attending and speaking at various events in Bangalore. We are attending <a href="http://in.pycon.org/2014/">Pycon India 2014</a>, <a href="http://functionalconf.com/">Functional Conf</a>, <a href="http://www.meetup.com/ElasticSearch-Exploring-the-power-of-distribution/events/208390472/">Elasticsearch Bangalore Meetup</a> and <a href="http://aws.amazon.com/events/executive-summit-2014-india/">AWS Executive Summit</a>. Phew! More details below.</p><h4>Pycon 2014</h4><p>Personally, I have been attending Pycon India since the first edition so it is like an annual get-together with all my fellow Python geeks. We use <a href="http://www.python.org/">Python</a> at Helpshift for prototyping and validating ideas quickly. I have built quite a few apps on Django and I often use Python and R for some quick data analysis. Fellow team member <a href="http://www.swaroopch.com/">Swaroop CH</a> has also written one of the early and popular books on Python — <a href="http://www.swaroopch.com/notes/python/">“A Byte of Python”</a>. It’s available for <a href="http://www.swaroopch.com/notes/python/#_download">free download in several formats</a>. If you are getting started with Python, I highly recommend it!</p><p>Given our involvement with Python and Pycon for the last several editions, we are doing our bit by <a href="http://in.pycon.org/2014/sponsors.html">sponsoring Pycon India 2014</a>. It’s our way of giving back to the awesome Python community. Watch out for interesting talks by Kushal Das (Keynote), <a href="http://in.pycon.org/funnel/2014/255-auth-as-a-service-with-lastuser">Kiran Jonnalagadda</a>, <a href="http://in.pycon.org/funnel/2014/214-python-arduino-and-connected-objects">Ankit Daftery</a> and <a href="http://in.pycon.org/funnel/2014/165-faster-data-processing-in-python">Anand S</a>. Drop by the Helpshift sponsor booth and say hi. Who knows, you might win a goodie!</p><p><a href="http://in.pycon.org/2014/">Pycon India 2014</a> will be held at Nimhans Convention Center, Bangalore on 27–28 September 2014.</p><h4>Functional Conference 2014</h4><p>We use <a href="http://clojure.org/">Clojure</a> quite heavily in our tech stack and it is our primary language for writing code at Helpshift (<a href="https://engineering.helpshift.com/2014/Functional-Testing-Clojure/">See Previous coverage here</a>). We also use <a href="http://www.erlang.org/">Erlang</a> for processing and receving multiple billions of events. As you can see we are a bit biased towards functional programming languages due to expressiveness, succintness and scalability (due to non-mutable data structures). Since we have a built a large production system on Clojure and Erlang, we wanted to share our experiences and hear from others as well. Three members from the Helpshift team will be speaking at the Functional conference. Their talks are linked below:</p><ol><li><a href="http://booking.agilefaqs.com/functional-conf-2014#workshop-54-info">Deep Dive Clojure Workshop (Full day)</a> by <a href="https://twitter.com/ghoseb">Baishampayan Ghose</a></li><li><a href="http://confengine.com/functional-conf-2014/proposal/325/purely-functional-data-structures-demystified">Purely functional data structures demystified (Talk)</a> by <a href="https://twitter.com/mohitthatte">Mohit Thatte</a></li><li><a href="http://confengine.com/functional-conf-2014/proposal/322/writing-and-improving-tail-recursive-functions">Writing and improving tail recursive functions (Talk)</a> by <a href="https://twitter.com/bhaskerkode">Bhasker Kode</a></li></ol><p>We are sponsoring Functional Conference as well. Come talk to us at our booth and win some goodies!</p><p><a href="http://functionalconf.com/">Functional Conf</a> will be held at Hotel Chancery Pavilion, Bangalore on 9–11 October 2014</p><h4>Elasticsearch Meetup</h4><p>We use <a href="http://www.elasticsearch.org/">Elasticsearch</a> at Helpshift in our stack for search as well as percolation. It is a critical component of our production setup. Swaroop CH gave a <a href="https://funnel.hasgeek.com/fifthel2014/1181-lessons-from-elasticsearch-in-production">highly rated talk</a> on Elasticsearch at <a href="https://fifthelephant.in/2014/">Fifth Elephant</a>. <a href="https://twitter.com/swaroopch">Swaroop</a> and <a href="https://twitter.com/vedang">Vedang</a> have been working hard to whip Elasticsearch into shape to serve our needs. Vedang is one of the senior members of the platform team and has built the tech stack from scratch. Vedang will be sharing some hard-fought production lessons at the Elasticsearch Meetup on <a href="http://www.meetup.com/ElasticSearch-Exploring-the-power-of-distribution/events/208390472/">“Elasticsearch: Lessons learnt in Production”</a>. Do not miss this if you are using Elasticsearch in your tech stack. He will also provide future plans and experiments at Helpshift using Elasticsearch.</p><p><a href="http://www.meetup.com/ElasticSearch-Exploring-the-power-of-distribution/events/208390472/">More details</a> about the event.</p><h4>AWS Executive Summit</h4><p>Finally I will be speaking about our in-app mobile helpdesk product and our experiences in scaling it using Amazon Web Services at the <a href="http://aws.amazon.com/events/executive-summit-2014-india/">AWS Executive Summit</a> next week. Werner Vogels (CTO, Amazon) will also be speaking at the event. You can register for the event <a href="http://aws.amazon.com/events/executive-summit-2014-india/">here</a></p><p>If you’re interested in working in a fast paced team, <a href="https://www.helpshift.com/about/careers/">we are hiring, join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2e075a5c22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/interact-with-us-at-tech-events-fb2e075a5c22">Interact with us at Tech events</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional Testing of Mobile and Web Apps using Clojure]]></title>
            <link>https://medium.com/helpshift-engineering/functional-testing-of-mobile-and-web-apps-using-clojure-4bedb365c7ca?source=rss-1a0cf73de31c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bedb365c7ca</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Helpshift Engineering Team]]></dc:creator>
            <pubDate>Fri, 19 Sep 2014 07:00:00 GMT</pubDate>
            <atom:updated>2018-07-04T12:39:38.594Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://twitter.com/mayurJ13">Mayur Jadhav</a></h4><h4>Background</h4><p>We use Clojure extensively at Helpshift. It is our primary language (though we use Go, Python and Erlang as well). We also use Clojure extensively for testing our systems. We believe in automated testing as well as automated generation of test cases. Clojure is a dialect of Lisp created by Rich Hickey that runs on the JVM. Like other Lisps, Clojure treats code as data and has a macro system. This makes it easy to do code/data generation to test a lot of input/output combinations. Also since it runs on the JVM, we have access to all the Java libraries. In essence this is the best of both worlds, you have the expressiveness, succintness and power of Lisp, the stability/tooling of the JVM and access to huge number of java libraries (through interop). This makes it ideal for automated testing of mobile and web applications.</p><p>Recently, as part of <a href="http://seleniumconf.org/">Selenium Conf</a> we gave a talk on <a href="http://confengine.com/selenium-conf-2014/schedule#session-216-info">“Functional Testing of Mobile and Web Apps using Clojure”</a> in which we shared our experience of using Clojure for testing mobile and web applications. The talk video, a short demo and the slides are embedded below:</p><h4>Talk</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FG-fjpO6nYPQ%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DG-fjpO6nYPQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FG-fjpO6nYPQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3ea0145fee6dab2de670ec6c4104449/href">https://medium.com/media/a3ea0145fee6dab2de670ec6c4104449/href</a></iframe><h4>Demo</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmO-vAMy0Ack%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmO-vAMy0Ack&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmO-vAMy0Ack%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8609636d035a1f58b7ee1a84a9a31144/href">https://medium.com/media/8609636d035a1f58b7ee1a84a9a31144/href</a></iframe><h4>Slides</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F274777c021fc01324ec95a304d6991b5&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fhelpshift%2Fclojure-for-functional-testing&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F274777c021fc01324ec95a304d6991b5%2Fslide_0.jpg%3F119642&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="981" frameborder="0" scrolling="no"><a href="https://medium.com/media/830aedfc353b8e62792c1df87b144cef/href">https://medium.com/media/830aedfc353b8e62792c1df87b144cef/href</a></iframe><p>If you are interested in working in a fast paced team, <a href="https://www.helpshift.com/about/careers/">we are hiring, join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bedb365c7ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helpshift-engineering/functional-testing-of-mobile-and-web-apps-using-clojure-4bedb365c7ca">Functional Testing of Mobile and Web Apps using Clojure</a> was originally published in <a href="https://medium.com/helpshift-engineering">helpshift-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>