Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from launchdarkly/pk/ms-timeouts
Browse files Browse the repository at this point in the history
Pk/ms timeouts
  • Loading branch information
pkaeding committed May 15, 2015
2 parents 609ca83 + 6c2ca29 commit 9f75f02
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
LaunchDarkly SDK for Java
=========================

![Circle CI](https://circleci.com/gh/launchdarkly/java-client.png)

Quick setup
-----------

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {

allprojects {
group = 'com.launchdarkly'
version = "0.7.0"
version = "0.8.0"
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
Expand Down
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies:
pre:
- cp gradle.properties.example gradle.properties
7 changes: 7 additions & 0 deletions gradle.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
githubUser = YOUR_GITHUB_USERNAME
githubPassword = YOUR_GITHUB_PASSWORD
signing.keyId = 5669D902
signing.password = SIGNING_PASSWORD
signing.secretKeyRingFile = SECRET_RING_FILE
ossrhUsername = launchdarkly
ossrhPassword = OSSHR_PASSWORD
4 changes: 2 additions & 2 deletions src/main/java/com/launchdarkly/client/LDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ protected CloseableHttpClient createClient() {
.build();

RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(config.connectTimeout * 1000)
.setSocketTimeout(config.socketTimeout * 1000)
.setConnectTimeout(config.connectTimeout)
.setSocketTimeout(config.socketTimeout)
.build();
client = CachingHttpClients.custom()
.setCacheConfig(cacheConfig)
Expand Down
41 changes: 37 additions & 4 deletions src/main/java/com/launchdarkly/client/LDConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ protected LDConfig(Builder builder) {
/**
* A <a href="http://en.wikipedia.org/wiki/Builder_pattern">builder</a> that helps construct {@link com.launchdarkly.client.LDConfig} objects. Builder
* calls can be chained, enabling the following pattern:
* <p>
*
* <pre>
* LDConfig config = new LDConfig.Builder()
* .connectTimeout(3)
* .socketTimeout(3)
* .build()
* </pre>
* </p>
*
*/
public static class Builder{
Expand Down Expand Up @@ -75,22 +74,56 @@ public Builder baseURI(URI baseURI) {
/**
* Set the connection timeout in seconds for the configuration. This is the time allowed for the underlying HTTP client to connect
* to the LaunchDarkly server. The default is 2 seconds.
*
* <p>Both this method and {@link #connectTimeoutMillis(int) connectTimeoutMillis} affect the same property internally.</p>
*
* @param connectTimeout the connection timeout in seconds
* @return the builder
*/
public Builder connectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
this.connectTimeout = connectTimeout * 1000;
return this;
}

/**
* Set the socket timeout in seconds for the configuration. This is the number of seconds between successive packets that the
* client will tolerate before flagging an error. The default is 10 seconds.
*
* <p>Both this method and {@link #socketTimeoutMillis(int) socketTimeoutMillis} affect the same property internally.</p>
*
* @param socketTimeout the socket timeout in seconds
* @return the builder
*/
public Builder socketTimeout(int socketTimeout) {
this.socketTimeout = socketTimeout;
this.socketTimeout = socketTimeout * 1000;
return this;
}

/**
* Set the connection timeout in milliseconds for the configuration. This is the time allowed for the underlying HTTP client to connect
* to the LaunchDarkly server. The default is 2000 ms.
*
* <p>Both this method and {@link #connectTimeout(int) connectTimeout} affect the same property internally.</p>
*
* @param connectTimeoutMillis the connection timeout in milliseconds
* @return the builder
*/
public Builder connectTimeoutMillis(int connectTimeoutMillis) {
this.connectTimeout = connectTimeoutMillis;
return this;
}

/**
* Set the socket timeout in milliseconds for the configuration. This is the number of milliseconds between successive packets that the
* client will tolerate before flagging an error. The default is 10,000 milliseconds.
*
* <p>Both this method and {@link #socketTimeout(int) socketTimeout} affect the same property internally.</p>
*
* @param socketTimeoutMillis the socket timeout in milliseconds
* @return the builder
*/
public Builder socketTimeoutMillis(int socketTimeoutMillis) {
this.socketTimeout = socketTimeoutMillis;
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/launchdarkly/client/LDCountryCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ public Locale toLocale()
NZ("New Zealand", "NZL", 554, Assignment.OFFICIALLY_ASSIGNED),

/**
* <a href=http://en.wikipedia.org/wiki/Oman"">Oman</a>
* <a href="http://en.wikipedia.org/wiki/Oman">Oman</a>
* [<a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#OM">OM</a>, OMN, 512,
* Officially assigned]
*/
Expand Down Expand Up @@ -2256,7 +2256,7 @@ public Assignment getAssignment()
* {@code Locale} class.
* </p>
*
* <table border="1" style="border-collapse: collapse;" cellpadding="5">
* <table border="1" style="border-collapse: collapse;" cellpadding="5" summary="">
* <tr bgcolor="#FF8C00">
* <th>CountryCode</th>
* <th>Locale</th>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/launchdarkly/client/LDUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ JsonElement getCustom(String key) {
/**
* A <a href="http://en.wikipedia.org/wiki/Builder_pattern">builder</a> that helps construct {@link com.launchdarkly.client.LDUser} objects. Builder
* calls can be chained, enabling the following pattern:
* <p>
*
* <pre>
* LDUser user = new LDUser.Builder("key")
* .country("US")
* .ip("192.168.0.1")
* .build()
* </pre>
* </p>
*
*/
public static class Builder {
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/com/launchdarkly/client/LDConfigTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.launchdarkly.client;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class LDConfigTest {
@Test
public void testConnectTimeoutSpecifiedInSeconds() {
LDConfig config = new LDConfig.Builder().connectTimeout(3).build();

assertEquals(3000, config.connectTimeout);
}

@Test
public void testConnectTimeoutSpecifiedInMilliseconds() {
LDConfig config = new LDConfig.Builder().connectTimeoutMillis(3000).build();

assertEquals(3000, config.connectTimeout);
}
@Test
public void testSocketTimeoutSpecifiedInSeconds() {
LDConfig config = new LDConfig.Builder().socketTimeout(3).build();

assertEquals(3000, config.socketTimeout);
}

@Test
public void testSocketTimeoutSpecifiedInMilliseconds() {
LDConfig config = new LDConfig.Builder().socketTimeoutMillis(3000).build();

assertEquals(3000, config.socketTimeout);
}
}

0 comments on commit 9f75f02

Please sign in to comment.