<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jordan Robinson</title>
    <description>A blog, largely about technical topics, written by Jordan Robinson, a developer.</description>
    <link>https://blog.jordanrobinson.co.uk/</link>
    <atom:link href="https://blog.jordanrobinson.co.uk/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 12 Jan 2025 16:51:31 +0000</pubDate>
    <lastBuildDate>Sun, 12 Jan 2025 16:51:31 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Shipping all the time</title>
        <description>&lt;p&gt;Something I’ve been thinking about a lot lately is shipping all the time and the realities of what that means as a developer.&lt;/p&gt;

&lt;p&gt;Very frequently, I see opinions that are polarised on the topic. From people claiming that you should completely avoid deploying on Fridays and there should be a manual review process for every release, versus deploying all the time no matter the risk.&lt;/p&gt;

&lt;p&gt;More recently, things like &lt;a href=&quot;https://itrevolution.com/product/accelerate/&quot;&gt;Accelerate&lt;/a&gt; (which is fantastic) and &lt;a href=&quot;https://dora.dev/&quot;&gt;DORA metrics&lt;/a&gt; have sought to statistically and scientifically prove that deploying more frequently is better. And I agree! The better systems I’ve worked on have been deployed multiple times a day, and the legacy, flaky or bad systems I’ve worked on often had long complicated release processes that had manual steps and schedules.&lt;/p&gt;

&lt;p&gt;On top of this, users of your product just want it to work. Consider the following scenario where a fix is found for a bug but the fix has to wait till after the weekend and needs to be signed off by another team.&lt;/p&gt;

&lt;p&gt;Users that only see your product sporadically, or for the first time, are going to see it as always being broken. The longer it’s broken, the more of a network effect this has.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/user-attachments/assets/8a88c0de-ff96-4ef1-8fa2-7fe8e3d03e0e&quot; alt=&quot;Diagram of users getting unhappy because you didn&apos;t deploy&quot; /&gt;&lt;/p&gt;

&lt;p&gt;While I’m very glad the discussion on this has shifted towards more frequently than less, there is a but. I don’t think deploying all the time is a silver bullet that fixes everything.&lt;/p&gt;

&lt;p&gt;The key consideration to have is that of Risk Bandwidth. This is illustrated particularly well in &lt;a href=&quot;https://sre.google/sre-book/embracing-risk/&quot;&gt;chapter 3 of the Google SRE book&lt;/a&gt;. The idea being that zero risk is unattainable and leads to the kind of systems that very rarely deploy.&lt;/p&gt;

&lt;p&gt;As such, as a developer you have to be mindful of the level of risk your deployment is going to cause, think about what can go wrong, who is going to get paged, and what would the impact be. This is going to be different in every situation based on what you’re working on, who your users are, and what your team is like.&lt;/p&gt;

&lt;p&gt;There’s no one size fits all solution here and understanding the amount of risk incurred by your deployment and whether that is acceptable or not is a great skill to learn and be comfortable with.&lt;/p&gt;
</description>
        <pubDate>Sat, 09 Nov 2024 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/shipping-all-the-time</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/shipping-all-the-time</guid>
        
        
      </item>
    
      <item>
        <title>On using Zenity and Cron to remind me to go for lunch</title>
        <description>&lt;p&gt;Sometimes, I’ll get really caught up in a problem or meeting and find that actually, I was meant to go for lunch a little while ago.&lt;/p&gt;

&lt;p&gt;Since lunchtime and a break from a problem is often the best debugger, I had a quick look into how to automate a reminder. While there are a million ways to remind yourself of upcoming meetings or tasks, I wanted something quite simple that I could dismiss easily and wasn’t tied to a work or personal calendar system.&lt;/p&gt;

&lt;p&gt;What I ended up going with and have been using for a few months now is a quick solution that uses Cron and Zenity.&lt;/p&gt;

&lt;p&gt;I simply&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;crontab -e&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To open up my crontab and edit it.&lt;/p&gt;

&lt;p&gt;Then put in the zenity command, which looks like this:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;30 12 * * * zenity --info --text &quot;&amp;lt;span foreground=\&quot;white\&quot; font=\&quot;64\&quot;&amp;gt;Go and grab some 🍜&amp;lt;/span&amp;gt;\n\n&quot; --no-wrap --display=:0.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And this pops up with a handy reminder each day.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/jordanrobinson/blog/assets/1202911/4f72aaf3-9e70-48ef-bdd8-9a5b0ad83669&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This might be a bit hard to parse on first glance so let me break it down:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;30 12 * * *&lt;/code&gt; is the cron task, saying, do this every day at 12:30.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zenity&lt;/code&gt; is the program that allows you to pop up a graphical window.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--info --text &quot;&amp;lt;span foreground=\&quot;white\&quot; font=\&quot;64\&quot;&amp;gt;Go and grab some 🍜&amp;lt;/span&amp;gt;\n\n&quot;&lt;/code&gt; is the contents of the message. Here we’re saying to use an info icon, as well as denoting the size and style of the text.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--no-wrap&lt;/code&gt; is just stylistic here, I found without it the alert was hard to read.&lt;/p&gt;

