Monday, June 5, 2017

JSON on BASH: JQ

In one of my previous posts, I wrote about underscore-cli for looking at JSON output (e.g. to see the curl response from a REST web service). An alternative to this is jq, a command line processor for JSON in bash.

Some things about jq that make it powerful is that it can be used as a filter (that what jq really is). This means that you can select which parts of the JSON buffer be returned from the stream so that you can you do your own navigation.

For more information, check out https://stedolan.github.io/jq/tutorial/

Friday, April 28, 2017

Documenting Architecture Decisions - ADR

As I reviewed the 2017 Thoughtworks technology techniques trends, one cool recommendation was about to "try" the concept of Lightweight Architecture Decision Records. I must admit, I have been looking for something like this as I'm tired of having note pads everywhere, and I'm really trying to stay away from MS-Word documents and Powerpoints for developers. I have been looking for something lightweight, easy for developers to follow.

Saturday, April 22, 2017

Twelve Factor Apps: Spring Cloud Config


I have been using Spring for many years now and I really like the simplicity and non-invasive model of its features. As I have been implementing 12 Factor applications, I needed to start using a central way to configure the many microservices we are building. This is where Spring Cloud Config comes to the rescue.

Saturday, March 4, 2017

REST Endpoint returning 404 without Exceptions

At some point in your REST endpoint design, you will need to return a non 200 response. Now, most implementations show how to implement this using exceptions. While this may seem like a nice approach (from a programming language point of view), exceptions can add overhead to the running JVM. This translates to ineffective use of resources of the JVM for supporting non 200 responses.

Here is a gist where you don't use exceptions to return non 200 responses:


A few things to note from this snippet:
  1. This is a Spring Boot implementation (Boot makes things so much simple)
  2. The HttpServletResponse is injected by Boot (Spring MVC), no need of additional setup.
  3. Notice that the body return is null already, so the non 200 response makes more sense.
Please note that this is an implementation specific construct to support non 200 responses. Jersey and others also provide a non exceptional way to handle this scenario. Semantics of what the endpoint does (nouns non verbs, uniform contracts, interfaces, etc) are not part of the discussion. This is strictly an implementation description meant to support the abstraction defined by the given REST endpoint.

Friday, February 10, 2017

Presentation on Spring Boot

A few months ago, I was invited to speak on Spring Boot and Cloud Native. This was a good discussion. It was fun to build an app from scratch using Boot. For those interested, you can find the app in my github account:

https://github.com/albertoaflores/spring-boot-demo

Slides used for that preso can be found here:

http://www.slideshare.net/albertoaflores/spring-boot-intro

Hope some find this useful.