BT

InfoQ Homepage News Nimbus: New Framework for Building Java Serverless Applications

Nimbus: New Framework for Building Java Serverless Applications

Leia em português

This item in japanese

Bookmarks

The Nimbus framework is a Java framework that aims to ease the development, testing, and deployment of Function-as-a-Service (FaaS) applications in the cloud. Nimbus provides a cloud-agnostic, common interface for interacting with cloud providers’ serverless functionality.

In a recent Medium post, Thomas Allerton, the author of the framework, states that "[f]or newcomers looking to make simple applications, there can be a very steep learning curve, having to learn the cloud lingo when all you really want is to deploy a few HTTP endpoints with somewhere to store the data." As an alternative to learning cloud configuration syntax and FaaS APIs, Nimbus makes use of annotations to support several common backend operations that are used when building function-based applications.

Allerton argues that the main advantage of Nimbus is not having to create a configuration file in order to declare cloud resources (like AWS SAM or the Serverless framework). In turn, developers "are much less prone to making mistakes by forgetting parameters". Additionally, Nimbus does compile-time checking of deployment parameters with the goal of detecting mistakes as early as possible.

To get a better feel for how the framework is used, consider the following example which utilizes the @HttpServerlessFunction annotation to create a very simple REST API.

public class RestApi {

    @HttpServerlessFunction(path="getOsTypes", method= HttpMethod.GET)
    public List<String> currentOsTypes() {
           return Arrays.asList(new String[] {"Windows", "Mac", "Linux"});
    }
}

Nimbus also supports other operations:

In addition to support for different types of operations, Nimbus also comes with support for several types of datastores should a serverless application require some sort of persistence. The following example shows setting up a document store using the @DocumentStore annotation.

@DocumentStore
public class OsPreference {

    @Key
    private String id;

    @Attribute
    private String preference;

    public OsPreference(String id, String preference) {
           this.id = id;
           this.preference = preference;
    }
    
    // ...
    // getters & setters
    // ...
}

With the document store setup, the DocumentStoreClient can then be used to persist data to it.

private DocumentStoreClient<OsPreference> client =
   ClientBuilder.getDocumentStoreClient(OsPreference.class);

@HttpServerlessFunction(path="setOsPreference", method= HttpMethod.POST)
@UsesDocumentStore(OsPreference.class)
public String setOsPreference(OsPreference osPreference) {
   client.put(osPreference);
   return "Success";
}

Support for additional data stores (and clients) include: relational store for storing relational data; key-value store for storing data to a key-value store; and a file store for object storage (with explicit support for static website hosting and file uploads)

Another common challenge of building serverless applications is testing. Nimbus provides explicit support for both unit and integration testing. The unit testing support adds the ability to create a local mock deployment of any of the operations listed above, which can accept requests and verify that functions are invoked correctly or that data is stored appropriately. The integration-testing support is somewhat more limited than the unit-testing support, and only supports HTTP-based tests. These tests add the ability to start a local web server which can be used to verify that requests invoke the expected function.

Currently, as part of the initial release, only AWS is supported. However, support for other cloud providers is planned.

To learn more about Nimbus, be sure to read the Getting Started guide, visit the reference documentation, or clone the source on GitHub.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Is this actively supported?

    by sandeep sharma /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I have evaluated the framework and raised a couple of issues on github however it seems the framework is not actively supported.

  • Re: Is this actively supported?

    by Thomas Allerton /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Yes it is actively supported, however there is currently only one active developer, so apologies for any delays getting back to you.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.