&lt;p&gt;and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--display=:0.0&lt;/code&gt; is specifying what monitor to show the alert on.&lt;/p&gt;

&lt;p&gt;And that’s it!&lt;/p&gt;
</description>
        <pubDate>Tue, 12 Dec 2023 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/zenity-and-cron-for-lunch</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/zenity-and-cron-for-lunch</guid>
        
        
      </item>
    
      <item>
        <title>Announcing awaitility-clj</title>
        <description>&lt;p&gt;As you may have guessed from my &lt;a href=&quot;/awaitility-clojure&quot;&gt;earlier post on Awaitility&lt;/a&gt;, currently at work I’m working with a lot of asynchronous systems. As a result, it made sense to make things a bit slicker in terms of testing them.&lt;/p&gt;

&lt;p&gt;So, to do this I’ve wrapped the code from the previous post into a clojure library called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awaitility-clj&lt;/code&gt; that can be found here:&lt;/p&gt;

&lt;p&gt;Github: &lt;a href=&quot;https://github.com/mypulse-uk/awaitility-clj&quot;&gt;https://github.com/mypulse-uk/awaitility-clj&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clojars: &lt;a href=&quot;https://clojars.org/ai.mypulse/awaitility-clj&quot;&gt;https://clojars.org/ai.mypulse/awaitility-clj&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And using it is as simple as&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/483283e8bca3aa04db90f36eb5bc5644.js?file=awaitility.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Hopefully people will find this as useful as I have been. At the minute it only supports a small amount of the arguments and config that the Java Awaitility does, but pull requests are encouraged and greatly appreciated.&lt;/p&gt;
</description>
        <pubDate>Fri, 01 Sep 2023 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/awaitility-clj-library</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/awaitility-clj-library</guid>
        
        
      </item>
    
      <item>
        <title>Using Awaitility in Clojure</title>
        <description>&lt;h2 id=&quot;awaitility&quot;&gt;Awaitility&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/awaitility/awaitility&quot;&gt;Awaitility&lt;/a&gt; is a pretty cool Java library that allows you to wait for asynchronous processes in tests. Lately we’ve been writing a lot of these kinds of tests where something will happen in an external component, such as Kafka, and we want our system to react to that and then assert on the state of our system. This is quite a tricky process as there’s actually more to think about than just a thread sleep call, so using something like Awaitility here is quite nice.&lt;/p&gt;

&lt;h2 id=&quot;a-nice-example-problem&quot;&gt;A Nice Example Problem&lt;/h2&gt;

&lt;p&gt;Instead of a large complicated problem involving Kafka and databases and various other problems, let’s have a small self-contained issue and see what the simplest case we can put together is first, and then from there build it up.&lt;/p&gt;

&lt;p&gt;Let’s say that we have the following function:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=example-code.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;This is pretty simple but it’ll basically randomly be above or below the number, so will be either true or false. Here this is basically just a proxy for an asynchronous process elsewhere.&lt;/p&gt;

&lt;p&gt;It will output something like&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Reading is... 0.38765405457829893
Reading is... 0.44857065444098454
Reading is... 0.14205946654844082
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;from the console when run.&lt;/p&gt;

&lt;p&gt;Then we want to add Awaitility to our project, so in Leiningen this looks like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=project.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;This will be slightly different if you are using Deps but you should be able to find a lot of resources for how this should look if so.&lt;/p&gt;

&lt;p&gt;Then, let’s put together our test. Here we assume that we want to wait until the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;check-reactor-is-ready&lt;/code&gt; function returns true, then we can assert on the various properties of that reactor.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=test.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;As tests go there’s not a lot of code or assertions here but it’s actually pretty good. Awaitility will throw if it takes longer than the default timeout of ten seconds, so if our function above doesn’t go over 0.5 in that time, our test will fail with an exception. If it doesn’t, the assumption is that we are ready to assert on the rest of the system.&lt;/p&gt;

&lt;p&gt;You can also compare this to what it would look like if we were using Awaitility in Java:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=javaExample.java&quot;&gt; &lt;/script&gt;

