These days, microservices-based architectures are being implemented almost everywhere. One business function could be using a few microservices that generate lots of network traffic in the form of messages being passed around. If we can make the way we pass messages more efficient by having a smaller message size, we could the same infrastructure to handle higher loads.
Protobuf (short for “protocol buffers”) provides language- and platform-neutral mechanisms for serializing structured data for use in communications protocols, data storage, and more. gRPC is a modern, open source remote procedure call (RPC) framework that can run anywhere. Together, they provide an efficient message format that is automatically compressed and provides first-class support for complex data structures among other benefits (unlike JSON).
Microservices environments require lots of communication between services, and for this to happen, services need to agree on a few things. They need to agree on an API for exchanging data, for example, POST (or PUT) and GET to send and receive messages. And they need to agree on the format of the data (JSON). Clients calling the service also need to write lots of boilerplate code to make the remote calls (frameworks!). Protobuf and gRPC provide a way to define the schema of the message (JSON cannot) and generate skeleton code to consume a gRPC service (no frameworks required).
Continue reading “Using a Kotlin-based gRPC API with Envoy proxy for server-side load balancing”
“Truth can only be found in one place: the code,” Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship.
The way we structure our code has a direct impact on how understandable is it. Code that is easy to follow with no or less hidden functionality is much easier to maintain. It also makes it easier for our fellow programmers to track down bugs in the code. This helps us to avoid Venkat’s Jesus Driven Development.
The way I write Spring applications comprises heavy use of Spring annotations. The problem with this approach is that partial flow of the application is controlled by annotations. The complete flow of my code is not in one place, that is, in my code. I need to look back to the documentation to understand the annotations’ behavior. By reading just the code, it is difficult to predict the flow of control.
Luckily, Spring has a new way to code to and it has been called Spring Functional or SpringFu. In this article, I will use Kotlin to showcase some of the benefits you get from SpringFu.
Continue reading “Writing better Spring applications using SpringFu”
Programs must be written for people to read, and only incidentally for machines to execute. — Abelson and Sussman
Kotlin is a new practical language designed to solve real-world problems. It is based on JVM but there are many differences between Kotlin and Java. Kotlin is a null-safe and concise language with support for functional programming. You can try programming in Kotlin here.
Kotlin coroutines provide an easy way to write highly scalable code, using the traditional style of programming, while avoiding having a thread allocated to each task.
In this article, I focus on code readability and how, in my opinion, coroutines provide a cleaner approach to writing code compared to a reactive approach. I have used Project Reactor to showcase the reactive code; however, the example can be extended to any reactive library, for example, RxJava and CompleteableFuture. Note that coroutine-based code scales as well as code written using a reactive approach. To me, coroutines are a win-win situation for developers.
Continue reading “How Kotlin’s coroutines improve code readability”
Kotlin coroutines is one of the major features of Eclipse Vert.x 3.5.
Most of us are used to writing interactive code and going the reactive way is not a trivial paradigm shift for everyone: programming using asynchronous APIs can be more challenging than using a direct synchronous style, in particular, if you have several operations that you want to do in sequence. Also, error propagation is often more complex when using asynchronous APIs.
Continue reading “Inter-Reactive Kotlin Applications”
I was lucky enough to speak at JavaOne 2017 last month. It was my first time there, as both an attendee and a speaker.
I must say I was very much impressed. In particular, during the keynotes, I was happy to see how Java is moving forward, keeping up with the fast innovation pace in the cloud area.
Continue reading “Server-side Kotlin with Eclipse Vert.x at JavaOne”