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

TCP input timeouts #318

Merged
merged 13 commits into from
Oct 23, 2018
93 changes: 14 additions & 79 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions cfg/cfg.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package cfg

import (
"time"

"github.com/graphite-ng/carbon-relay-ng/validate"
m20 "github.com/metrics20/go-metrics20/carbon20"
)

type Config struct {
Listen_addr string
Plain_read_timeout Duration
Pickle_addr string
Pickle_read_timeout Duration
Admin_addr string
Http_addr string
Spool_dir string
Expand All @@ -28,6 +33,29 @@ type Config struct {
Rewriter []Rewriter
}

func NewConfig() Config {
return Config{
Plain_read_timeout: Duration{
2 * time.Minute,
},
Pickle_read_timeout: Duration{
2 * time.Minute,
},
Validation_level_legacy: validate.LevelLegacy{m20.MediumLegacy},
Validation_level_m20: validate.LevelM20{m20.MediumM20},
}
}

type Duration struct {
time.Duration
}

func (d *Duration) UnmarshalText(text []byte) error {
var err error
d.Duration, err = time.ParseDuration(string(text))
return err
}

type Aggregation struct {
Function string
Regex string
Expand Down
11 changes: 3 additions & 8 deletions cmd/carbon-relay-ng/carbon-relay-ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
tbl "github.com/graphite-ng/carbon-relay-ng/table"
"github.com/graphite-ng/carbon-relay-ng/ui/telnet"
"github.com/graphite-ng/carbon-relay-ng/ui/web"
m20 "github.com/metrics20/go-metrics20/carbon20"
log "github.com/sirupsen/logrus"

"strconv"
Expand All @@ -36,7 +35,7 @@ import (

var (
config_file string
config cfg.Config
config = cfg.NewConfig()
to_dispatch = make(chan []byte)
inputs []input.Plugin
shutdownTimeout = time.Second * 30 // how long to wait for shutdown
Expand All @@ -63,10 +62,6 @@ func main() {
runtime.SetBlockProfileRate(*blockProfileRate)
runtime.MemProfileRate = *memProfileRate

// validation defaults
config.Validation_level_legacy.Level = m20.MediumLegacy
config.Validation_level_m20.Level = m20.MediumM20

config_file = "/etc/carbon-relay-ng.ini"
if 1 == flag.NArg() {
val := flag.Arg(0)
Expand Down Expand Up @@ -168,11 +163,11 @@ func main() {
}

if config.Listen_addr != "" {
inputs = append(inputs, input.NewPlain(config.Listen_addr, table))
inputs = append(inputs, input.NewPlain(config.Listen_addr, config.Plain_read_timeout.Duration, table))
}

if config.Pickle_addr != "" {
inputs = append(inputs, input.NewPickle(config.Pickle_addr, table))
inputs = append(inputs, input.NewPickle(config.Pickle_addr, config.Pickle_read_timeout.Duration, table))
}

if config.Amqp.Amqp_enabled == true {
Expand Down
4 changes: 2 additions & 2 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# log level description

* trace: for tracing messages from start to finish, including unroutable/discards [1]
* debug: state changes that we only need to know when debugging [1]
* info: harmless, but interesting not-so-common events. e.g. connection changes, manually triggered flushes, etc. (this used to be `notice`)
* debug: state changes that we only need to know when debugging, client conns opening and closing [1]
* info: harmless, but interesting not-so-common events. e.g. outbound connection changes, manually triggered flushes, etc. (this used to be `notice`)
* warn: minor issues (network timeouts etc)
* error: recoverable errors
* fatal: errors and problems that result in shutdown
Expand Down
4 changes: 4 additions & 0 deletions examples/carbon-relay-ng.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ blacklist = [

### plaintext Carbon ###
listen_addr = "0.0.0.0:2003"
# close inbound plaintext connections if they've been idle for this long ("0s" to disable)
plain_read_timeout = "2m"

### Pickle Carbon ###
pickle_addr = "0.0.0.0:2013"
# close inbound pickle connections if they've been idle for this long ("0s" to disable)
pickle_read_timeout = "2m"

### AMQP ###
[amqp]
Expand Down
File renamed without changes.
Loading