| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package butler | 5 package butler |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| 11 "sort" | 11 "sort" |
| 12 "sync" | 12 "sync" |
| 13 "time" | 13 "time" |
| 14 | 14 |
| 15 "github.com/luci/luci-go/common/clock" | 15 "github.com/luci/luci-go/common/clock" |
| 16 "github.com/luci/luci-go/common/config" | |
| 17 "github.com/luci/luci-go/common/data/stringset" | 16 "github.com/luci/luci-go/common/data/stringset" |
| 18 "github.com/luci/luci-go/common/iotools" | 17 "github.com/luci/luci-go/common/iotools" |
| 19 log "github.com/luci/luci-go/common/logging" | 18 log "github.com/luci/luci-go/common/logging" |
| 20 "github.com/luci/luci-go/common/proto/google" | 19 "github.com/luci/luci-go/common/proto/google" |
| 21 "github.com/luci/luci-go/common/runtime/paniccatcher" | 20 "github.com/luci/luci-go/common/runtime/paniccatcher" |
| 22 "github.com/luci/luci-go/common/sync/parallel" | 21 "github.com/luci/luci-go/common/sync/parallel" |
| 23 "github.com/luci/luci-go/logdog/client/butler/bundler" | 22 "github.com/luci/luci-go/logdog/client/butler/bundler" |
| 24 "github.com/luci/luci-go/logdog/client/butler/output" | 23 "github.com/luci/luci-go/logdog/client/butler/output" |
| 25 "github.com/luci/luci-go/logdog/client/butler/streamserver" | 24 "github.com/luci/luci-go/logdog/client/butler/streamserver" |
| 26 "github.com/luci/luci-go/logdog/client/butlerlib/streamproto" | 25 "github.com/luci/luci-go/logdog/client/butlerlib/streamproto" |
| 27 "github.com/luci/luci-go/logdog/common/types" | 26 "github.com/luci/luci-go/logdog/common/types" |
| 27 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 28 | 28 |
| 29 "golang.org/x/net/context" | 29 "golang.org/x/net/context" |
| 30 ) | 30 ) |
| 31 | 31 |
| 32 const ( | 32 const ( |
| 33 // DefaultMaxBufferAge is the default amount of time that a log entry ma
y | 33 // DefaultMaxBufferAge is the default amount of time that a log entry ma
y |
| 34 // be buffered before being dispatched. | 34 // be buffered before being dispatched. |
| 35 DefaultMaxBufferAge = time.Duration(5 * time.Second) | 35 DefaultMaxBufferAge = time.Duration(5 * time.Second) |
| 36 | 36 |
| 37 // DefaultOutputWorkers is the default number of output workers to use. | 37 // DefaultOutputWorkers is the default number of output workers to use. |
| 38 DefaultOutputWorkers = 16 | 38 DefaultOutputWorkers = 16 |
| 39 | 39 |
| 40 // streamBufferSize is the maximum amount of stream data to buffer in me
mory. | 40 // streamBufferSize is the maximum amount of stream data to buffer in me
mory. |
| 41 streamBufferSize = 1024 * 1024 * 5 | 41 streamBufferSize = 1024 * 1024 * 5 |
| 42 | 42 |
| 43 // keepAliveChannelSize is the size of the I/O keep-alive channel buffer
. | 43 // keepAliveChannelSize is the size of the I/O keep-alive channel buffer
. |
| 44 keepAliveChannelSize = 128 | 44 keepAliveChannelSize = 128 |
| 45 ) | 45 ) |
| 46 | 46 |
| 47 // Config is the set of Butler configuration parameters. | 47 // Config is the set of Butler configuration parameters. |
| 48 type Config struct { | 48 type Config struct { |
| 49 // Output is the output instance to use for log dispatch. | 49 // Output is the output instance to use for log dispatch. |
| 50 Output output.Output | 50 Output output.Output |
| 51 // OutputWorkers is the number of simultaneous goroutines that will be u
sed | 51 // OutputWorkers is the number of simultaneous goroutines that will be u
sed |
| 52 // to output Butler log data. If zero, DefaultOutputWorkers will be used
. | 52 // to output Butler log data. If zero, DefaultOutputWorkers will be used
. |
| 53 OutputWorkers int | 53 OutputWorkers int |
| 54 | 54 |
| 55 // Project is the project that the log stream will be bound to. | 55 // Project is the project that the log stream will be bound to. |
| 56 » Project config.ProjectName | 56 » Project cfgtypes.ProjectName |
| 57 // Prefix is the log stream common prefix value. | 57 // Prefix is the log stream common prefix value. |
| 58 Prefix types.StreamName | 58 Prefix types.StreamName |
| 59 | 59 |
| 60 // GlobalTags are a set of global log stream tags to apply to individual | 60 // GlobalTags are a set of global log stream tags to apply to individual |
| 61 // streams on registration. Individual stream tags will override tags wi
th | 61 // streams on registration. Individual stream tags will override tags wi
th |
| 62 // the same key. | 62 // the same key. |
| 63 GlobalTags streamproto.TagMap | 63 GlobalTags streamproto.TagMap |
| 64 | 64 |
| 65 // BufferLogs, if true, instructs the butler to buffer collected log dat
a | 65 // BufferLogs, if true, instructs the butler to buffer collected log dat
a |
| 66 // before sending it to Output. | 66 // before sending it to Output. |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 // shutdown prematurely, so this should be reasonably quick. | 662 // shutdown prematurely, so this should be reasonably quick. |
| 663 b.Activate() | 663 b.Activate() |
| 664 } | 664 } |
| 665 | 665 |
| 666 // Returns the configured Butler error. | 666 // Returns the configured Butler error. |
| 667 func (b *Butler) getRunErr() error { | 667 func (b *Butler) getRunErr() error { |
| 668 b.shutdownMu.Lock() | 668 b.shutdownMu.Lock() |
| 669 defer b.shutdownMu.Unlock() | 669 defer b.shutdownMu.Unlock() |
| 670 return b.runErr | 670 return b.runErr |
| 671 } | 671 } |
| OLD | NEW |