-
Notifications
You must be signed in to change notification settings - Fork 30
/
Async.java
29 lines (26 loc) · 1.1 KB
/
Async.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.puppetlabs.http.client;
import com.puppetlabs.http.client.impl.JavaClient;
import com.puppetlabs.http.client.impl.PersistentAsyncHttpClient;
import com.puppetlabs.http.client.metrics.Metrics;
/**
* This class allows you to create an AsyncHttpClient for use in making
* HTTP Requests. It consists exclusively of a static method to create
* a client.
*/
public class Async {
/**
* Allows you to create an instance of an AsyncHttpClient for use in
* making HTTP requests.
*
* @param clientOptions the list of options with which to configure the client
* @return an AsyncHttpClient that can be used to make requests
*/
public static AsyncHttpClient createClient(ClientOptions clientOptions) {
final String metricNamespace = Metrics.buildMetricNamespace(clientOptions.getMetricPrefix(),
clientOptions.getServerId());
return new PersistentAsyncHttpClient(JavaClient.createClient(clientOptions),
clientOptions.getMetricRegistry(),
metricNamespace,
clientOptions.isEnableURLMetrics());
}
}