All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tomakehurst.crashlab.HttpSteps Maven / Gradle / Ivy

The newest version!
package com.tomakehurst.crashlab;

import com.ning.http.client.*;

import java.io.IOException;

public abstract class HttpSteps implements Runnable {

    private final AsyncCompletionHandler completionHandler;
    private final AsyncHttpClient httpClient;
    private final String name;

    protected HttpSteps(String name) {
        this(name, new NoOpCompetionHandler(), buildClient());
    }

    protected static AsyncHttpClient buildClient() {
        final int timeoutMs = 60 * 60 * 1000;
        AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
                .setConnectionTimeoutInMs(timeoutMs)
                .setRequestTimeoutInMs(timeoutMs)
                .build();
        return new AsyncHttpClient(config);
    }

    protected HttpSteps(String name, AsyncCompletionHandler completionHandler, AsyncHttpClient httpClient) {
        this.completionHandler = completionHandler;
        this.httpClient = httpClient;
        this.name = name;
    }

    public String name() {
        return name;
    }

    @Override
    public void run() {
        try {
            run(httpClient, completionHandler);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public abstract ListenableFuture run(AsyncHttpClient http, AsyncCompletionHandler completionHandler) throws IOException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy