-
Multiple instances in Terraform: count versus foreach
A typical use case when ops-ing servers is to rotate servers: Create a new server and remove the old server. Since our servers are managed by Terraform and Ansible this should be an easy exercise. If you know what you are doing…
read more
-
Terraform 0.12, Ansible and AWS setup
Our AWS setup is automated using Terraform and Ansible. We recently upgraded to the next major release Terraform 0.12 and needed to refactor our setup in order to support this new major version. This post is a write up of how to setup Terraform 0.12, AWS and Ansible using dynamic inventory.
read more
-
Event Sourcing: Invariants spanning multiple aggregates
When you are designing your aggregate boundaries in an event sourced system, you are usually thinking about how large or small you want to make your aggregates.
This begs the question, however, what if you want to have smaller aggregates, but that results in an invariant that will be split across two aggregates?
read more
-
React + Redux: our pursuit of performance (part 1)
While having dabbled with the critically acclaimed React + Redux combo for the past year, we’ve had our fair share of performance challenges. While React is pretty darn fast out of the box, there comes a time that you’ll run into a brick wall, performance wise. This is a series of posts for those who are in the same boat as we were and will serve as a guide to row this boat safely to shore. We will be sharing our experiences and providing solutions.
read more
-
Event Sourcing in Elixir
In this post we will explore how we can use some of Elixir’s more interesting features to implement event sourcing. OTP is the star of this show, enabling us to do some very nice tricks that would be practically impossible with Ruby. OTP stands for Open Telecom Platform, and is Erlang’s answer to the problem of concurrency. OTP relies on immutability of data to provide some very nice abstractions that make working with it very easy.
read more
-
Share code between mobile and web with react-native-web
Nowadays applications often have to support multiple platforms. Besides a web-application, there is also a need for mobile applications on multiple platforms. Therefore a developer requires knowledge of webdevelopment, iOS development, Android development and probably a lot of time. This means projects often require multiple teams of developers, working on the same application for different platforms with multiple codebases. Wouldn’t it be great to have a single shared codebase that would work on both mobile and web?
read more
-
Building an OAuth2 provider in Node.js
Last week I needed a Node.js web application to provide OAuth 2 access tokens under the
read moreauthorization_code
grant. I choose to use thenode-oauth2-server
, mainly because it is reasonably popular, does not requirepassport
and it looks well-written.
-
Elixir-y goodness from front to back with Elixirscript
Elixir is an amazing language for the backend. Erlangs BEAM VM gives it a battle tested, highly reliable, functional base. Pattern matching is a joy and OTP offers tried and true answers to concurrency, scalability and uptime challenges. Mix in Elixirs pleasant ruby-like syntax, the lovely
read more|>
pipeline operator and zero-cost abstractions with hygienic macros and the result is a cocktail I could drink all day, every day.
-
Rearranging and hiding items in a UITableView
Creating a TableView just like Apple’s own Mail App where you rearrange and hide Mail Folders is pretty straigthforward, once you know how to do it.
read more
-
Handling large result sets from postgresql in active-record
There are several ways for handling large result sets from the database in your application. Each way has its own limitations and pros and cons. All of them have the advantage of reducing memory footprint. In this blogpost we will discuss three ways and see how they compare.
read more
-
Unraveling npm: Deterministic dependencies with Yarn
Npm is known to be non-deterministic. This means that depending on the order you install dependencies in, your
read morenode_modules
folder can look very different. Debugging a dependency issue often consists of throwing away yournode_modules
and runningnpm install
again. With the average JS project nowadays having hundreds of dependencies this can be pretty scary.
-
active-record hash versus array syntax
While migrating a ruby app using active-record from using
read morecharacter
columns in our postgres database touuid
s I learned about a difference in using the hash syntax versus the array syntax in where clauses.
-
Simple event sourcing - users, authentication, authorization (part 6)
Previously we spend some time preparing the code to support multiple kinds of events and data, rather than just supporting blog posts. In this part we’ll add user accounts, together with the required authentication and authorization code. We’ll again use event sourcing and the memory image to keep track of all users and currently active sessions. But the biggest changes to the application are related to security, and authorization in particular. It turns out event sourcing allows for an additional layer of authorization which allows us to whitelist any change a particular user is allowed to make.
read more
-
Simple event sourcing - refactoring and transactions (part 5)
In the previous part we added blog post comment functionality. In this part we’ll do some refactoring and change the memory image implementation to automatically retry domain logic on optimistic locking conflicts, giving us a simplified form of transactions. We’ll also change the event store to support multiple types of event streams in a single event store.
read more
-
Simple event sourcing - conflict resolution (part 4)
After our deep dive into a Redis event store implementation we’re now getting back to actually adding functionality to the blogging application. Like the Getting started with Rails guide we’ll add the capability to add comments to blog posts. Adding this functionality is straightforward, but it will require us to look into resolving conflicts when multiple people make modifications to the same blog post or comment concurrently.
read more
-
Simple event sourcing - Redis event store (part 3)
In the previous part we developed a fake event store for our blogging application. This event store just kept all events in-memory, making it unsuitable for production use. But it did allow us to adapt our application to using an event store, and let us work out the details of the event store interface without having to worry about an actual persistence mechanism.
read more
-
Simple event sourcing - consistency (part 2)
In the first part of this series we developed a simple blogging application that uses event sourcing to keep track of all changes made by the users. However, we did not yet write these events to durable storage. This means all data is lost when the application is restarted, which is clearly not acceptable. Saving and restoring events will be the responsibility of the event store, which we’ll start implementing in this part. But before we get to actually writing events to disk, we must first tackle the problem of maintaining data consistency when using event sourcing.
read more
-
Simple event sourcing - introduction (part 1)
This is the first part of a series on building an event sourced application. We’ll build a simple blogging application (inspired by the Ruby on Rails “Getting Started” tutorial), so the domain should be familiar. This allows us to focus on implementing a memory image based architecture using event sourcing. Another goal is to show that this kind of architecture is not more complex (and arguably, simpler) than those implemented by traditional database centered applications. The example code is in Scala using the Play! web framework, but should be understandable enough if you come from a Java (or similar) background.
read more
-
Picking the right abstraction
Recently I had to adapt some older Java code to support a new requirement: an existing CSV report needed to include a user’s email address, translated from the user id. Pretty simple, but how does the CSV report generator translate the user id to an email address?
read more
-
Play! 2.0: A First Impression
Play! is a web framework for Java and Scala. Play promises to bring the developer productivity of web frameworks like Ruby on Rails to the Java and Scala languages. Of course, it wouldn’t make much sense just to copy Rails. So Play adds its own spin: Play 2.0 is fully statically type checked, giving the developer quick feedback when something doesn’t make any sense.
read more
-
Serializing strings, Unicode, and randomized testing using ScalaCheck
While implementing a simple event store for an example application I needed to serialize JSON data to binary arrays and turn those bytes back into the original JSON. Obviously, that’s a piece of cake!
read more
-
Towards an immutable domain model – monads (part 5)
This is the fifth and final part of this series. In this last part we’ll reduce the boilerplate code related to handling events and as a bonus we’ll also make handling validation a bit nicer. But before we take a deep dive into the code, let’s consider the design of the last three Invoice implementations.
read more
-
Towards an immutable domain model – believe the type (part 4)
We’re already on the fourth part of this series. In this part we’ll explore how we can improve on the original design now that the invoice is immutable.
read more
-
Towards an immutable domain model – immutability achieved (part 3)
In part 1 we looked at a stereotypical implementation of an
read moreInvoice
domain class. In part 2 we introduced event sourcing to extract the durability and reporting concerns from the behavioral requirements and to move closer to making theInvoice
immutable. In this part we’ll explore the first implementation of an immutableInvoice
.
-
Towards an immutable domain model – immutable change (part 2)
In the first part of this series an
read moreInvoice
domain object was defined as a starting point for discussing immutable domain objects. JPA and Scala were used for the example implementation. In this part we’ll look at this example from a different perspective to move closer to an immutable domain model.
-
Towards an immutable domain model – introduction (part 1)
This is the first part of a (short) series of blogs on implementing a rich domain model using only immutable domain objects. This first part introduces a (simple) example domain model and provides a JPA implementation using Scala. This exampe will serve as a baseline that should be familiar to most developers who have experience with an ORM. The other parts of this series will redesign the example to use only immutable objects and will explore some of the benefits and drawbacks of doing so.
read more
-
Option[Scala] - a better null?
Yesterday I watched Graham Tackley’s talk (slides) on moving from Java to Scala at theguardian. The presentation is well worth watching if you’re considering adding Scala to your project.
read more
-
Fixing date in test using JUnit MethodRule
One of the principles of a good unit test is that they are repeatable. This is especially important if the tests involve dates. Typically this is programmed in the setUp and tearDown of the unit tests. This might lead to duplication if multiple tests depend on such a fixed date. Of course we can abstract this to an Abstract base class, but in the end we all know that reuse via inheritance is a bad idea. JUnit @Rule can be a solution for this.
read more
subscribe via RSS