Photo by Andreas Klassen on Unsplash

We, as software developers, are now designing more microservices than monolith applications. We also need to implement microservices more productively and reliably than before, with the technology stacks we are most familiar with.

In the Java world, to develop and deploy microservices, we often utilize existing frameworks that share environments such as application servers, non-optimized Java runtimes, dynamic and reflection and so on. These result in high RAM utilization and slow startup time, further reduce developers’ productivity and microservices’ stability.

Quarkus is a Java runtime that targets the needs of the Java microservices developers. It is designed for developers to…


According to https://api.rocket.rs/master/rocket/response/struct.Redirect.html, it recommends Redirect::to("/other_url") or Redirect::temporary("/other_url") be used to implement your requirements, which returns status code 303 and 307 respectively, with the location header set as the other_url. For example:

#[post("/", format ="application/json", data = "<new_post>")]

pub fn create_post(new_post: Json<NewPost>, _connection: DbConn) -> Redirect {

...

Redirect::to(format!("/new?title={}", Uri::percent_encode(new_post.title.as_str())))

}

And the response will similar to the following:

< HTTP/1.1 303 See Other

< Location: /new?title=Rust%20microservices

< Server: Rocket

< Content-Length: 0

...

Thanks for reading.


Yes. You are right. I don't need the nightly features of Rust in this post. I just took the convenience of experimenting Rocket and Diesel with the Rust nightly compiler in my second post: https://genekuo.medium.com/creating-a-rest-api-in-rust-with-persistence-rust-rocket-and-diesel-a4117d400104. So I use the same here. We should use the stable version whenever developing in production. Thanks for pointing that out.


Photo by John Baker on Unsplash

Introduction

We will be creating a REST API in Rust, which serves resources (posts) with persistence in a postgres database.

Rocket framework will be used to setup the API and Diesel to handle persistence with a Postgres database.

We will test our Rust API and a Postgres database by running them as separate docker containers which communicate with each other to expose CRUD functionalities from our API and implement persistence with a Postgres database.

I’ve provided the source code in the rocket-diesel branch of my Github repo.

Dependencies: Cargo.toml

First, we need to setup the following dependencies for our REST API project:

[dependencies]
rocket…

Introduction

We will create a simple REST service providing the functions of CRUD (create, read, update, and delete) for in-memory user data. Without serialization and deserialization between JSON and Rust instances, which we will expand the source code on further articles, this example will handle only CRUD of user ids to focus on the coding of a HTTP service with Rust and relevant crates.

The sample code can be cloned from the following GitHub repository: https://github.com/genekuo/rust-microservices.git

After implementing the initial version of the microservices, we will test it by using curl commands to see how it works.

Initial setup with hyper crate

We have decided to…


In this article, I summarises several ES6 features and a brief introduction to the concept and usage of these features with simple examples. The main goal is to provide newcomers a quick start in making use of ES6.

let and const

Prior to ES6, we can use var to declare a variable inside a code block and the JavaScript engine hoists the declaration to the top of the execution context, such as a function. This mechanism makes the variable visible outside of the block in which it is declared. …


In JavaScript, there are no abstract blueprints for objects called “classes” as there are in traditional object-oriented languages. However, the JavaScript’s [[prototype]] mechanism we will discuss in this article provides behavior delegation for modelling objects in an application, such as the emulation of inheritance, polymorphism, instance construction and so on. Behavior delegation has more flexible and dynamic features than those of class-based object modelling in traditional object-oriented languages.

Traditional Object-oriented Approach to Object Modeling

Many languages provides syntax which enables class-oriented software design, that is, we design parent and child classes as blueprints for objects (or instances). With traditional object-oriented language like Java, objects are instantiated…


In Kotlin, functions are the first-class citizens. They are meant to increase reusability and at the same time to reduce the possibility of unsafe programs that are often untestable and buggy. We will take a look at the functional programming features of Kotlin and understand how they help developers to write safe programs.

How to avoid writing unsafe programs

Many bugs come from programs executing incorrectly with the outside world, which are effects that are not easy to test and we have little control of. They are guidelines that can make our programs safer from buggy code.

Avoiding sharing mutable variables

This principle protects programs from…


Photo by Giorgio Dell'Erba on Unsplash

In this article, we will first understand what GraphQL is when designing APIs on a software architecture. we will then get to know the concepts and the GraphQL Query operation that we can utilize to design and implement the APIs per our needs. Finally, we will build a rather simple GraphQL server based on what we have learned in this article with the help of Apollo, and test it through Apollo GraphQL Playground.

What is GraphQL?

When designing network communication between client and server, REST has been one of the most popular choices in the software industry. In REST, it enables applications to…


source: https://kubernetes.io/

Kubernetes is a software system that allows you to deploy and manage containerized apps. It abstracts away the underlying infrastructure to simplify development, deployment and management for both dev and ops teams. There are many benefits and components provided by the Kubernetes platform with many options about installing and setting up the Kubernetes cluster such as single-node, multiple-node and cloud-based deployments. In this article, we will focus on setting up multiple-node cluster on a laptop (such as 2.7 GHz Intel Core i5, 8G RAM should be sufficient for demonstration purpose).

In the process of setting up the Kubernetes cluster, you…

Gene Kuo

Solutions Architect, AWS CSAA/CDA: microservices, kubernetes, algorithms, Java, Rust, Golang, React, JavaScript…

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