All Projects → bbilger → Jrestless

bbilger / Jrestless

Licence: apache-2.0
Run JAX-RS applications on AWS Lambda using Jersey. Supports Spring 4.x. The serverless framework can be used for deployment.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jrestless

Zappa
Serverless Python
Stars: ✭ 224 (+140.86%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Express
Run Node.js web applications and APIs using existing application frameworks on AWS #serverless technologies such as Lambda, API Gateway, Lambda@Edge, and ALB.
Stars: ✭ 4,265 (+4486.02%)
Mutual labels:  api-gateway, serverless, aws-lambda
Aegis
Serverless Golang deploy tool and framework for AWS Lambda
Stars: ✭ 277 (+197.85%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Aws Alias
Alias support for Serverless 1.x
Stars: ✭ 171 (+83.87%)
Mutual labels:  api-gateway, serverless, aws-lambda
Aws Serverless Java Container
A Java wrapper to run Spring, Jersey, Spark, and other apps inside AWS Lambda.
Stars: ✭ 1,054 (+1033.33%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Sinatra Sample
Demo code for running Ruby Sinatra on AWS Lambda
Stars: ✭ 195 (+109.68%)
Mutual labels:  api-gateway, serverless, aws-lambda
Vandium Node
AWS Lambda framework for building functions using Node.js for API Gateway, IoT applications, and other AWS events.
Stars: ✭ 377 (+305.38%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (+9.68%)
Mutual labels:  api-gateway, serverless, aws-lambda
Corgi
AWS Lambda / API Gateway native, fast and simple web framework
Stars: ✭ 44 (-52.69%)
Mutual labels:  api-gateway, serverless, aws-lambda
Lambda Api
Lightweight web framework for your serverless applications
Stars: ✭ 929 (+898.92%)
Mutual labels:  api-gateway, serverless, aws-lambda
Zappa
Serverless Python
Stars: ✭ 11,859 (+12651.61%)
Mutual labels:  api-gateway, serverless, aws-lambda
Aws Power Tuner Ui
AWS Lambda Power Tuner UI is an open source project creating a deployable easy to use website built on a layered technology stack allowing you to optimize your Lambda functions for cost and/or performance in a data-driven way via an easy to use UI.
Stars: ✭ 52 (-44.09%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+3101.08%)
Mutual labels:  api-gateway, serverless, aws-lambda
Yoyo
A dead simple comment engine built on top of AWS lambda and React, alternative comment service to Disqus.
Stars: ✭ 210 (+125.81%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Architectures Aws
The code repository for the Serverless Architectures on AWS book
Stars: ✭ 120 (+29.03%)
Mutual labels:  api-gateway, serverless, aws-lambda
Claudia
Deploy Node.js projects to AWS Lambda and API Gateway easily
Stars: ✭ 3,690 (+3867.74%)
Mutual labels:  api-gateway, serverless, aws-lambda
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+410.75%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-45.16%)
Mutual labels:  api-gateway, serverless, aws-lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+8974.19%)
Mutual labels:  api-gateway, serverless, aws-lambda
Aws Github Actions
Deploy 🚀 to AWS ☁️ with GitHub Actions!
Stars: ✭ 70 (-24.73%)
Mutual labels:  serverless, aws-lambda

JRestless

JRestless allows you to create serverless applications using JAX-RS.

Build Status codecov GitHub issues GitHub closed issues License

SonarQube: SonarQube - Quality Gate SonarQube - Coverage SonarQube - Bugs SonarQube - Vulnerabilities SonarQube - Tests SonarQube - Duplicated Blocks SonarQube - Technical Debt SonarQube - Code Smells

Table of Contents

Description

JRestless is a framework allowing you to build serverless JAX-RS applications or rather to run JAX-RS applications in FasS (Function as a Service) environments like AWS Lambda. This is achieved by providing a generic Jersey container that handles requests in the form of POJOs. For each FaaS environment there is a separate module acting as an integration layer between the actual environment and the generic Jersey container.

Since this framework is just a wrapper around or rather a container for Jersey, you can use almost all JAX-RS features plus Jersey's custom extensions like Spring integration - not Spring MVC, though since this functionality is provided by JAX-RS itself.

Supported Environments:

Motivation

The motivation for this project is to avoid a cloud vendor lock-in and to allow developers to run and test their code locally.

Features

  • Almost all JAX-RS features can be used (JSON/XML/text/... requests/responses, container request/response filters, etc.). Example: aws-gateway-showcase
  • Jersey extensions can be used. For example:
  • AWS Gateway Functions can also consume and produce binary data. Example: aws-gateway-binary
  • AWS Gateway Functions use the data added to the request by authorizers (Custom Authorizers or Cognito User Pool Authorizers) to create a Principal (CustomAuthorizerPrincipal or CognitoUserPoolAuthorizerPrincipal) within the SecurityContext containing all claims. Examples: aws-gateway-security-cognito-authorizer and aws-gateway-security-custom-authorizer
  • AWS Gateway Functions can use a CORS filter. Example: aws-gateway-cors
  • Injection of provider and/or function type specific values via @javax.ws.rs.core.Context into resources and endpoints:
    • All AWS functions can inject com.amazonaws.services.lambda.runtime.Context.
    • AWS Gateway Functions can also inject the raw request GatewayRequest
    • AWS Service Functions can also inject the raw request ServiceRequest
    • AWS SNS Functions can also inject the raw request SNSRecord
  • It's worth mentioning that AWS Gateway Functions is designed to be used with API Gateway's proxy integration type for Lambda Functions. So there are no limitations on the status code, the headers and the body you return.

Function Types

AWS

  • Gateway Functions are AWS Lambda functions that get invoked by AWS API Gateway. Usage example: aws-gateway-usage-example. Read More....
  • Service Functions are AWS Lambda functions that can either be invoked by other AWS Lambda functions or can be invoked directly through the AWS SDK. The point is that you don't use AWS API Gateway. You can abstract the fact that you invoke an AWS Lambda function away by using a special feign client (jrestless-aws-service-feign-client). Usage example: aws-service-usage-example. Read More....
  • SNS functions are AWS Lambda function that get invoked by SNS. This allow asynchronous calls to other Lambda functions. So when one Lambda function publishes a message to one SNS topic, SNS can then invoke all (1-N) subscribed Lambda functions. Usage example: aws-sns-usage-example. Read More....

Fn Project

Note: the framework is split up into multiple modules, so you choose which functionality you actually want to use. See Modules

Usage Example

AWS Usage Example

All examples, including the following one, can be found in a separate repository: https://github.com/bbilger/jrestless-examples

JRestless does not depend on the serverless framework but it simplifies the necessary AWS configuration tremendously and will be used for this example.

Install serverless (>= 1.0.2) as described in the docs https://serverless.com/framework/docs/guide/installing-serverless/

Setup your AWS account as described in the docs https://serverless.com/framework/docs/providers/aws/guide/credentials/

Create a new function using serverless

mkdir aws-gateway-usage-example
cd aws-gateway-usage-example
serverless create --template aws-java-gradle --name aws-gateway-usage-example
rm -rf src/main/java # remove the classes created by the template
mkdir -p src/main/java/com/jrestless/aws/examples # create the package structure

Replace serverless.yml with the following contents:

service: aws-gateway-usage-example-service

provider:
  name: aws
  runtime: java8
  stage: dev
  region: eu-central-1

package:
  artifact: build/distributions/aws-gateway-usage-example.zip

functions:
  sample:
    handler: com.jrestless.aws.examples.RequestHandler
    events:
      - http:
          path: sample/{proxy+}
          method: any

Replace build.gradle with the following contents:

apply plugin: 'java'

repositories {
  jcenter()
  mavenCentral()
}
dependencies {
  compile(
    'com.jrestless.aws:jrestless-aws-gateway-handler:0.6.0',
    'org.glassfish.jersey.inject:jersey-hk2:2.26',
    'org.glassfish.jersey.media:jersey-media-json-jackson:2.26'
  )
}
task buildZip(type: Zip) {
  archiveName = "${project.name}.zip"
  from compileJava
  from processResources
  into('lib') {
    from configurations.runtime
  }
}
build.dependsOn buildZip

Create a new JAX-RS resource and a response object (src/main/java/com/jrestless/aws/examples/SampleResource.java):

package com.jrestless.aws.examples;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/sample")
public class SampleResource {
  @GET
  @Path("/health")
  @Produces({ MediaType.APPLICATION_JSON })
  public Response getHealthStatus() {
    return Response.ok(new HealthStatusResponse("up and running")).build();
  }
  static class HealthStatusResponse {
    private final String statusMessage;
    HealthStatusResponse(String statusMessage) {
      this.statusMessage = statusMessage;
    }
    public String getStatusMessage() {
      return statusMessage;
    }
  }
}

Create the request handler (src/main/java/com/jrestless/aws/examples/RequestHandler.java):

package com.jrestless.aws.examples;

import org.glassfish.jersey.server.ResourceConfig;

import com.jrestless.aws.gateway.GatewayFeature;
import com.jrestless.aws.gateway.handler.GatewayRequestObjectHandler;

public class RequestHandler extends GatewayRequestObjectHandler {
  public RequestHandler() {
    // initialize the container with your resource configuration
    ResourceConfig config = new ResourceConfig()
      .register(GatewayFeature.class)
      .packages("com.jrestless.aws.examples");
    init(config);
    // start the container
    start();
  }
}

Build your function from within the directory aws-gateway-usage-example:

gradle build

This, amongst other things, creates a deployable version of your function (build/distributions/aws-gateway-usage-example.zip) using the dependent task buildZip.

Now you can deploy the function using serverless:

serverless deploy

If serverless is configured correctly, it should show you an endpoint in its output.

...
endpoints
  ANY - https://<SOMEID>.execute-api.eu-central-1.amazonaws.com/dev/sample/{proxy+}
...

Hit the endpoint:

curl -H 'Accept: application/json' 'https://<SOMEID>.execute-api.eu-central-1.amazonaws.com/dev/sample/health'
# {"statusMessage":"up and running"}

Fn Project Usage Example

A very good example of how to use JRestless on Fn Project can be found here: https://github.com/fnproject/fn-jrestless-example

Modules

JRestless is split up into multiple modules whereas one has to depend on the *-handler modules, only. jrestless-aws-gateway-handler is probably the most interesting one.

All modules are available in jcenter.

Alternative Projects

AWS

  • Java
    • lambadaframework provides similar functionality like JRestless. It implements some features of the JAX-RS standard and includes deployment functionality within the framework itself.
    • ingenieux/lambada Non-JAX-RS Java framework
    • aws-lambda-servlet run JAX-RS applications - uses Jersey and pretends to run in a servlet container
    • aws-serverless-java-container run JAX-RS (using Jersey), Spring (MVC) and Spark - pretends to run in a servlet container
  • JavaScript
  • Python
    • Zappa - run and deploy Python applications
    • Chalice - run and deploy Python applications

Limitations

AWS

  • for all function types
    • stateless only (you could utilize some cache like Redis, though)
    • AWS Lambda functions have a maximum execution time of 5 minutes
  • Gateway functions
    • AWS API Gateway has a timeout of 30 seconds
    • Multiple headers with same name are not supported

Fn Project

Release History

CHANGELOG

Meta

License

Distributed under Apache 2.0 license. See License for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].