mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
bump fluent-logger-golang version
This version supports async connections. Signed-off-by: Pierre Carrier <pierre@meteor.com>
This commit is contained in:
parent
d89dae6e4b
commit
9c2a0739fb
3 changed files with 37 additions and 14 deletions
|
@ -71,7 +71,7 @@ clone git github.com/golang/protobuf 68415e7123da32b07eab49c96d2c4d6158360e9b
|
|||
# gelf logging driver deps
|
||||
clone git github.com/Graylog2/go-gelf aab2f594e4585d43468ac57287b0dece9d806883
|
||||
|
||||
clone git github.com/fluent/fluent-logger-golang v1.0.0
|
||||
clone git github.com/fluent/fluent-logger-golang v1.1.0
|
||||
# fluent-logger-golang deps
|
||||
clone git github.com/philhofer/fwd 899e4efba8eaa1fea74175308f3fae18ff3319fa
|
||||
clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c
|
||||
|
|
|
@ -14,6 +14,8 @@ import (
|
|||
|
||||
const (
|
||||
defaultHost = "127.0.0.1"
|
||||
defaultNetwork = "tcp"
|
||||
defaultSocketPath = ""
|
||||
defaultPort = 24224
|
||||
defaultTimeout = 3 * time.Second
|
||||
defaultBufferLimit = 8 * 1024 * 1024
|
||||
|
@ -25,11 +27,14 @@ const (
|
|||
type Config struct {
|
||||
FluentPort int
|
||||
FluentHost string
|
||||
FluentNetwork string
|
||||
FluentSocketPath string
|
||||
Timeout time.Duration
|
||||
BufferLimit int
|
||||
RetryWait int
|
||||
MaxRetry int
|
||||
TagPrefix string
|
||||
AsyncConnect bool
|
||||
}
|
||||
|
||||
type Fluent struct {
|
||||
|
@ -42,12 +47,18 @@ type Fluent struct {
|
|||
|
||||
// New creates a new Logger.
|
||||
func New(config Config) (f *Fluent, err error) {
|
||||
if config.FluentNetwork == "" {
|
||||
config.FluentNetwork = defaultNetwork
|
||||
}
|
||||
if config.FluentHost == "" {
|
||||
config.FluentHost = defaultHost
|
||||
}
|
||||
if config.FluentPort == 0 {
|
||||
config.FluentPort = defaultPort
|
||||
}
|
||||
if config.FluentSocketPath == "" {
|
||||
config.FluentSocketPath = defaultSocketPath
|
||||
}
|
||||
if config.Timeout == 0 {
|
||||
config.Timeout = defaultTimeout
|
||||
}
|
||||
|
@ -60,8 +71,13 @@ func New(config Config) (f *Fluent, err error) {
|
|||
if config.MaxRetry == 0 {
|
||||
config.MaxRetry = defaultMaxRetry
|
||||
}
|
||||
if config.AsyncConnect {
|
||||
f = &Fluent{Config: config, reconnecting: true}
|
||||
f.reconnect()
|
||||
} else {
|
||||
f = &Fluent{Config: config, reconnecting: false}
|
||||
err = f.connect()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -171,9 +187,9 @@ func (f *Fluent) EncodeData(tag string, tm time.Time, message interface{}) (data
|
|||
// Close closes the connection.
|
||||
func (f *Fluent) Close() (err error) {
|
||||
if len(f.pending) > 0 {
|
||||
_ = f.send()
|
||||
err = f.send()
|
||||
}
|
||||
err = f.close()
|
||||
f.close()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -194,7 +210,14 @@ func (f *Fluent) close() (err error) {
|
|||
|
||||
// connect establishes a new connection using the specified transport.
|
||||
func (f *Fluent) connect() (err error) {
|
||||
f.conn, err = net.DialTimeout("tcp", f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout)
|
||||
switch f.Config.FluentNetwork {
|
||||
case "tcp":
|
||||
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout)
|
||||
case "unix":
|
||||
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentSocketPath, f.Config.Timeout)
|
||||
default:
|
||||
err = net.UnknownNetworkError(f.Config.FluentNetwork)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package fluent
|
||||
|
||||
const Version = "1.0.0"
|
||||
const Version = "1.1.0"
|
||||
|
|
Loading…
Reference in a new issue