Skip to content

Commit 9464283

Browse files
committed
separate test-client into its own mod file
test client is only intended for local development and testing, not as a go-installable, so remove it from the main go.mod hierarchy to reduce dependencies for upstream consumers. bump go.mod to min go to 1.13 (GO111MODULE where defaulted to auto) update to v6 for the min go version bump
1 parent 7ca8c68 commit 9464283

File tree

9 files changed

+46
-42
lines changed

9 files changed

+46
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/test-client/test-client

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
Changelog
22
=========
33

4-
## head
5-
* update dependency
4+
## 6.0.0 2025-09-07
5+
* move test-client to its own go.mod file, so as to trim dependencies
6+
for upstream consumers. test-client is intended for local testing
7+
and/or develment and not necesarily installable via go-install.
8+
* bump go.mod go version to 1.13, the version which GO111MODULE defaults to
9+
auto.
610

711
## 5.1.0 2023-07-19
812
* Fix for tag format in substatter. (GH-55)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Some examples:
2222
import (
2323
"log"
2424

25-
"github.com/cactus/go-statsd-client/v5/statsd"
25+
"github.com/cactus/go-statsd-client/v6/statsd"
2626
)
2727

2828
func main() {
@@ -109,7 +109,7 @@ or interrupt existing integrations.
109109
import (
110110
"log"
111111

112-
"github.com/cactus/go-statsd-client/v5/statsd"
112+
"github.com/cactus/go-statsd-client/v6/statsd"
113113
)
114114

115115
func main() {

go.mod

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
module github.com/cactus/go-statsd-client/v5
1+
module github.com/cactus/go-statsd-client/v6
22

3-
go 1.11
4-
5-
require (
6-
github.com/jessevdk/go-flags v1.6.1
7-
golang.org/x/sys v0.30.0 // indirect
8-
)
3+
go 1.13

go.sum

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
2-
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
3-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
4-
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
5-
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
6-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
7-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

statsd/statsdtest/recorder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/cactus/go-statsd-client/v5/statsd"
10+
"github.com/cactus/go-statsd-client/v6/statsd"
1111
)
1212

1313
func TestRecordingSenderIsSender(t *testing.T) {

test-client/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/cactus/go-statsd-client/test-client/v6
2+
3+
go 1.20
4+
5+
require github.com/alecthomas/kong v1.12.1
6+
7+
require github.com/cactus/go-statsd-client/v6 v6.0.0
8+
9+
replace github.com/cactus/go-statsd-client/v6 => ../

test-client/go.sum

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
2+
github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0=
3+
github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
4+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
5+
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=

test-client/main.go

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,31 @@ import (
1010
"os"
1111
"time"
1212

13-
"github.com/cactus/go-statsd-client/v5/statsd"
14-
flags "github.com/jessevdk/go-flags"
13+
"github.com/alecthomas/kong"
14+
"github.com/cactus/go-statsd-client/v6/statsd"
1515
)
1616

1717
func main() {
18-
1918
// command line flags
2019
var opts struct {
21-
HostPort string `long:"host" default:"127.0.0.1:8125" description:"host:port of statsd server"`
22-
Prefix string `long:"prefix" default:"test-client" description:"Statsd prefix"`
23-
StatType string `long:"type" default:"count" description:"stat type to send. Can be one of: timing, count, gauge"`
24-
StatValue int64 `long:"value" default:"1" description:"Value to send"`
25-
Name string `short:"n" long:"name" default:"counter" description:"stat name"`
26-
Rate float32 `short:"r" long:"rate" default:"1.0" description:"sample rate"`
27-
Volume int `short:"c" long:"count" default:"1000" description:"Number of stats to send. Volume."`
28-
Nil bool `long:"nil" description:"Use nil client"`
29-
Buffered bool `long:"buffered" description:"Use a buffered client"`
30-
Duration time.Duration `short:"d" long:"duration" default:"10s" description:"How long to spread the volume across. For each second of duration, volume/seconds events will be sent."`
20+
HostPort string `name:"host" default:"127.0.0.1:8125" help:"host:port of statsd server"`
21+
Prefix string `name:"prefix" default:"test-client" help:"Statsd prefix"`
22+
StatType string `name:"type" enum:"timing,count,gauge" default:"count" help:"stat type to send. Can be one of: timing, count, gauge"`
23+
StatValue int64 `name:"value" default:"1" help:"Value to send"`
24+
Name string `name:"name" short:"n" default:"counter" help:"stat name"`
25+
Rate float32 `name:"rate" short:"r" default:"1.0" help:"sample rate"`
26+
Volume int `name:"count" short:"c" default:"1000" help:"Number of stats to send. Volume."`
27+
Nil bool `name:"nil" help:"Use nil client"`
28+
Buffered bool `name:"buffered" help:"Use a buffered client"`
29+
Duration time.Duration `name:"duration" short:"d" default:"10s" help:"How long to spread the volume across. For each second of duration, volume/seconds events will be sent."`
3130
}
3231

3332
// parse said flags
34-
_, err := flags.Parse(&opts)
35-
if err != nil {
36-
if e, ok := err.(*flags.Error); ok {
37-
if e.Type == flags.ErrHelp {
38-
os.Exit(0)
39-
}
40-
}
41-
fmt.Printf("Error: %+v\n", err)
42-
os.Exit(1)
43-
}
33+
kong.Parse(&opts,
34+
kong.Name("test-client"),
35+
kong.UsageOnError(),
36+
)
37+
fmt.Printf("%+v\n", opts)
4438

4539
if opts.Nil && opts.Buffered {
4640
fmt.Printf("Specifying both nil and buffered together is invalid\n")
@@ -64,6 +58,7 @@ func main() {
6458
}
6559

6660
var client statsd.Statter = (*statsd.Client)(nil)
61+
var err error
6762
if !opts.Nil {
6863
if opts.Buffered {
6964
config.UseBuffered = true
@@ -96,6 +91,8 @@ func main() {
9691
log.Fatal("Unsupported state type")
9792
}
9893

94+
log.Printf("sending to %s\n", opts.HostPort)
95+
9996
pertick := opts.Volume / int(opts.Duration.Seconds()) / 10
10097
// add some extra time, because the first tick takes a while
10198
ender := time.After(opts.Duration + 100*time.Millisecond)

0 commit comments

Comments
 (0)