func newLumberjackClient( conn *transport.Client, compressLevel int, maxWindowSize int, timeout time.Duration, beat string, ) (*client, error) { c := &client{} c.Client = conn c.win.init(defaultStartMaxWindowSize, maxWindowSize) enc, err := makeLogstashEventEncoder(beat) if err != nil { return nil, err } cl, err := v2.NewSyncClientWithConn(conn, v2.JSONEncoder(enc), v2.Timeout(timeout), v2.CompressionLevel(compressLevel)) if err != nil { return nil, err } c.client = cl return c, nil }
func newAsyncLumberjackClient( conn *transport.Client, queueSize int, compressLevel int, maxWindowSize int, timeout time.Duration, beat string, ) (*asyncClient, error) { c := &asyncClient{} c.Client = conn c.win.init(defaultStartMaxWindowSize, maxWindowSize) enc, err := makeLogstashEventEncoder(beat) if err != nil { return nil, err } c.connect = func() error { err := c.Client.Connect() if err == nil { c.client, err = v2.NewAsyncClientWithConn(c.Client, queueSize, v2.JSONEncoder(enc), v2.Timeout(timeout), v2.CompressionLevel(compressLevel)) } return err } return c, nil }