Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
/ lightning Public archive

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

License

Notifications You must be signed in to change notification settings

eBay/lightning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Build Status 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(Ananth, Prabhu Pandurangan, Pragadesh) at eBay Inc. We would like to give special thanks to our Director Sham Kalwit for his vision, valuable guidance and encouragement.

License

MIT

About

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

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages