Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass timeout to the socket transport, close #17 #18

Merged
merged 1 commit into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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