From 0a7fb1bd510ed9517a5e5047ddaff9494dd80f6f Mon Sep 17 00:00:00 2001 From: nixargh Date: Tue, 7 Jun 2022 20:15:43 +0300 Subject: [PATCH] v2.2.0: - init as go module - remove 10 minutes deadline for incoming connection - add -version flag --- CHANGELOG.md | 12 +++++++++++- go.mod | 10 ++++++++++ go.sum | 12 ++++++++++++ main.go | 14 +++++++++++--- receiver.go | 5 ++--- 5 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/CHANGELOG.md b/CHANGELOG.md index 83fe5a6..0f51461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.2.0] - 2022-06-07 +### Changed +- Init as go module. + +### Removed +- `receiver.go` 10 minutes deadline for incoming connections. + +### Added +- `main.go` **-version** flag to show **Groxy** version. + ## [2.1.0] - 2022-01-30 ### Added - Mutual TLS support. -- New parameter **-forceTenant** that allows to revrite metric tenant if it is already set. +- New parameter **-forceTenant** that allows to rewrite metric tenant if it is already set. ## [2.0.1] - 2022-01-08 ### Fixed diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..90a911d --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/nixargh/groxy + +go 1.17 + +require ( + github.com/gorilla/mux v1.8.0 + github.com/sirupsen/logrus v1.8.1 +) + +require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..24777da --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index 227ce52..43edb23 100644 --- a/main.go +++ b/main.go @@ -2,15 +2,17 @@ package main import ( "flag" - log "github.com/sirupsen/logrus" + "fmt" "os" "strings" "sync/atomic" "time" + + log "github.com/sirupsen/logrus" // "github.com/pkg/profile" ) -var version string = "2.1.0" +var version string = "2.2.0" var clog, slog, rlog, tlog, stlog *log.Entry @@ -82,6 +84,7 @@ func main() { var hostname string var compressedOutput bool var compressedInput bool + var showVersion bool flag.StringVar(&instance, "instance", "default", "Groxy instance name (for log and metrics)") flag.StringVar(&tenant, "tenant", "", "Graphite project name to store metrics in") @@ -114,12 +117,18 @@ func main() { flag.StringVar(&systemTenant, "systemTenant", "", "Graphite project name to store SELF metrics in. By default is equal to 'tenant'") flag.StringVar(&systemPrefix, "systemPrefix", "", "Prefix to add to any SELF metric. By default is equal to 'prefix'") flag.StringVar(&hostname, "hostname", "", "Hostname of a computer running Groxy") + flag.BoolVar(&showVersion, "version", false, "Groxy version") flag.Parse() // Setup logging log.SetOutput(os.Stdout) + if showVersion { + fmt.Println(version) + os.Exit(1) + } + if jsonLog == true { log.SetFormatter(&log.JSONFormatter{}) } else { @@ -214,7 +223,6 @@ func main() { state.OutBpm = atomic.LoadInt64(&state.OutBytes) - out_bytes clog.WithFields(log.Fields{"state": state}).Info("Dumping state.") - sendStateMetrics(instance, hostname, systemTenant, systemPrefix, inputChan) } } diff --git a/receiver.go b/receiver.go index 07ce84b..f185d33 100644 --- a/receiver.go +++ b/receiver.go @@ -6,14 +6,14 @@ import ( "crypto/tls" "crypto/x509" "fmt" - log "github.com/sirupsen/logrus" "io" "io/ioutil" "net" "strconv" "strings" "sync/atomic" - "time" + + log "github.com/sirupsen/logrus" // "github.com/pkg/profile" ) @@ -104,7 +104,6 @@ func runReceiver( } func readMetric(connection net.Conn, inputChan chan *Metric, compress bool) { - connection.SetReadDeadline(time.Now().Add(600 * time.Second)) var uncompressedConn io.ReadCloser var err error