&lt;p&gt;We can go a bit further with this and do things like change the wait time, which will look like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=test-two.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;If we then also change the criteria to be a bit more stringent such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt; 0.95&lt;/code&gt;, we should be able to get a timeout if we run a few times.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=output.txt&quot;&gt; &lt;/script&gt;

&lt;p&gt;Finally let’s clean it up a little and put it into a threaded form so it’s a bit easier to read:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/32a2e5951997c1139a2ce68afb5e13bb.js?file=test-three.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;And that’s it for now, just a quick intro but you should be able to build on this quite a bit when testing asynchronous operations.&lt;/p&gt;
</description>
        <pubDate>Fri, 06 Jan 2023 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/awaitility-clojure</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/awaitility-clojure</guid>
        
        
      </item>
    
      <item>
        <title>Cursive - Fixing other issues when resolving symbols</title>
        <description>&lt;p&gt;It’s been a good while since my last post &lt;a href=&quot;https://blog.jordanrobinson.co.uk/clojure-cursive-httpkit-resolution&quot;&gt;on this&lt;/a&gt;, but I found something pretty relevant to it so thought a follow-up would make good sense.&lt;/p&gt;

&lt;p&gt;When you’re trying to resolve things in Cursive, this intention in IntelliJ sometimes won’t appear, the reasoning for this is actually due to a hidden-away setting in the editor intentions menu of IntelliJ.&lt;/p&gt;

&lt;p&gt;I’m not sure what causes this to be turned off, but I’ve seen it happen to other people a few times.&lt;/p&gt;

&lt;p&gt;The setting is located here in the settings menu:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/191520357-d636e132-1fbe-422c-824d-c5726551377a.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And once you’ve turned it on again then custom symbol resolution will work exactly as it did before.&lt;/p&gt;
</description>
        <pubDate>Wed, 21 Sep 2022 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/clojure-cursive-fixing-symbol-resolution</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/clojure-cursive-fixing-symbol-resolution</guid>
        
        
      </item>
    
      <item>
        <title>Clojure, Cursive - Resolving &quot;cannot be resolved&quot;</title>
        <description>&lt;p&gt;Recently I’ve been using &lt;a href=&quot;https://github.com/http-kit/http-kit&quot;&gt;http-kit&lt;/a&gt; quite a bit when working with Clojure. The main things I like about it are the sensible defaults, async by default, and being able to set a timeout.&lt;/p&gt;

&lt;p&gt;Aside from this I also use &lt;a href=&quot;https://cursive-ide.com/&quot;&gt;Cursive&lt;/a&gt;. As such I had a small issue where when using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;httpkit.client&lt;/code&gt; functions, cursive was unable to figure out what the functions under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client&lt;/code&gt; are. The reason for this looks to be because &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;httpkit.client&lt;/code&gt; &lt;a href=&quot;https://github.com/http-kit/http-kit/blob/56bf0bad71bf419819d0bd788b70f0ec5a36cea9/src/org/httpkit/client.clj#L297&quot;&gt;uses a macro to generate it’s functions&lt;/a&gt; relating to requests called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;defreq&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;defreq&lt;/code&gt; is something that Cursive doesn’t seem to recognise as generating a function, so as such you end up with this error: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;org.httpkit.client/get cannot be resolved&lt;/code&gt; although the function will work as expected.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/105392572-419eeb00-5c13-11eb-9115-df772d62242f.png&quot; alt=&quot;cursive cannot be resolved error&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This annoyed me for a little while so I looked into it a bit further and asked around on the lovely &lt;a href=&quot;https://slofile.com/slack/clojurians&quot;&gt;Clojurians slack&lt;/a&gt;, which is a great community.&lt;/p&gt;

&lt;p&gt;It wasn’t long before someone was able to give me an answer on how to resolve this.&lt;/p&gt;

&lt;p&gt;You can see the conversation &lt;a href=&quot;https://clojurians-log.clojureverse.org/cursive/2021-01-21&quot;&gt;here&lt;/a&gt; in the Clojurians slack archive, but I’ve also replicated the instructions below in case that gets lost for whatever reason.&lt;/p&gt;

&lt;p&gt;To fix it:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Go to the defreq macro definition in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;httpkit.client&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Put the cursor on the defreq and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alt-enter&lt;/code&gt; to bring up the suggestions&lt;/li&gt;
  &lt;li&gt;Choose “Resolve defreq as…”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/105392618-4cf21680-5c13-11eb-8c16-f2eb527dc91a.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Select “Specify” and then type in “Declare” in the var name, picking the one from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clojure.core&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/105392671-5a0f0580-5c13-11eb-8f56-5de655248076.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This should then resolve it. You can see a list of your definitions in the settings, too, under Settings → Languages &amp;amp; Frameworks → Clojure → Symbol Resolution&lt;/p&gt;

