Skip to content

Commit

Permalink
Fix Windows compatibility for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer04 authored and hush-hush committed Nov 29, 2021
1 parent 8bd4f00 commit 8cf6183
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions statsd/pipe_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ func TestPipeWriterReconnect(t *testing.T) {

out := make(chan string)
go acceptOne(t, ln, out)

client, err := New(pipepath)
require.Nil(t, err)

// first attempt works, then connection closes
err = client.Gauge("metric", 1, []string{"key:val"}, 1)
require.Nil(t, err, "Failed to send gauge: %s", err)

timeout := time.After(1 * time.Second)
timeout := time.After(5 * time.Second)
select {
case got := <-out:
assert.Equal(t, got, "metric:1|g|#key:val\n")
Expand All @@ -120,7 +121,7 @@ func TestPipeWriterReconnect(t *testing.T) {
err = client.Gauge("metric", 3, []string{"key:val"}, 1)
require.Nil(t, err, "Failed to send second gauge: %s", err)

timeout = time.After(500 * time.Millisecond)
timeout = time.After(3 * time.Second)
select {
case got := <-out:
assert.Equal(t, got, "metric:3|g|#key:val\n")
Expand Down
12 changes: 8 additions & 4 deletions statsd/uds_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

package statsd

import "fmt"
import (
"fmt"
"io"
"time"
)

// newUDSWriter is disable on windows as unix sockets are not available
func newUDSWriter(addr string) (io.WriteCloser, error) {
return nil, fmt.Errorf("unix socket is not available on windows")
// newUDSWriter is disabled on Windows as Unix sockets are not available.
func newUDSWriter(_ string, _ time.Duration) (io.WriteCloser, error) {
return nil, fmt.Errorf("Unix socket is not available on Windows")
}

0 comments on commit 8cf6183

Please sign in to comment.