GithubHelp home page GithubHelp logo

sairam0903 / lightning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ebay/lightning

0.0 2.0 0.0 15.32 MB

Lightning is a Java based, super fast, multi-mode, asynchronous, and distributed URL execution engine from eBay

License: MIT License

Java 10.31% HTML 89.28% JavaScript 0.02% CSS 0.38%

lightning's Introduction

Lightning logo

Lightning is a Java based, super fast, multi-mode, asynchronous, and distributed URL execution engine from eBay that delivers at scale.
Please refer Detailed documentation for more information.

Release Documentation Core API Client API CoreCov ClientCov

Usage

Run In Embedded Mode

To configure lightning core as an embedded service within the application. Click to Learn more about different Modes of Operation.

// Build LightningClient in Embedded Mode
final LightningClient client = new LightningClientBuilder().setEmbeddedMode(true).build();

// Create task List
final List<Task> lightningTasks = new ArrayList<>();
lightningTasks.add(new URLTask("http://www.ebay.com"));
lightningTasks.add(new URLTask("http://www.stubhub.com"));
lightningTasks.add(new URLTask("http://github.com/"));


// Submit task List with LightningResponseCallback and Timeout
final LightningResponseCallback callback = new LightningResponseCallback() {
    // Called when request could not complete within the given timeout
    @Override
    public void onTimeout(LightningResponse response) {
        System.out.println("Lightning request timed out.");
    }

    // Called when the request execution is completed
    @Override
    public void onComplete(LightningResponse response) {
        System.out.println("Request execution complete.");
        final int failureCount = response.getFailedResponses().size();
        if (failureCount > 0) {
            System.out.println("One or more requests failed.");
        } else {
            System.out.println("All results are successful with HTTP 200.");
            // Consume response...

        }
        System.out.println(response.prettyPrint());
    }
};

client.submitWithCallback(lightningTasks, callback, 5000);

Please find step-by-step here.

Run In Standalone Mode

To configure lightning core as an external service.

//Build LightningClient and register with a core instance running @localhost on port 8989
LightningClient client = new LightningClientBuilder().addSeed("localhost").setCorePort(8989).build();

//Create tasks List
final List<Task> lightningTasks = new ArrayList<Task>();
lightningTasks.add(new URLTask("http://www.ebay.com"));
lightningTasks.add(new URLTask("http://www.stubhub.com"));
lightningTasks.add(new URLTask("http://github.com/"));

//Submit task List with LightningResponseCallback and Timeout
LightningResponseCallback callback = new LightningResponseCallback() {
    // Called when request could not complete within the given timeout
    @Override
    public void onTimeout(LightningResponse response) {
        log.info("Lightning request timed out.");
    }
    
    //Called when the request execution is completed
    @Override
    public void onComplete(LightningResponse response) {
        log.info("Request execution complete.");
        int failureCount = response.getFailedResponses().size();
        if (failureCount > 0) {
            log.info("One or more requests failed.");
        } else {
            log.info("All results are successful with HTTP 200.");
            //Consume response...
        }
        log.info(response.prettyPrint());
    }
};
client.submitWithCallback(tasks, callback, 5000);

Please find step-by-step here.

Changelog

See CHANGELOG.md

Contributors

Lightning is served to you by Shankar Shukla and Site Engineering Tools Team at eBay Inc. We would like to give special thanks to our Manager Sham Kalwit for his vision, valuable guidance and encouragement.

License

MIT

lightning's People

Contributors

shankarshukla avatar

Watchers

James Cloos avatar Sai Ram Gupta avatar

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.