&lt;p&gt;All in all this was another nice interaction with the Clojure community.&lt;/p&gt;

</description>
        <pubDate>Thu, 21 Jan 2021 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/clojure-cursive-httpkit-resolution</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/clojure-cursive-httpkit-resolution</guid>
        
        
      </item>
    
      <item>
        <title>Chaining Requests and Using Variables in Insomnia</title>
        <description>&lt;h2 id=&quot;insomnia&quot;&gt;Insomnia&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://insomnia.rest&quot;&gt;Insomnia&lt;/a&gt; is an open source rest client often thought of as a lightweight modern alternative to &lt;a href=&quot;https://www.postman.com/&quot;&gt;Postman&lt;/a&gt;. In the past year or so I’ve used it a lot more than I have Postman, if only due to the quicker startup times, less bloat, and much easier to use UX.&lt;/p&gt;

&lt;p&gt;I’d really recommend it, switching is easy too, as it supports importing a lot of things, such as collections, from Postman. While there isn’t support for some of the more esoteric features in Postman, Insomnia makes up for it by being immensely more usable.&lt;/p&gt;

&lt;h2 id=&quot;chained-requests&quot;&gt;Chained Requests&lt;/h2&gt;

&lt;p&gt;Chaining requests is a practice that allows you to take the token or information from one request, store it in a variable temporarily, and then use that as authentication or input for another request.&lt;/p&gt;

&lt;p&gt;Insomnia has support for this out of the box, and while there are a few bits of information in their &lt;a href=&quot;https://support.insomnia.rest/article/43-chaining-requests&quot;&gt;docs&lt;/a&gt;, (as well as a gif that moves way too fast) they assume that you are quite familiar with Insomnia. As such I ended up documenting how to do this for myself and thought it would also make a good blog post.&lt;/p&gt;

&lt;p&gt;Firstly, you will need to have an environment to store your variable in, this is as simple as clicking the manage environments button (or using the shortcut, ctrl+e) just below the Insomnia header, shown here:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/103244551-47c3e380-4955-11eb-8d7d-51724ee18c11.png&quot; alt=&quot;insomnia environments&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then, you’ll need to add a variable for the variable you want to pass along between requests. The syntax of these environments is JSON, so you can just quite happily call your variable whatever you want. Once you have it you’ll want to triger the autocomplete for the value (ctrl + space) and select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Response -&amp;gt; Body Attribute&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note you can also have headers and urls here, but for the example we have let’s just use an attribute from the response body.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/103244555-48f51080-4955-11eb-9931-85490aaa6753.png&quot; alt=&quot;variable setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will then give you a clickable item, which when clicked opens a means to edit the variable, which in this menu is described as a tag.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/103244554-485c7a00-4955-11eb-97c0-9ce6dc03f2ac.png&quot; alt=&quot;variable modal&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Of note here is that we’ve selected a request to bring our variable from (the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Request&lt;/code&gt; section of the modal) and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Filter&lt;/code&gt; section. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Filter&lt;/code&gt; allows us to filter down the json of the response to use a variable, for example a token from a response. We can also set when this is resent, e.g 86400 seconds, which would be once per day.&lt;/p&gt;

&lt;p&gt;For this example in the image I’ve set it to filter on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$.species&lt;/code&gt;, to give you an idea of how to filter, but for the rest of this, let’s assume that we then use the filter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$.species.name&lt;/code&gt;, which will give us &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ditto&lt;/code&gt; in the live preview window.&lt;/p&gt;

&lt;p&gt;Now that we’ve defined our variable, to use it in another request, we simply need to open the autocomplete where we need it, whether that’s in the url or the headers, query string etc.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/103244556-48f51080-4955-11eb-80f9-80d1db23492a.png&quot; alt=&quot;second request setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And that’s it! You can also reuse this variable in multiple requests. The most useful thing I’ve found to do with variables in this way is to create a request that gets a token, then use that same bearer token as authorisation for all the api requests stored in insomnia. You do have to add the variable manually as a header/auth method, however once done this never needs to be touched agan.&lt;/p&gt;
</description>
        <pubDate>Sun, 27 Dec 2020 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/insomnia-chained-requests</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/insomnia-chained-requests</guid>
        
        
      </item>
    
      <item>
        <title>Clojure - Getting started with Liberator and TDD</title>
        <description>&lt;h2 id=&quot;liberator&quot;&gt;Liberator&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://clojure-liberator.github.io/liberator/&quot;&gt;Liberator&lt;/a&gt; is a library that allows for creation of REST-based endpoints for construction of an API in Clojure. It has a simple set of functions that are quite powerful and allow for a great deal of customisation. It also has a slightly less simple &lt;a href=&quot;https://clojure-liberator.github.io/liberator/tutorial/decision-graph.html&quot;&gt;decision graph&lt;/a&gt; that makes more sense with experience.&lt;/p&gt;

