1
0
Fork 0
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:
Pierre Carrier 2016-01-19 00:07:13 -08:00
parent d89dae6e4b
commit 9c2a0739fb
3 changed files with 37 additions and 14 deletions

View file

@ -71,7 +71,7 @@ clone git github.com/golang/protobuf 68415e7123da32b07eab49c96d2c4d6158360e9b
# gelf logging driver deps # gelf logging driver deps
clone git github.com/Graylog2/go-gelf aab2f594e4585d43468ac57287b0dece9d806883 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 # fluent-logger-golang deps
clone git github.com/philhofer/fwd 899e4efba8eaa1fea74175308f3fae18ff3319fa clone git github.com/philhofer/fwd 899e4efba8eaa1fea74175308f3fae18ff3319fa
clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c

View file

@ -14,6 +14,8 @@ import (
const ( const (
defaultHost = "127.0.0.1" defaultHost = "127.0.0.1"
defaultNetwork = "tcp"
defaultSocketPath = ""
defaultPort = 24224 defaultPort = 24224
defaultTimeout = 3 * time.Second defaultTimeout = 3 * time.Second
defaultBufferLimit = 8 * 1024 * 1024 defaultBufferLimit = 8 * 1024 * 1024
@ -25,11 +27,14 @@ const (
type Config struct { type Config struct {
FluentPort int FluentPort int
FluentHost string FluentHost string
FluentNetwork string
FluentSocketPath string
Timeout time.Duration Timeout time.Duration
BufferLimit int BufferLimit int
RetryWait int RetryWait int
MaxRetry int MaxRetry int
TagPrefix string TagPrefix string
AsyncConnect bool
} }
type Fluent struct { type Fluent struct {
@ -42,12 +47,18 @@ type Fluent struct {
// New creates a new Logger. // New creates a new Logger.
func New(config Config) (f *Fluent, err error) { func New(config Config) (f *Fluent, err error) {
if config.FluentNetwork == "" {
config.FluentNetwork = defaultNetwork
}
if config.FluentHost == "" { if config.FluentHost == "" {
config.FluentHost = defaultHost config.FluentHost = defaultHost
} }
if config.FluentPort == 0 { if config.FluentPort == 0 {
config.FluentPort = defaultPort config.FluentPort = defaultPort
} }
if config.FluentSocketPath == "" {
config.FluentSocketPath = defaultSocketPath
}
if config.Timeout == 0 { if config.Timeout == 0 {
config.Timeout = defaultTimeout config.Timeout = defaultTimeout
} }
@ -60,8 +71,13 @@ func New(config Config) (f *Fluent, err error) {
if config.MaxRetry == 0 { if config.MaxRetry == 0 {
config.MaxRetry = defaultMaxRetry config.MaxRetry = defaultMaxRetry
} }
if config.AsyncConnect {
f = &Fluent{Config: config, reconnecting: true}
f.reconnect()
} else {
f = &Fluent{Config: config, reconnecting: false} f = &Fluent{Config: config, reconnecting: false}
err = f.connect() err = f.connect()
}
return return
} }
@ -171,9 +187,9 @@ func (f *Fluent) EncodeData(tag string, tm time.Time, message interface{}) (data
// Close closes the connection. // Close closes the connection.
func (f *Fluent) Close() (err error) { func (f *Fluent) Close() (err error) {
if len(f.pending) > 0 { if len(f.pending) > 0 {
_ = f.send() err = f.send()
} }
err = f.close() f.close()
return return
} }
@ -194,7 +210,14 @@ func (f *Fluent) close() (err error) {
// connect establishes a new connection using the specified transport. // connect establishes a new connection using the specified transport.
func (f *Fluent) connect() (err error) { 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 return
} }

View file

@ -1,3 +1,3 @@
package fluent package fluent
const Version = "1.0.0" const Version = "1.1.0"