Skip to content

Commit

Permalink
Pass timeout to the socket transport, close #17 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
vykulakov committed Dec 25, 2019
1 parent 5849303 commit cf2e7f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

func main() {
// flume avro instance address
client, err := avroipc.NewClient("localhost:20200", 0, 1024, 6)
client, err := avroipc.NewClient("localhost:20200", 0, 0, 1024, 6)
if err != nil {
log.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type Client interface {
Close() error
Append(event *Event) (string, error)
AppendBatch(event []*Event) (string, error)
AppendBatch(events []*Event) (string, error)
}

type client struct {
Expand All @@ -22,8 +22,8 @@ type client struct {
}

// NewClient creates an avro Client, and connect to addr immediately
func NewClient(addr string, sendTimeout time.Duration, bufferSize, compressionLevel int) (Client, error) {
trans, err := NewSocket(addr)
func NewClient(addr string, timeout, sendTimeout time.Duration, bufferSize, compressionLevel int) (Client, error) {
trans, err := NewSocketTimeout(addr, timeout)
if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion ipc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ func TestSend(t *testing.T) {
}

bufferSize := 8

timeout := time.Duration(0)
sendTimeout := time.Duration(0)

// flume avro instance address
client, err := NewClient(addr, sendTimeout, bufferSize, levelInt)
client, err := NewClient(addr, timeout, sendTimeout, bufferSize, levelInt)
require.NoError(t, err)

event := &Event{
Expand Down

0 comments on commit cf2e7f1

Please sign in to comment.