&lt;p&gt;In this post we’ll put together a very simple endpoint, by starting first with a test and then progressing from there.&lt;/p&gt;

&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;First off we’ll need to run:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=new-app.sh&quot;&gt; &lt;/script&gt;

&lt;p&gt;Which will set up our project and give us the basics for running our code.&lt;/p&gt;

&lt;p&gt;This gives us a failing test and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-main&lt;/code&gt; function that we can run.&lt;/p&gt;

&lt;p&gt;Then, let’s add the dependencies to our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;project.clj&lt;/code&gt; so that they look like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=project.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;This will give us the bare minimum libraries that we need to run a server that can accept and respond to requests.&lt;/p&gt;

&lt;p&gt;Once we have our libraries we have somewhat of a chicken and egg problem, in that we need to do some basic setup before we can get testing working. First off we want to add a place for our resource that will be using liberator, that should look a bit like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=resource-start.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;And we’ll need to modify our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.clj&lt;/code&gt; to be able to start something that can respond to web requests. That should look something like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=core.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Since this is a more basic tutorial, while we’re here let’s talk about this in a little bit more detail, there’s essentially three parts to this file.&lt;/p&gt;

&lt;h3 id=&quot;the-core-file&quot;&gt;The core file&lt;/h3&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=core-1.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;First off there are the imports, which are pretty standard. Because this is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.clj&lt;/code&gt; generated for us by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lein&lt;/code&gt; command, we also have a &lt;a href=&quot;https://clojuredocs.org/clojure.core/gen-class&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:gen-class&lt;/code&gt;&lt;/a&gt;. We’re also using &lt;a href=&quot;https://clojuredocs.org/clojure.core/require&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:require&lt;/code&gt;&lt;/a&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:as&lt;/code&gt; to be able to alias the libraries, so we can be more specific in the body of the code, as well as giving meaningful names to things instead of long namespaces.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=core-2.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Then we have the main part of the file, where we define how to start a server. This uses Jetty as well as some ring middleware to be able to start up a server on port 3000 on localhost. There are a few parts to this that may not seem immediately obvious, but the key things to note are that we’re using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;defroutes&lt;/code&gt; from our other file here, as well as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:join? false&lt;/code&gt; which will help us out when we go to test our server.&lt;/p&gt;

&lt;p&gt;The reason we have this as a separate function is so that we can call it from both this file, as well as from tests.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=core-3.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Finally we have the main function, which is our entrypoint for if we call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lein run&lt;/code&gt;. For now for us, this just starts the server, but you could happily make this start a database or use something like &lt;a href=&quot;https://github.com/stuartsierra/component&quot;&gt;components&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;putting-the-test-in-place&quot;&gt;Putting the test in place&lt;/h2&gt;

&lt;p&gt;Now that we have all the scaffolding for the project, we can put a test in. Thankfully, Leiningen sets most of this up for you. You should currently be able to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lein test&lt;/code&gt; and see that the example test given fails. Hooray!&lt;/p&gt;

&lt;p&gt;For this example, let’s assume that the data we want our endpoint to return is.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=data.json&quot;&gt; &lt;/script&gt;

&lt;p&gt;And as such let’s set up a test that looks for this. The first step is to allow us to call our webserver from a test. To do this we’ll use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;use-fixtures&lt;/code&gt; like so:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=test-1.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;This lets us start up the server at the start of the test suite, runs the tests, and stops the server once our tests are done. This is a pretty common pattern in component and integration tests and because we’ve modularised the starting of our server, we can simply call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start-server&lt;/code&gt; here from our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.clj&lt;/code&gt; and it will spin up a fresh server for us. In a more complicated setup you would likely want to have this on a random free port instead of using the port hardcoded in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.clj&lt;/code&gt; but, like most of this example, a lot of it can be swapped out later.&lt;/p&gt;

