Repost home page

Publish/Subscribe is a common mechanism used for services (or microservices) to communicate with one another. It does not, however, pair well with serverless functions such as Amazon’s Lambda, or Google’s Cloud Functions. A relatively new service — Repost — provides a PubSub system designed to be used with serverless functions. We’re going to have a look at using it.

Many systems, especially microservice based applications, require services to talk to one another. While your system is small, you might just send http requests directly from one service to another. This very quickly runs into a problem though. …


Kotlin’s type system gives plenty of advantages over Java. The default to have types non-nullable, and adding nullability deliberately and optionally is a huge boon, made even better by the compilers ability to predict potential null reference errors. Something neither language does well (in my opinion), however, is handle error conditions.

Java’s checked exceptions are one of the most complained about features I’ve ever encountered, and with good reason. Having each method list every possible way in which it can go wrong, and having the caller have to directly deal with that is an exercise in boredom. …


The Kotlin language has a large number of features that can be classed as syntactic sugar — they make the language just a bit nicer to use and read, mostly by eliminating repetitive code.

A common form of repetitive code comes when you want to work with Maps. Maps will almost always come up in some form or another, often when communicating with external systems (e.g. JSON data coming in). They’re popular for their flexibility and use in inter-language operations— keys can be strings and data can be any value. …


Even for a small application, it will often become desirable to change settings when the app runs rather than when it is compiled. A configuration file full of the various settings for the application is not uncommon in this scenario, where changes to the settings can be made and the app restarted with the new settings — the only question is what format should this settings file be?

JSON and YAML are both popular choices, as are Java Properties Files and sometimes INI files and other application-specific text formats. They all have their pros and cons, but all fall in…


For a few years now, Kubernetes (pronounced coo-burr-net-eez, abbreviated to k8s) has been getting a lot of attention and hype in the DevOps world. However, it’s very hard to see what it does without having used it in a real world scenario.

From the kubernetes page

Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications.

It groups containers that make up an application into logical units for easy management and discovery. …


There are plenty of stories out there telling us of the advantages of CQRS — The Command and Query Responsibility Segregation pattern. The simple version is that we should separate Commands (user requests that change the data) from Queries (user requests that request data or some calculation on it), and that the data model we use often shouldn’t be the same for the two cases. Queries should never cause a change in the state of the system — no database writes, no file access — while Commands should only do these things and should not return data.

For example, in…


This is part of a series about building a User Defined Type system using Kotlin. If you haven’t read the previous parts (Part 1 and Part 2), I recommend catching up before you do.

In part 1 and 2, we implemented a simple but powerful User Defined Type system. We can describe a type and create instances of that type, and the code to do so is fairly easy to use from Kotlin. Our example usage looks like this:

While we can create a type and instance, this is a User type system, we need to be able to…


This is part of a series about building a User Defined Type system using Kotlin. If you haven’t read the previous parts (Part 1 and Part 2), I recommend catching up before you do.

The Type system we defined is powerful and flexible. Unlike some UDT systems, it allows a type to be defined in code as easily as from user data, and to be used almost like a Kotlin type, as long as all you want to do is move data around. So we’re going to add some more features.

First, it would be nice to more easily access…


This is Part 2 of a series on User Defined Types in Kotlin. If you haven’t read Part 1, I recommend catching up on it before proceeding.

In part 1, we defined a User Type System. It was simple, but flexible. However, it’s still lacking one important feature, creating instances of the Types we define. As it stands, the Type system looks like this:

(Notice that since part 1, I’ve added a fieldsByIdentifier method to DType. This is just for more readable access to the type’s fields. …

Eventually, most developers end up working on a project with User Defined Types. Often it’s the basis of a customisable forms system. For me, it was a school record system in which different schools tracked different pupil statistics.

When working with UDTs, it can be tempting to reach for a dynamically typed language, such as Javascript, and relying on the lack of strong typing to handle the changing type schema. However, a strongly typed UDT can be made in very few (<500) lines of kotlin, taking advantage of some of its features.

For a UDT, we need to be able…

James

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store