GithubHelp home page GithubHelp logo

termite's Introduction

Overview

Termite is another research project of "Lambdafication" process after Podilizer in scope of Service Tooling initiative. We developed the library which would take care of automatic Lambda functions generating based on the the written code. This library could be used both in existing projects and in developing from scratch.

Idea

The idea of library is to use java custom annotations for marking and configuring Lambda functions. This approach allows to abstract the function creation process which helps developer to focus on the actual code writing. Java annotations have already proven themselves being used in successful projects, for instance Spring framework. We want to create a convenient tool with least configurations to simplify Lambdalizing process and help users to get involved into FaaS.

Implementation

The library does two main jobs: creating functions and invoking them when it's needed.

To implement the first part we used java built-in annotation processor linked to custom annotation. Annotation processors are being performed over the compilation phase. It means that after compilation of your project marked with particular annotations methods are already created at provider's service (AWS Lambda as first implementation).

The invoking part of the library was implemented using java aspectj library, that allows to intercept the appropriate method call over the runtime phase and call already created Lambda function instead of the local method. Furthermore every function invocation starts in the new thread, it provides the use of the such strength of FaaS as auto-scaling.

Structure diagram

How to

Before using Termite directly from our Git repository, make sure to fulfil the following prerequisites:

  • AWS account and credentials configured at your machine (aws command-line tool should work: aws lambda list-functions)
  • JDK 1.8+ installed
  • Maven installed

Clone from repository (In the folder ‘example’ you can find example project which uses Termite):

clone https://github.com/serviceprototypinglab/termite.git

Compile the project:

cd termite
mvn clean install

Afterwards, Termite is ready to be used within your Java application. Assuming you use Maven, create your own Maven project and configure dependencies. In case you use another build system, Termite does not offer integration yet but we are happy to accept patches of course.

<dependency>
    <groupId>ch.zhaw.splab.servicetooling</groupId>
    <artifactId>Termite</artifactId>
    <version>0.1</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>${aspectj.version}</version>
    <scope>runtime</scope>
</dependency>

Correct execution is able only with the following argument to the Maven execution plugin:

-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/
aspectjweaver-${aspectj.version}.jar

Also you need the generic Maven plugin for compiling generated sources because Termite will generate some source code files:

<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <version>2.2.4</version>
        <executions>
            <execution>
                <id>process</id>
                <goals>
                    <goal>process</goal>
                </goals>
                <phase>process-sources</phase>
                <configuration>
                    <proc>none</proc>
                    <outputDirectory>${generated.sources.directory}</outputDirectory>
                    <processors>
                        <processor>ch.zhaw.splab.podilizerproc.annotations.LambdaProcessor
                        </processor>
                    </processors>
                </configuration>
            </execution>
        </executions>
</plugin>

A full example of a Maven configuration file is located in the Termite repository at

example/pom.xml

Afterwards, you’re ready to go serverless! Annotate functions you want to upload with “@Lambda”, see the example above.

Compile the created project:

mvn clean install

termite's People

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.