&lt;p&gt;Once we have that, we can add our test, which as a whole file, should look like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=test.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Here we’re using &lt;a href=&quot;https://github.com/http-kit/http-kit&quot;&gt;http-kit&lt;/a&gt; to make a simple request to our endpoint, then we’re decoding the body with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;json/read-str&lt;/code&gt; and comparing it to our expected data.&lt;/p&gt;

&lt;h2 id=&quot;getting-to-green&quot;&gt;Getting to green&lt;/h2&gt;

&lt;p&gt;Now that we have a red test, we’re going to want to turn it green, which in this case is actually a little simpler than the rest of the setup so far. We can make our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource.clj&lt;/code&gt; look like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/facfae126370a6c26ced361fa8979ce8.js?file=resource.clj&quot;&gt; &lt;/script&gt;

&lt;p&gt;Which adds our route to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;make-routes&lt;/code&gt; function, and uses liberator to define the resource. Of particular note here is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:handle-ok&lt;/code&gt; which is how Liberator defines what will be returned for the OK status code. This can be a function, so you can have much more complicated implementations than this, but this makes a good start.&lt;/p&gt;

&lt;p&gt;With this, we just need to run a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lein test&lt;/code&gt; and our test &lt;em&gt;should&lt;/em&gt; be green!&lt;/p&gt;

&lt;p&gt;With such a simple example there’s not too much refactoring for us to do now, but we can definitely add more tests, like checking the status code of the response, or what happens if we hit an endpoint that isn’t yet set up.&lt;/p&gt;
</description>
        <pubDate>Sat, 23 May 2020 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/liberator-tdd</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/liberator-tdd</guid>
        
        
      </item>
    
      <item>
        <title>Book Report - Understanding the Four Rules of Simple Design</title>
        <description>&lt;p&gt;Understanding the Four Rules of Simple Design is a relatively short book with a big focus on TDD and the way that it affects how we approach design. While the book is pretty concise, the contents is detailed and at times insightful.&lt;/p&gt;

&lt;p&gt;It has a website here: &lt;a href=&quot;https://leanpub.com/4rulesofsimpledesign&quot;&gt;https://leanpub.com/4rulesofsimpledesign&lt;/a&gt; where you can buy it, too.&lt;/p&gt;

&lt;p&gt;If you’re looking out for it in a bookstore, it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/91866582-96dd5e80-ec6a-11ea-880e-b1d36559948e.png&quot; alt=&quot;four-rules-cover&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It’s by Corey Haines, who has a blog here: &lt;a href=&quot;https://articles.coreyhaines.com/&quot;&gt;https://articles.coreyhaines.com/&lt;/a&gt; that has some interesting posts and also some additional information around the book itself.&lt;/p&gt;

&lt;p&gt;This blog post is part of my “Book Report” series, where while reading a book I’ve been recommended I’ll take informal notes on each chapter and then type them up at the end as a blog post I can reread later as both a refresher and a place to note down my thoughts on the book in general.&lt;/p&gt;

&lt;h2 id=&quot;section-breakdown&quot;&gt;Section Breakdown&lt;/h2&gt;

&lt;h3 id=&quot;part-1---this-book&quot;&gt;Part 1 - This Book&lt;/h3&gt;

&lt;p&gt;This section is much more of an introduction to the book itself than anything else, but I did like how it outlined that the examples are in Ruby, who it’s for, and the overall structure of the book itself.&lt;/p&gt;

&lt;p&gt;I did find it a bit odd that it didn’t go into the &lt;a href=&quot;https://martinfowler.com/bliki/BeckDesignRules.html&quot;&gt;four simple rules themselves&lt;/a&gt; at this point when talking about what the book will be about. There’s a foreword from Kent Beck himself talking a bit about them, but the assumption here is that you know what they are and have done a bit of background reading previously.&lt;/p&gt;

&lt;h3 id=&quot;part-2---where-do-these-thoughts-come-from&quot;&gt;Part 2 - Where do these thoughts come from?&lt;/h3&gt;

&lt;p&gt;Like the book itself, this section is pretty small but has a lot of parts to unpack and think about. In particular there are a lot of nice quotes in here that are good talking points, e.g.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;“We’ll never be more ignorant than we are at this moment”&lt;/li&gt;
  &lt;li&gt;“If you have to ask how fast your test suite should be, it should be faster”&lt;/li&gt;
  &lt;li&gt;“This is going to change in the future, so it is worth my investment right now.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This section is littered with nice little quotes like this that make you think and are easy to agree with.&lt;/p&gt;

