Giter Club home page Giter Club logo

bifrost's Introduction

#Bifrost A remote code execution framework over RabbitMQ.

Provides a callable interface like Java executor service. Code is executed remotely using RabbitMQ as communication channel.

##Quickstart Guide The basic workflow goes like this:

  • On server side, open connection to RMQ cluster, create ExecutionServer, start() and wait for commands.
  • On client side, open connection to RMQ Cluster, create Executor and keep submitting Callable objects.

###Connection to cluster Create a Connection object.

Connection connection = new Connection(Lists.newArrayList("localhost"));

//Start the connection
connection.start();

//Do whatever

//Stop the connection
connection.stop();

###RemoteCallable

The basic entity used is the RemoteCallable template. This object is json serialized and forwarded to the remote executor. You can derive this class to create your own executor.

class TestAction extends RemoteCallable<Void> {

    public TestAction() {
        super("test");   //Set some name in the constructor
    }

    @Override
    public Void call() throws Exception {
        //Implement your method
        System.out.println("Hello World");
        return null;
    }
}

The HttpCallCommand is a callable that can be used to make remote HTTP service calls.

###Server The server component takes care of actually running the callable that you have sent from the client. To create a server use the following builder:

RemoteCallExecutionServer<Void> executionServer = RemoteCallExecutionServer.<Void>builder(TestAction.class)
                                                                        .objectMapper(mapper)
                                                                        .connection(connection)
                                                                        .concurrency(10)
                                                                        .requestQueue("bifrost-send")
                                                                        .build();

executionServer.start(); //Start the server
...
executionServer.stop(); //To stop the server

###Client The client interface is like a standard Java ExecutorService. To use it, create builder like the following:

BifrostExecutor<Map<String,Object>> executor = BifrostExecutor.<Map<String,Object>>builder(TestAction.class)
                .connection(connection)
                .objectMapper(mapper)
                .requestQueue("bifrost-send")
                .responseQueue("bifrost-recv")
                .executorService(Executors.newFixedThreadPool(10))
                .build();

//To submit job and wait for response
Future<Void> result = scheduler.submit(new TestAction());
result.get();

//To submit job and not wait for response use a RemoteTask<T> wrapper
scheduler.submit(new RemoteTask<Void>(new TestAction());

//To stop the executor
executor.shutdown();

##Version

0.1

##Tech

Uses RabbitMQ. Written in Java.

##Contribution, Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

Please follow the contribution guidelines when submitting pull requests.

LICENSE

Copyright 2014 Flipkart Internet Pvt. Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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.