Code Monkey home page Code Monkey logo

jerverless's Introduction


GitHub license Build Status GitHub (pre-)release GitHub last commit HitCount OpenCollective Backers

Turn anything into a serverless function.. Docker ready!

jerverless is a serverless runner which will execute anything (binaries, commands or your scripts) as a serverless function. It simply pipes http POST data into STDIN of any executable vice versa.

How it works!

See more info,

Example functions

How to create functions?

On Machine (or VM)

  1. Download Jerverless and extract the archive

  2. Create jerverless.yml

# use port 8080
port: 8080
# enable CORS for the server
cors: '*'
# Define your routes
routes:
  # a sample route with
  - endpoint: /foo # endpoint /foo
    command: python test.py # command to run
    contentType: text/html # set content type
    
  - endpoint: /bar #endpoint /bar
    command: python test.py --bar # command with an argument
    contentType: text/html # set your content type
    cors: 'xyz.com' # override cors for this specific route
  1. Create your program (eg:- helloworld.py)

We are using python2.7 in example

name = raw_input()
print "Hello %s!" % name
  1. Start server!
 $ bin/jerverless

or if you are on windows

 $ bin\jerverless.bat
  1. Test it!
 $ curl -d Jerverless http://localhost:8080/foo

Or simply use template and jump to last step!

Docker

  1. On your local machine, clone this repo and go to an examples directory of choice (eg: python):
 $ git clone https://github.com/jerverless/jerverless.git
 $ cd jerverless/examples/python
  1. Create the docker image:
 $ docker build --no-cache -t jerverless-py .
  1. Run the app:
 $ docker run -it -p 8080:8080 jerverless-py
  1. Navigate to 'https://localhost:8080/function' in your browser.

Kubernetes

  1. Create docker image for your function and push to dockerhub

  2. Add docker image name to .yml deployment

Project Status

  • Initial work (Structure, basic server with runner)
  • Multithreaded server mode
  • Unit cases
  • CLI commands
  • Basic Samples
  • Docs
  • Beta Release!

Developer Guide

Requirements

  • JDK 1.8

Getting started

Clone the repository in your local directory

 $ git clone <forked_url>

We are using gradle as the build tool. This command will download and install gradle, then it will build the jar file.

Windows users may use .\gradlew instead of ./gradlew It applies to all bash commands listed below.

 $ ./gradlew assemble

The resulted jar file can be found in build/libs

 $ java -jar build/libs/jerverless-1.0.0.jar

Or run

 $ ./gradlew assembleDist

This will create distributions of jerverless, you can find them in build/distributions/

To install this distribution in a path you desired try out

 $ ./gradlew installDist

By default it will be installed in build/install/jerverless

To run the distribution, try

 $ build/install/jerverless/bin/jerverless

Become a committer

Submit a pull request or raise 3 helpful issues to join jerverless Team!

jerverless's People

Contributors

daxter44 avatar imesh94 avatar isuru117 avatar kasvith avatar shalithasuranga avatar skaveesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jerverless's Issues

Error: Could not find or load main class org.jerverless.boot.BootServer

I'm just setting up the environment on windows.

Having this issue.

$ java -jar build/libs/jerverless-1.0.0.jar
Error: Could not find or load main class org.jerverless.boot.BootServer

Check the build.gradle
jar { manifest { attributes 'Main-Class': 'org.jerverless.boot.BootServer' } }

Deserialize stdin into JSONable interface?

Since the HTTP data is POSTed, it will be more natural for the function to receive a JSON object rather than an input stream and output a JSON object. This will help in porting the functions to other cloud providers which also receive a JSON event object.

Something like this:

const rl = readline.createJSONInterface({
    input: process.stdin
});

A way to run more functions

Motivation

Currently jerverless supports only one endpoint. /function, what if we can make it flexible, to add more function handlers?

Proposal

We can add

  • Function endpoints ๐Ÿ”ข : so people can also build apps using jerverless using anything they like. One instance now can handle more functions like /foo, /bar
  • Request Mappers ๐Ÿคœ : Some functions may need special formatting in requests, with this users can build their own request mappers which maps a traditional http request in to the format they want
  • Response Mappers ๐Ÿค› : Oh yes, we need the other way also, what if you want a JSON response? a XML ? even an HTML ? what if an user wanted to reshape the response of application without touching the code ? (maybe its legacy, we know nobody touches it if it works ๐Ÿ˜‰), well now they can also define response mappers
  • Request Restrictions ๐Ÿ›‘ : On some point users may want to force the clients to use a HTTP method like GET, PUT, POST etc, we now allow to restrict them ๐Ÿ˜‰ (or can we add this to mapper? its also okey)

More to come

Roadmap

  • Endpoints
  • Input Mappers
  • Response Formatters

Introduce Gradle

Maven is messy, a big xml file will be generated
Using Gradle we can reduce the complexity and we can build better scripts

Update README

$ build/install/bin/jerverless should be changed to $ build/install/jerverless/bin/jerverless

Can't change configuration during runtime

javerless.yml file is loaded on application booting time.To add a function, there is a down time therefore working functions also have to be stopped for sometime, better to add a feature to scan changes in javerless.yml file once in 1 minute (or respectively).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.