&lt;p&gt;As well as this it also touches briefly on code ownership, which I’ve thought and read about a lot before. The key post that cemented this for me is &lt;a href=&quot;https://www.hanselman.com/blog/YouAreNotYourCode.aspx&quot;&gt;“You are not your code.”&lt;/a&gt; by Scott Hanselman. The book posits that you can get past this through practice, and while I agree in part, I do think that this is mainly a psychological barrier that can be easy to put up; since fundamentally it’s nice to take pride in your work.&lt;/p&gt;

&lt;p&gt;This section also outlines Conway’s game of life as well, which was the main problem tackled at code retreat, and then details the four rules themselves. In the book they’re described as:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Tests Pass&lt;/li&gt;
  &lt;li&gt;Expresses Intent&lt;/li&gt;
  &lt;li&gt;No Duplication (DRY)&lt;/li&gt;
  &lt;li&gt;Small&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Which is a little simplified from the original rules but convey the same intent.&lt;/p&gt;

&lt;h3 id=&quot;part-3---examples&quot;&gt;Part 3 - Examples&lt;/h3&gt;

&lt;p&gt;This section starts the main thrust of the book, and has a lot of really interesting insights and talking points. The examples are easy to follow and really very illustrative of the concepts the author is trying to convey.&lt;/p&gt;

&lt;p&gt;One of the key themes of this section (and indeed book) is about asking questions around the design - with a lot of the design being iteratively answered through questions, in the same way that when driving your design through tests that your design iteratively takes shape.&lt;/p&gt;

&lt;p&gt;There’s really a lot to cover in this section (and a lot of it really interesting) so to pick out just one part, in particular I liked the part “Don’t have tests depend on previous tests”. This is something I’ve had come up quite a bit when reviewing other code and had to force myself not to do previously, so to see it here articulated a lot better than I have in the past was really nice. The crux of the section is that by having your tests rely on each other, you end up with a fragile test system. Your tests should be explicit when they fail as opposed to having one failure break many tests; causing you to spend a lot of time investigating.&lt;/p&gt;

&lt;p&gt;While this section is pretty dense and the examples are only loosely connected in places, it does a very good job of the overall aim of the book, which is to help you understand the four simple rules of design. The examples are good at showing the fallacies that can sometimes occur and overall does a really good job of explaining why the rules are what they are in a clear and concise manner; something I find a lot of books on software design and TDD struggle with.&lt;/p&gt;

&lt;h3 id=&quot;part-4---other-good-stuff&quot;&gt;Part 4 - Other Good Stuff&lt;/h3&gt;

&lt;p&gt;This section has some addendum that didn’t really fit in the main section of the book, including things such as pair programming thoughts, example constraints for running through the game of life problem in a pair, and further reading. That’s not to say that there isn’t a lot of wisdom here however, since there most certainly is.&lt;/p&gt;

&lt;p&gt;In particular one point that I really liked and that I’ve definitely taken with me after reading this book is the thought that the 4 rules are simple enough to apply consciously, whereas things like SOLID are best internalized and applied subconsciously.&lt;/p&gt;

&lt;h3 id=&quot;overall-thoughts&quot;&gt;Overall Thoughts&lt;/h3&gt;

&lt;p&gt;This is probably one of my favourite technical books and really has stuck with me in a lot of my day-to-day working and thoughts on development and design. It’s short but it has a lot to say and the things it does have to say are very thought-provoking.&lt;/p&gt;

&lt;p&gt;I’d really recommend picking it up if you haven’t already, and when possible, practicing pairing and tdd through some of the constraints and examples in the book. Some of them can be a bit labourious (“No return values” in particular really makes the functional programming part of my brain scream a bit) and some of them are definitely more fun than others, but overall pairing through a kata this way is a really nice way to hone your craft and learn from others.&lt;/p&gt;
</description>
        <pubDate>Wed, 11 Dec 2019 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/four-rules</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/four-rules</guid>
        
        
      </item>
    
      <item>
        <title>Scaling Sitecore for high traffic sites</title>
        <description>&lt;h3 id=&quot;scaling-sitecore-for-high-traffic-sites&quot;&gt;Scaling Sitecore for high traffic sites&lt;/h3&gt;

&lt;p&gt;Scaling Sitecore up is one of those things that, while very necessary, there aren’t as many resources on the internet regarding the subject as I’d like. As such, I’ve decided to put together this post with a few tips and gotchas around scaling out to handle lots of traffic to your Sitecore site.&lt;/p&gt;

&lt;p&gt;While there is the &lt;a href=&quot;https://doc.sitecore.com/developers/90/platform-administration-and-architecture/en/sitecore-scaling-scenarios.html&quot;&gt;Sitecore scaling scenarios&lt;/a&gt; document put out by Sitecore (though not yet available for 9.1) this does focus more on the infrastructure required and other concerns. While this is all very important, it forms a baseline that you can then build on; there are a lot of other factors in play that no matter the number of servers you scale up to, could still cause issues.&lt;/p&gt;

