Skip to content

Commit

Permalink
fix rebase shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
kang-makes committed Nov 21, 2023
1 parent 331323e commit 51be5d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *StatsD) connect() error {
}
case "tcp":
var err error
s.Conn, err = net.Dial("tcp", s.address)
s.conn, err = net.Dial(s.transport, s.address)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions receiver/statsdreceiver/internal/transport/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ func Test_Server_ListenAndServe(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
trans := Transport(tt.name)
addr := tt.getFreeEndpointFn(t, tt.name)
testFreeEndpoint(t, tt.name, addr)

srv, err := tt.buildServerFn(trans, addr)
srv, err := tt.buildServerFn(tt.transport, addr)
require.NoError(t, err)
require.NotNil(t, srv)

Expand All @@ -67,7 +66,7 @@ func Test_Server_ListenAndServe(t *testing.T) {

runtime.Gosched()

gc, err := tt.buildClientFn(tt.name, addr)
gc, err := tt.buildClientFn(tt.transport.String(), addr)
require.NoError(t, err)
require.NotNil(t, gc)
err = gc.SendMetric(client.Metric{
Expand Down
4 changes: 4 additions & 0 deletions receiver/statsdreceiver/internal/transport/tcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type tcpServer struct {
stopChan chan struct{}
}

// Ensure that Server is implemented on TCP Server.
var _ Server = (*tcpServer)(nil)

// NewTCPServer creates a transport.Server using TCP as its transport.
Expand All @@ -46,6 +47,7 @@ func NewTCPServer(transport Transport, address string) (Server, error) {
return &tsrv, nil
}

// ListenAndServe starts the server ready to receive metrics.
func (t *tcpServer) ListenAndServe(nextConsumer consumer.Metrics, reporter Reporter, transferChan chan<- Metric) error {
if nextConsumer == nil || reporter == nil {
return errNilListenAndServeParameters
Expand Down Expand Up @@ -76,6 +78,7 @@ LOOP:
return errTCPServerDone
}

// handleConn is helper that parses the buffer and split it line by line to be parsed upstream.
func (t *tcpServer) handleConn(c net.Conn, transferChan chan<- Metric) {
payload := make([]byte, 4096)
var remainder []byte
Expand Down Expand Up @@ -103,6 +106,7 @@ func (t *tcpServer) handleConn(c net.Conn, transferChan chan<- Metric) {
}
}

// Close closes the server.
func (t *tcpServer) Close() error {
close(t.stopChan)
t.wg.Wait()
Expand Down

0 comments on commit 51be5d3

Please sign in to comment.