Skip to content

Commit 21e9bcf

Browse files
authored
Merge pull request #33 from robinst/add-close-method
Add close method to StatsDClient and extend Closeable
2 parents 3f6556c + 193a518 commit 21e9bcf

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/main/java/com/timgroup/statsd/NoOpStatsDClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
public final class NoOpStatsDClient implements StatsDClient {
1111
@Override public void stop() { }
12+
@Override public void close() { }
1213
@Override public void count(String aspect, long delta, String... tags) { }
1314
@Override public void count(String aspect, long delta, double sampleRate, String... tags) { }
1415
@Override public void incrementCounter(String aspect, String... tags) { }

src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ public void stop() {
345345
}
346346
}
347347

348+
@Override
349+
public void close() {
350+
stop();
351+
}
352+
348353
/**
349354
* Generate a suffix conveying the given tag list to the client
350355
*/

src/main/java/com/timgroup/statsd/StatsDClient.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.timgroup.statsd;
22

3+
import java.io.Closeable;
4+
35
/**
46
* Describes a client connection to a StatsD server, which may be used to post metrics
57
* in the form of counters, timers, and gauges.
@@ -15,14 +17,20 @@
1517
* @author Tom Denley
1618
*
1719
*/
18-
public interface StatsDClient {
20+
public interface StatsDClient extends Closeable {
1921

2022
/**
2123
* Cleanly shut down this StatsD client. This method may throw an exception if
2224
* the socket cannot be closed.
2325
*/
2426
void stop();
2527

28+
/**
29+
* @see #stop()
30+
*/
31+
@Override
32+
void close();
33+
2634
/**
2735
* Adjusts the specified counter by a given delta.
2836
*

0 commit comments

Comments
 (0)