&lt;h3 id=&quot;the-html-cache&quot;&gt;The HTML Cache&lt;/h3&gt;

&lt;p&gt;In referring to this I’m talking about the rendering based caching, where you can set the settings of specific renderings to cache, and the ways of varying that cache to make sure that your site functions correctly. Sitecore’s HTML cache is actually very good; being based on the standard .Net memory cache. You can even interrogate it through code and clear things yourself, as outlined in a really useful blog post &lt;a href=&quot;https://briancaos.wordpress.com/2018/10/31/sitecore-9-caching-sitecore-caching-cachemanager-getallcaches-changed-from-sitecore-8/&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Best practice is of course to cache as much as possible. In particular I’d recommend anything with ajax or dynamic components using query strings to cache based on query string, and have the api endpoints or search pages idempotent. If you’re unfamiliar with the concept there’s a &lt;a href=&quot;http://cloudingmine.com/idempotence-what-is-it-and-why-should-i-care/&quot;&gt;nice blog post here explaining it.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/56134765-25bedd80-5f87-11e9-8492-846f7b167696.jpg&quot; alt=&quot;Sitecore content editor caching settings&quot; /&gt;&lt;/p&gt;

&lt;p&gt;However, the cache clearing strategy for this cache could be described as a little extreme; on any publish, the entire cache is evacuated. This means that while you could just be publishing, say, a single piece of content or dictionary entry, the entire site’s HTML cache will be cleared and need to be re-cached. As such you have to be quite careful with what your renderings are doing, since if your content editors are likely to publish frequently, or during traffic spikes.&lt;/p&gt;

&lt;h3 id=&quot;caching-across-multiple-servers&quot;&gt;Caching Across Multiple Servers&lt;/h3&gt;

&lt;p&gt;Also worth mentioning is that the HTML cache is that it is of course located on each machine. In any large website for Sitecore you’re going to want multiple content delivery servers, but this means that the work to fill those caches is multiplied by the number of content delivery servers you have. Why is this a big deal? Well, if we look at this diagram we can see that this can have a cascading effect to other parts of the infrastructure, since if we double the amount of CD servers, everything else has to accommodate that.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/1202911/56134777-2c4d5500-5f87-11e9-9f12-99a1c1245ca6.jpg&quot; alt=&quot;Scaling horizontally diagram&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Another problem with this is that things that are time-sensitive can vary between CD servers, since one server could be hit, for example, a minute after the other one. While they might both be valid, if a user refreshes and gets totally different data, this could cause all kinds of problems.&lt;/p&gt;

&lt;p&gt;Ideally, the way to mitigate this would be to have one single cache that all the CD servers interact with, and use as a central store; however this is not supported, even though there have been quite a few questions about it in the Sitecore community, &lt;a href=&quot;https://community.sitecore.net/developers/f/8/t/8512#pi214filter=all&amp;amp;pi214scroll=false&quot;&gt;such as this one.&lt;/a&gt; This is something that I really hope is available in forthcoming versions of Sitecore.&lt;/p&gt;

&lt;h3 id=&quot;apis-and-assets&quot;&gt;APIs and Assets&lt;/h3&gt;

&lt;p&gt;Scaling out APIs based on Sitecore is no trivial task, but there are a few points to be aware of. First off, you’re going to want to offload as much of the requests that your API is using to your search service, whether this is Azure Search or Solr. Architecting it in this way greatly reduces the load on your content delivery servers and on your database, using the search servers for what they’re intended for.&lt;/p&gt;

&lt;p&gt;For your more frequently hit APIs, I would also recommend putting &lt;a href=&quot;https://varnish-cache.org/intro/index.html&quot;&gt;Varnish&lt;/a&gt; in front of the API, Varnish is a static caching layer. I’ve seen it handle truly staggering amounts of traffic, I really can’t recommend it enough.&lt;/p&gt;

&lt;p&gt;Finally, for assets, using a CDN is best practice, and &lt;a href=&quot;https://blog.jordanrobinson.co.uk/sitecore-and-cloudfront&quot;&gt;I’ve wrote a few bits and pieces on that before that you might want to check out.&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 12 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://blog.jordanrobinson.co.uk/scaling-sitecore</link>
        <guid isPermaLink="true">https://blog.jordanrobinson.co.uk/scaling-sitecore</guid>
        
        
      </item>
    
  </channel>
</rss>
