diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42e3f62 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.testCoverage.txt diff --git a/database/main.go b/database/main.go index fa1c4b7..5f7f4b2 100644 --- a/database/main.go +++ b/database/main.go @@ -1,80 +1,49 @@ -// Package database provides the functionality to open, close and use a database package database import ( + gormigrate "github.com/go-gormigrate/gormigrate/v2" + "gorm.io/driver/postgres" "gorm.io/gorm" - // load gorm defaults driver - _ "gorm.io/driver/mysql" - _ "gorm.io/driver/postgres" - _ "gorm.io/driver/sqlite" - - "github.com/bdlm/log" + "gorm.io/gorm/logger" ) -// Write Database connection for writing purposes -var Write *gorm.DB - -// Read Database connection for reading purposes -var Read *gorm.DB - -// Configuration files -var ( - config *Config - runtime []interface{} -) - -// Config of the database connection -type Config struct { - // type of the database, currently supports sqlite and postgres - Type string - // connection configuration - Connection string - // create another connection for reading only - ReadConnection string - // enable logging of the generated sql string - Logging bool +type Database struct { + DB *gorm.DB + Connection string `toml:"connection"` + Debug bool `toml:"debug"` + Testdata bool `toml:"testdata"` + LogLevel logger.LogLevel `toml:"log_level"` + migrations map[string]*gormigrate.Migration + migrationTestdata map[string]*gormigrate.Migration } -// Open database and set the given configuration -func Open(c Config) (err error) { - writeLog := log.WithField("db", "write") - config = &c - Write, err = gorm.Open(config.Type, config.Connection) +func (config *Database) Run() error { + db, err := gorm.Open(postgres.Open(config.Connection), &gorm.Config{ + Logger: logger.Default.LogMode(config.LogLevel), + }) if err != nil { - return + return err } - Write.SingularTable(true) - Write.LogMode(c.Logging) - Write.SetLogger(writeLog) - Write.Callback().Create().Remove("gorm:update_time_stamp") - Write.Callback().Update().Remove("gorm:update_time_stamp") - if len(config.ReadConnection) > 0 { - readLog := log.WithField("db", "read") - Read, err = gorm.Open(config.Type, config.ReadConnection) - if err != nil { - return - } - Read.SingularTable(true) - Read.LogMode(c.Logging) - Read.SetLogger(readLog) - Read.Callback().Create().Remove("gorm:update_time_stamp") - Read.Callback().Update().Remove("gorm:update_time_stamp") - } else { - Read = Write + db.Debug().Exec("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";") + if config.Debug { + db = db.Debug() } - Write.AutoMigrate(runtime...) - return + + config.DB = db + if err = config.migrate(config.Testdata); err != nil { + return err + } + return nil } -// Close connnection to database safely -func Close() { - Write.Close() - if len(config.ReadConnection) > 0 { - Read.Close() - } -} +func (config *Database) Status() error { + sqlDB, err := config.DB.DB() + if err != nil { + return err -// AddModel to the runtime -func AddModel(m interface{}) { - runtime = append(runtime, m) + } + if err = sqlDB.Ping(); err != nil { + return err + } + return nil } diff --git a/database/main_test.go b/database/main_test.go index e9ae1bb..636bab8 100644 --- a/database/main_test.go +++ b/database/main_test.go @@ -1,84 +1 @@ -// Package that provides the functionality to open, close and use a database package database - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -type TestModel struct { - ID int64 - Value string `gorm:"type:varchar(255);column:value" json:"value"` -} - -// Function to test the error handling for the database opening -func TestOpenNoDB(t *testing.T) { - assert := assert.New(t) - - c := Config{} - - err := Open(c) - assert.Error(err, "error") -} - -// Function to test the opening of one database -func TestOpenOneDB(t *testing.T) { - assert := assert.New(t) - AddModel(&TestModel{}) - - c := Config{ - Type: "sqlite3", - Logging: true, - Connection: "file:database?mode=memory", - } - var count int64 - - err := Open(c) - assert.NoError(err, "no error") - - Write.Create(&TestModel{Value: "first"}) - Write.Create(&TestModel{Value: "secound"}) - - var list []*TestModel - Read.Find(&list).Count(&count) - assert.Equal(int64(2), count, "not enought entries") - Close() -} - -// Function to test the opening of a second database -func TestOpenTwoDB(t *testing.T) { - assert := assert.New(t) - AddModel(&TestModel{}) - c := Config{ - Type: "sqlite3", - Logging: true, - Connection: "file:database?mode=memory", - ReadConnection: "file/", - } - - err := Open(c) - assert.Error(err, "no error found") - - c = Config{ - Type: "sqlite3", - Logging: true, - Connection: "file:database?mode=memory", - ReadConnection: "file:database2?mode=memory", - } - var count int64 - - err = Open(c) - assert.NoError(err, "no error") - - Write.Create(&TestModel{Value: "first"}) - Write.Create(&TestModel{Value: "secound"}) - - var list []*TestModel - Write.Find(&list).Count(&count) - assert.Equal(int64(2), count, "not enought entries") - - result := Read.Find(&list) - assert.Error(result.Error, "error, because it is the wrong database") - Close() -} diff --git a/database/migration.go b/database/migration.go new file mode 100644 index 0000000..87079e8 --- /dev/null +++ b/database/migration.go @@ -0,0 +1,96 @@ +package database + +import ( + "errors" + "sort" + + "github.com/bdlm/log" + gormigrate "github.com/go-gormigrate/gormigrate/v2" +) + +var ( + ErrNothingToMigrate = errors.New("there is nothing to migrate") +) + +func (config *Database) sortedMigration(testdata bool) []*gormigrate.Migration { + var migrations []*gormigrate.Migration + for _, v := range config.migrations { + migrations = append(migrations, v) + } + if testdata { + for _, v := range config.migrationTestdata { + migrations = append(migrations, v) + } + } + sort.SliceStable(migrations, func(i, j int) bool { + return migrations[i].ID < migrations[j].ID + }) + return migrations +} + +func (config *Database) Migrate() error { + return config.migrate(false) +} +func (config *Database) MigrateTestdata() error { + return config.migrate(true) +} +func (config *Database) migrate(testdata bool) error { + migrations := config.sortedMigration(testdata) + if len(migrations) == 0 { + return ErrNothingToMigrate + } + + m := gormigrate.New(config.DB, gormigrate.DefaultOptions, migrations) + + return m.Migrate() +} + +func (config *Database) AddMigration(m ...*gormigrate.Migration) { + config.addMigrate(false, m...) +} +func (config *Database) AddMigrationTestdata(m ...*gormigrate.Migration) { + config.addMigrate(true, m...) +} +func (config *Database) addMigrate(testdata bool, m ...*gormigrate.Migration) { + if config.migrations == nil { + config.migrations = make(map[string]*gormigrate.Migration) + } + if config.migrationTestdata == nil { + config.migrationTestdata = make(map[string]*gormigrate.Migration) + } + + for _, i := range m { + if testdata { + config.migrations[i.ID] = i + } else { + config.migrationTestdata[i.ID] = i + } + } +} + +func (config *Database) ReRun(id string) { + migrations := config.sortedMigration(true) + x := 0 + for _, m := range migrations { + if m.ID == id { + break + } + x = x + 1 + } + + for i := len(migrations) - 1; i >= x; i = i - 1 { + m := migrations[i] + log.Warnf("rollback %s", m.ID) + err := m.Rollback(config.DB) + if err != nil { + log.Errorf("rollback %s", err) + } + } + for _, m := range migrations { + log.Warnf("run %s", m.ID) + err := m.Migrate(config.DB) + if err != nil { + log.Errorf("run %s", err) + } + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3993bfc --- /dev/null +++ b/go.mod @@ -0,0 +1,24 @@ +module dev.sum7.eu/genofire/golang-lib + +go 1.16 + +require ( + github.com/BurntSushi/toml v0.3.1 + github.com/bdlm/log v0.1.20 + github.com/bdlm/std v1.0.1 // indirect + github.com/chenjiandongx/ginprom v0.0.0-20201217063207-fe11b7f55a35 + github.com/gin-contrib/sessions v0.0.3 + github.com/gin-contrib/static v0.0.1 + github.com/gin-gonic/autotls v0.0.3 + github.com/gin-gonic/gin v1.7.2 + github.com/go-gormigrate/gormigrate/v2 v2.0.0 + github.com/google/uuid v1.2.0 + github.com/prometheus/client_golang v1.10.0 + github.com/stretchr/testify v1.7.0 + golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a + golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba + gorm.io/driver/postgres v1.1.0 + gorm.io/gorm v1.21.10 + gorm.io/plugin/prometheus v0.0.0-20210507023802-dc84a49b85d1 + nhooyr.io/websocket v1.8.7 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..cb3f63d --- /dev/null +++ b/go.sum @@ -0,0 +1,649 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/bdlm/log v0.1.20 h1:fSxBuBSHz+DkxPSFlaVcPiep20mCYUJZ5azUynkjhfA= +github.com/bdlm/log v0.1.20/go.mod h1:30V5Zwc5Vt5ePq5rd9KJ6JQ/A5aFUcKzq5fYtO7c9qc= +github.com/bdlm/std v1.0.1 h1:USdxays+0tgB3BJCEQ9z942tmTWmzpVPC7jCvczsj/I= +github.com/bdlm/std v1.0.1/go.mod h1:dittT3gnvbHQ4P+1UbkdSwkHFHVl1gx8qYu4zIFyB+Q= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff/go.mod h1:+RTT1BOk5P97fT2CiHkbFQwkK3mjsFAP6zCYV2aXtjw= +github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= +github.com/bradleypeabody/gorilla-sessions-memcache v0.0.0-20181103040241-659414f458e1/go.mod h1:dkChI7Tbtx7H1Tj7TqGSZMOeGpMP5gLHtjroHd4agiI= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenjiandongx/ginprom v0.0.0-20201217063207-fe11b7f55a35 h1:Vh3xwuCA2dUtIOSZyLFZmbQAcGWTut/dqaikEfnIM7E= +github.com/chenjiandongx/ginprom v0.0.0-20201217063207-fe11b7f55a35/go.mod h1:lINNCb1ZH3c0uL/9ApaQ8muR4QILsi0STj8Ojt8ZmwU= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg= +github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sessions v0.0.3 h1:PoBXki+44XdJdlgDqDrY5nDVe3Wk7wDV/UCOuLP6fBI= +github.com/gin-contrib/sessions v0.0.3/go.mod h1:8C/J6cad3Il1mWYYgtw0w+hqasmpvy25mPkXdOgeB9I= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-contrib/static v0.0.1 h1:JVxuvHPuUfkoul12N7dtQw7KRn/pSMq7Ue1Va9Swm1U= +github.com/gin-contrib/static v0.0.1/go.mod h1:CSxeF+wep05e0kCOsqWdAWbSszmc31zTIbD8TvWl7Hs= +github.com/gin-gonic/autotls v0.0.3 h1:/kVAtMOz7qmohg93VMTb0SqB0g7wQm6ujPS8BsNeDC8= +github.com/gin-gonic/autotls v0.0.3/go.mod h1:GThKJ63OxN5tZl+YkxOVVaqm9qYiwi8kk9z0dbSCe5M= +github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA= +github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-gormigrate/gormigrate/v2 v2.0.0 h1:e2A3Uznk4viUC4UuemuVgsNnvYZyOA8B3awlYk3UioU= +github.com/go-gormigrate/gormigrate/v2 v2.0.0/go.mod h1:YuVJ+D/dNt4HWrThTBnjgZuRbt7AuwINeg4q52ZE3Jw= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= +github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= +github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= +github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/gorilla/sessions v1.1.1/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= +github.com/gorilla/sessions v1.1.3 h1:uXoZdcdA5XdXF3QzuSlheVRUvjl+1rKY7zBXL68L9RU= +github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk= +github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= +github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= +github.com/jackc/pgconn v1.6.4/go.mod h1:w2pne1C2tZgP+TvjqLpOigGzNqjBgQW9dUw/4Chex78= +github.com/jackc/pgconn v1.8.1 h1:ySBX7Q87vOMqKU2bbmKbUvtYhauDFclYbNDYIE1/h6s= +github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.0.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.0.6 h1:b1105ZGEMFe7aCvrT1Cca3VoVb4ZFMaFJLJcg/3zD+8= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0= +github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= +github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= +github.com/jackc/pgtype v1.4.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= +github.com/jackc/pgtype v1.7.0 h1:6f4kVsW01QftE38ufBYxKciO6gyioXSC0ABIRLcZrGs= +github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA= +github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= +github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= +github.com/jackc/pgx/v4 v4.8.1/go.mod h1:4HOLxrl8wToZJReD04/yB20GDwf4KBYETvlHciCnwW0= +github.com/jackc/pgx/v4 v4.11.0 h1:J86tSWd3Y7nKjwT/43xZBvpi04keQWx8gNC2YkdJhZI= +github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= +github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b/go.mod h1:g2nVr8KZVXJSS97Jo8pJ0jgq29P6H7dG0oplUA86MQw= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8= +github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= +github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= +github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.10.0 h1:/o0BDeWzLWXNZ+4q5gXltUvaMpJqckTa+jTNoB+z4cg= +github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.18.0 h1:WCVKW7aL6LEe1uryfI9dnEc2ZqNB1Fn0ok930v0iL1Y= +github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/quasoft/memstore v0.0.0-20180925164028-84a050167438/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc h1:jUIKcSPO9MoMJBbEoyE/RJoE8vz7Mb8AjvifMMwSyvY= +github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY= +golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.0.1 h1:omJoilUzyrAp0xNoio88lGJCroGdIOen9hq2A/+3ifw= +gorm.io/driver/mysql v1.0.1/go.mod h1:KtqSthtg55lFp3S5kUXqlGaelnWpKitn4k1xZTnoiPw= +gorm.io/driver/postgres v1.0.0/go.mod h1:wtMFcOzmuA5QigNsgEIb7O5lhvH1tHAF1RbWmLWV4to= +gorm.io/driver/postgres v1.1.0 h1:afBljg7PtJ5lA6YUWluV2+xovIPhS+YiInuL3kUjrbk= +gorm.io/driver/postgres v1.1.0/go.mod h1:hXQIwafeRjJvUm+OMxcFWyswJ/vevcpPLlGocwAwuqw= +gorm.io/driver/sqlite v1.1.1 h1:qtWqNAEUyi7gYSUAJXeiAMz0lUOdakZF5ia9Fqnp5G4= +gorm.io/driver/sqlite v1.1.1/go.mod h1:hm2olEcl8Tmsc6eZyxYSeznnsDaMqamBvEXLNtBg4cI= +gorm.io/driver/sqlserver v1.0.2 h1:FzxAlw0/7hntMzSiNfotpYCo9Lz8dqWQGdmCGqIiFGo= +gorm.io/driver/sqlserver v1.0.2/go.mod h1:gb0Y9QePGgqjzrVyTQUZeh9zkd5v0iz71cM1B4ZycEY= +gorm.io/gorm v1.9.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.20.0/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.21.9/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= +gorm.io/gorm v1.21.10 h1:kBGiBsaqOQ+8f6S2U6mvGFz6aWWyCeIiuaFcaBozp4M= +gorm.io/gorm v1.21.10/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= +gorm.io/plugin/prometheus v0.0.0-20210507023802-dc84a49b85d1 h1:57jZSDGkCbdiUIR+RtGYGFu3dwLPzLfD3Evu8X2iZlo= +gorm.io/plugin/prometheus v0.0.0-20210507023802-dc84a49b85d1/go.mod h1:NUWDZYJguGM83quFGTS8kj1a1bCTgxkx4+CJkF6xKhs= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= +nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/http/io.go b/http/io.go deleted file mode 100644 index bf73670..0000000 --- a/http/io.go +++ /dev/null @@ -1,30 +0,0 @@ -// Package http provides the logic of the webserver -package http - -import ( - "encoding/json" - "errors" - "net/http" - "strings" -) - -// Read data from a http request via json format (input) -func Read(r *http.Request, to interface{}) (err error) { - if !strings.Contains(r.Header.Get("Content-Type"), "application/json") { - err = errors.New("no json request received") - return - } - err = json.NewDecoder(r.Body).Decode(to) - return -} - -// Write data as json to a http response (output) -func Write(w http.ResponseWriter, data interface{}) { - js, err := json.Marshal(data) - if err != nil { - http.Error(w, "failed to encode response: "+err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - w.Write(js) -} diff --git a/http/io_test.go b/http/io_test.go deleted file mode 100644 index e0811d5..0000000 --- a/http/io_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// Package that provides the logic of the webserver -package http - -import ( - "bytes" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/stretchr/testify/assert" -) - -// Function to test write() -func TestWrite(t *testing.T) { - assert := assert.New(t) - - w := httptest.NewRecorder() - from := map[string]string{"a": "b"} - Write(w, from) - result := w.Result() - - assert.Equal([]string{"application/json"}, result.Header["Content-Type"], "no header information") - buf := new(bytes.Buffer) - buf.ReadFrom(result.Body) - to := buf.String() - assert.Equal("{\"a\":\"b\"}", to, "wrong content") - - w = httptest.NewRecorder() - value := make(chan int) - Write(w, value) - result = w.Result() - - assert.Equal(http.StatusInternalServerError, result.StatusCode, "wrong statuscode") - -} - -// Function to test read() -func TestRead(t *testing.T) { - assert := assert.New(t) - - to := make(map[string]string) - r, _ := http.NewRequest("GET", "/a", strings.NewReader("{\"a\":\"b\"}")) - - r.Header["Content-Type"] = []string{"application/json"} - err := Read(r, &to) - assert.NoError(err, "no error") - assert.Equal(map[string]string{"a": "b"}, to, "wrong content") - - r.Header["Content-Type"] = []string{""} - err = Read(r, &to) - assert.Error(err, "no error") -} diff --git a/http/main.go b/http/main.go deleted file mode 100644 index a6fc569..0000000 --- a/http/main.go +++ /dev/null @@ -1,12 +0,0 @@ -package http - -import "net/http" - -// GetRemoteIP of http Request -func GetRemoteIP(r *http.Request) string { - ip := r.Header.Get("X-Forwarded-For") - if len(ip) <= 1 { - ip = r.RemoteAddr - } - return ip -} diff --git a/http/main_test.go b/http/main_test.go deleted file mode 100644 index 9ac355f..0000000 --- a/http/main_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package http - -import ( - "net/http" - "testing" - - "github.com/stretchr/testify/assert" -) - -// Function to test the logging -func TestGetIP(t *testing.T) { - assertion := assert.New(t) - - req, _ := http.NewRequest("GET", "https://google.com/lola/duda?q=wasd", nil) - ip := GetRemoteIP(req) - - assertion.Equal("", ip, "no remote ip address") -} diff --git a/web/api/status/main.go b/web/api/status/main.go new file mode 100644 index 0000000..ee2691e --- /dev/null +++ b/web/api/status/main.go @@ -0,0 +1,47 @@ +package status + +import ( + "net/http" + + "github.com/gin-gonic/gin" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +var ( + VERSION string = "" + UP func() bool = func() bool { + return true + } + EXTRAS interface{} = nil +) + +type Status struct { + Version string `json:"version"` + Up bool `json:"up"` + Extras interface{} `json:"extras,omitempty"` +} + +// @Summary Show Status of current API +// @Description Show version and status +// @Produce json +// @Success 200 {object} Status +// @Failure 400 {object} web.HTTPError +// @Failure 404 {object} web.HTTPError +// @Router /api/status [get] +func init() { + web.ModuleRegister(func(r *gin.Engine, ws *web.Service) { + r.GET("/api/status", func(c *gin.Context) { + status := &Status{ + Version: VERSION, + Up: UP(), + Extras: EXTRAS, + } + if !status.Up { + c.JSON(http.StatusInternalServerError, status) + return + } + c.JSON(http.StatusOK, status) + }) + }) +} diff --git a/web/api/status/main_test.go b/web/api/status/main_test.go new file mode 100644 index 0000000..56fb8f2 --- /dev/null +++ b/web/api/status/main_test.go @@ -0,0 +1,23 @@ +package status + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/web/webtest" +) + +func TestAPIStatus(t *testing.T) { + assert := assert.New(t) + s := webtest.New(assert) + assert.NotNil(s) + + obj := Status{} + // GET - common name + s.Request(http.MethodGet, "/api/status", nil, http.StatusOK, &obj) + assert.Equal(VERSION, obj.Version) + assert.Equal(EXTRAS, obj.Extras) + assert.True(obj.Up) +} diff --git a/web/auth/api_login.go b/web/auth/api_login.go new file mode 100644 index 0000000..f90060a --- /dev/null +++ b/web/auth/api_login.go @@ -0,0 +1,76 @@ +package auth + +import ( + "errors" + "net/http" + + "github.com/gin-contrib/sessions" + "github.com/gin-gonic/gin" + "gorm.io/gorm" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +type login struct { + Username string `json:"username" example:"kukoon"` + Password string `json:"password" example:"super secret password"` +} + +// @Summary Login +// @Description Login by username and password, you will get a cookie of current session +// @Accept json +// @Produce json +// @Success 200 {object} User +// @Failure 400 {object} web.HTTPError +// @Failure 401 {object} web.HTTPError +// @Failure 500 {object} web.HTTPError +// @Router /api/v1/auth/login [post] +// @Param body body login false "login" +func init() { + web.ModuleRegister(func(r *gin.Engine, ws *web.Service) { + r.POST("/api/v1/auth/login", func(c *gin.Context) { + var data login + if err := c.BindJSON(&data); err != nil { + c.JSON(http.StatusBadRequest, web.HTTPError{ + Message: web.APIErrorInvalidRequestFormat, + Error: err.Error(), + }) + return + } + + d := &User{} + if err := ws.DB.Where(map[string]interface{}{"username": data.Username}).First(d).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: APIErrorUserNotFound, + Error: err.Error(), + }) + return + } + c.JSON(http.StatusInternalServerError, web.HTTPError{ + Message: web.APIErrorInternalDatabase, + Error: err.Error(), + }) + return + } + if !d.ValidatePassword(data.Password) { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: APIErrorIncorrectPassword, + }) + return + } + + session := sessions.Default(c) + session.Set("user_id", d.ID.String()) + if err := session.Save(); err != nil { + c.JSON(http.StatusBadRequest, web.HTTPError{ + Message: APIErrorCreateSession, + Error: err.Error(), + }) + return + } + + c.JSON(http.StatusOK, d) + }) + }) +} diff --git a/web/auth/api_login_test.go b/web/auth/api_login_test.go new file mode 100644 index 0000000..87d9857 --- /dev/null +++ b/web/auth/api_login_test.go @@ -0,0 +1,44 @@ +package auth + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/database" + "dev.sum7.eu/genofire/golang-lib/web" + "dev.sum7.eu/genofire/golang-lib/web/webtest" +) + +func TestAPILogin(t *testing.T) { + assert := assert.New(t) + s := webtest.New(assert) + assert.NotNil(s) + s.DatabaseMigration(func(db *database.Database) { + SetupMigration(db) + }) + + hErr := web.HTTPError{} + // invalid + s.Request(http.MethodPost, "/api/v1/auth/login", 1, http.StatusBadRequest, &hErr) + assert.Equal(web.APIErrorInvalidRequestFormat, hErr.Message) + + req := login{} + hErr = web.HTTPError{} + // invalid - user + s.Request(http.MethodPost, "/api/v1/auth/login", &req, http.StatusUnauthorized, &hErr) + assert.Equal(APIErrorUserNotFound, hErr.Message) + + req.Username = "admin" + hErr = web.HTTPError{} + // invalid - password + s.Request(http.MethodPost, "/api/v1/auth/login", &req, http.StatusUnauthorized, &hErr) + assert.Equal(APIErrorIncorrectPassword, hErr.Message) + + req.Password = "CHANGEME" + obj := User{} + // valid login + s.Request(http.MethodPost, "/api/v1/auth/login", &req, http.StatusOK, &obj) + assert.Equal("admin", obj.Username) +} diff --git a/web/auth/api_password.go b/web/auth/api_password.go new file mode 100644 index 0000000..5fea3b4 --- /dev/null +++ b/web/auth/api_password.go @@ -0,0 +1,61 @@ +package auth + +import ( + "net/http" + + "github.com/bdlm/log" + "github.com/gin-gonic/gin" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +// @Summary Change Password +// @Description Change Password of current login user +// @Accept json +// @Produce json +// @Success 200 {object} boolean "if password was saved (e.g. `true`)" +// @Failure 400 {object} web.HTTPError +// @Failure 401 {object} web.HTTPError +// @Failure 500 {object} web.HTTPError +// @Router /api/v1/my/auth/password [post] +// @Security ApiKeyAuth +// @Param body body string false "new password" +func init() { + web.ModuleRegister(func(r *gin.Engine, ws *web.Service) { + r.POST("/api/v1/my/auth/password", MiddlewareLogin(ws), func(c *gin.Context) { + d, ok := GetCurrentUser(c, ws) + if !ok { + return + } + var password string + if err := c.BindJSON(&password); err != nil { + c.JSON(http.StatusBadRequest, web.HTTPError{ + Message: web.APIErrorInvalidRequestFormat, + Error: err.Error(), + }) + return + } + if err := d.SetPassword(password); err != nil { + c.JSON(http.StatusInternalServerError, web.HTTPError{ + Message: APIErrroCreatePassword, + Error: err.Error(), + }) + return + } + + result := ws.DB.Save(&d) + if err := result.Error; err != nil { + c.JSON(http.StatusInternalServerError, web.HTTPError{ + Message: web.APIErrorInternalDatabase, + Error: err.Error(), + }) + return + } + if result.RowsAffected > 1 { + log.Panicf("there should not be more then 1 user with the same email, it was %d session", result.RowsAffected) + } + + c.JSON(http.StatusOK, result.RowsAffected == 1) + }) + }) +} diff --git a/web/auth/api_password_test.go b/web/auth/api_password_test.go new file mode 100644 index 0000000..58e0f3e --- /dev/null +++ b/web/auth/api_password_test.go @@ -0,0 +1,41 @@ +package auth + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/database" + "dev.sum7.eu/genofire/golang-lib/web" + "dev.sum7.eu/genofire/golang-lib/web/webtest" +) + +func TestAPIPassword(t *testing.T) { + assert := assert.New(t) + s := webtest.New(assert) + assert.NotNil(s) + s.DatabaseMigration(func(db *database.Database) { + SetupMigration(db) + }) + + passwordCurrent := "CHANGEME" + passwordNew := "test" + + hErr := web.HTTPError{} + // invalid + s.Request(http.MethodPost, "/api/v1/my/auth/password", &passwordNew, http.StatusUnauthorized, &hErr) + assert.Equal(APIErrorNoSession, hErr.Message) + + s.TestLogin() + + res := false + // set new password + s.Request(http.MethodPost, "/api/v1/my/auth/password", &passwordNew, http.StatusOK, &res) + assert.True(res) + + res = false + // set old password + s.Request(http.MethodPost, "/api/v1/my/auth/password", &passwordCurrent, http.StatusOK, &res) + assert.True(res) +} diff --git a/web/auth/api_status.go b/web/auth/api_status.go new file mode 100644 index 0000000..fed239b --- /dev/null +++ b/web/auth/api_status.go @@ -0,0 +1,28 @@ +package auth + +import ( + "net/http" + + "github.com/gin-gonic/gin" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +// @Summary Login status +// @Description show user_id and username if logged in +// @Accept json +// @Produce json +// @Success 200 {object} User +// @Failure 401 {object} web.HTTPError +// @Failure 500 {object} web.HTTPError +// @Router /api/v1/auth/status [get] +func init() { + web.ModuleRegister(func(r *gin.Engine, ws *web.Service) { + r.GET("/api/v1/auth/status", MiddlewareLogin(ws), func(c *gin.Context) { + d, ok := GetCurrentUser(c, ws) + if ok { + c.JSON(http.StatusOK, d) + } + }) + }) +} diff --git a/web/auth/api_status_test.go b/web/auth/api_status_test.go new file mode 100644 index 0000000..aca6661 --- /dev/null +++ b/web/auth/api_status_test.go @@ -0,0 +1,34 @@ +package auth + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/database" + "dev.sum7.eu/genofire/golang-lib/web" + "dev.sum7.eu/genofire/golang-lib/web/webtest" +) + +func TestAPIStatus(t *testing.T) { + assert := assert.New(t) + s := webtest.New(assert) + assert.NotNil(s) + s.DatabaseMigration(func(db *database.Database) { + SetupMigration(db) + }) + + hErr := web.HTTPError{} + // invalid + s.Request(http.MethodGet, "/api/v1/auth/status", nil, http.StatusUnauthorized, &hErr) + assert.Equal(APIErrorNoSession, hErr.Message) + + s.TestLogin() + + obj := User{} + // invalid - user + s.Request(http.MethodGet, "/api/v1/auth/status", nil, http.StatusOK, &obj) + assert.Equal("admin", obj.Username) + +} diff --git a/web/auth/error.go b/web/auth/error.go new file mode 100644 index 0000000..8062e08 --- /dev/null +++ b/web/auth/error.go @@ -0,0 +1,10 @@ +package auth + +const ( + APIErrorUserNotFound string = "user not found" + APIErrorIncorrectPassword string = "incorrect password" + APIErrorNoSession string = "no session" + APIErrorCreateSession string = "create session" + + APIErrroCreatePassword string = "error during create password" +) diff --git a/web/auth/lib_user.go b/web/auth/lib_user.go new file mode 100644 index 0000000..82c18a9 --- /dev/null +++ b/web/auth/lib_user.go @@ -0,0 +1,51 @@ +package auth + +import ( + "errors" + "net/http" + + "github.com/gin-contrib/sessions" + "github.com/gin-gonic/gin" + "github.com/google/uuid" + "gorm.io/gorm" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +func GetCurrentUserID(c *gin.Context) (uuid.UUID, bool) { + session := sessions.Default(c) + + v := session.Get("user_id") + if v == nil { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: APIErrorNoSession, + }) + return uuid.Nil, false + } + + id := uuid.MustParse(v.(string)) + return id, true +} + +func GetCurrentUser(c *gin.Context, ws *web.Service) (*User, bool) { + id, ok := GetCurrentUserID(c) + if !ok { + return nil, false + } + d := &User{ID: id} + if err := ws.DB.First(d).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: APIErrorUserNotFound, + Error: err.Error(), + }) + return nil, false + } + c.JSON(http.StatusInternalServerError, web.HTTPError{ + Message: web.APIErrorInternalDatabase, + Error: err.Error(), + }) + return nil, false + } + return d, true +} diff --git a/web/auth/middleware.go b/web/auth/middleware.go new file mode 100644 index 0000000..1a69cf5 --- /dev/null +++ b/web/auth/middleware.go @@ -0,0 +1,47 @@ +package auth + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/google/uuid" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +func MiddlewareLogin(ws *web.Service) gin.HandlerFunc { + return func(c *gin.Context) { + _, ok := GetCurrentUserID(c) + if !ok { + c.Abort() + } + } +} + +func MiddlewarePermissionParamUUID(ws *web.Service, obj HasPermission) gin.HandlerFunc { + return MiddlewarePermissionParam(ws, obj, "uuid") +} +func MiddlewarePermissionParam(ws *web.Service, obj HasPermission, param string) gin.HandlerFunc { + return func(c *gin.Context) { + userID, ok := GetCurrentUserID(c) + if !ok { + c.Abort() + } + objID, err := uuid.Parse(c.Params.ByName(param)) + if err != nil { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: web.APIErrorInvalidRequestFormat, + Error: err.Error(), + }) + c.Abort() + } + _, err = obj.HasPermission(ws.DB, userID, objID) + if err != nil { + c.JSON(http.StatusUnauthorized, web.HTTPError{ + Message: http.StatusText(http.StatusUnauthorized), + Error: err.Error(), + }) + c.Abort() + } + } +} diff --git a/web/auth/models.go b/web/auth/models.go new file mode 100644 index 0000000..fb94c74 --- /dev/null +++ b/web/auth/models.go @@ -0,0 +1,41 @@ +package auth + +import ( + "github.com/google/uuid" + "golang.org/x/crypto/bcrypt" + "gorm.io/gorm" +) + +type User struct { + ID uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"88078ec0-2135-445f-bf05-632701c77695"` + Username string `json:"username" gorm:"unique" example:"kukoon"` + Password string `json:"-" example:"super secret password"` +} + +func NewUser(username, password string) (*User, error) { + user := &User{ + Username: username, + } + if err := user.SetPassword(password); err != nil { + return nil, err + } + return user, nil +} + +func (this *User) SetPassword(password string) error { + p, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + if err != nil { + return err + } + this.Password = string(p) + return nil +} + +func (this *User) ValidatePassword(password string) bool { + err := bcrypt.CompareHashAndPassword([]byte(this.Password), []byte(password)) + return err == nil +} + +type HasPermission interface { + HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error) +} diff --git a/web/auth/models_test.go b/web/auth/models_test.go new file mode 100644 index 0000000..bd2fdcd --- /dev/null +++ b/web/auth/models_test.go @@ -0,0 +1,60 @@ +package auth + +import ( + "testing" + + gormigrate "github.com/go-gormigrate/gormigrate/v2" + "github.com/google/uuid" + "gorm.io/gorm" + + "dev.sum7.eu/genofire/golang-lib/database" + + "github.com/stretchr/testify/assert" +) + +var ( + TestUser1ID = uuid.MustParse("88078ec0-2135-445f-bf05-632701c77695") +) + +func SetupMigration(db *database.Database) { + db.AddMigration([]*gormigrate.Migration{ + { + ID: "01-schema-0008-01-user", + Migrate: func(tx *gorm.DB) error { + return tx.AutoMigrate(&User{}) + }, + Rollback: func(tx *gorm.DB) error { + return tx.Migrator().DropTable("users") + }, + }, + { + ID: "10-data-0008-01-user", + Migrate: func(tx *gorm.DB) error { + user, err := NewUser("admin", "CHANGEME") + if err != nil { + return err + } + user.ID = TestUser1ID + return tx.Create(user).Error + }, + Rollback: func(tx *gorm.DB) error { + return tx.Delete(&User{ + ID: TestUser1ID, + }).Error + }, + }, + }...) +} + +func TestUserPassword(t *testing.T) { + assert := assert.New(t) + password := "password" + user, err := NewUser("admin", password) + + assert.Nil(err) + assert.NotNil(user) + + assert.False(user.ValidatePassword("12346")) + assert.True(user.ValidatePassword(password)) + assert.NotEqual(password, user.Password, "password should be hashed") +} diff --git a/web/error.go b/web/error.go new file mode 100644 index 0000000..738eada --- /dev/null +++ b/web/error.go @@ -0,0 +1,13 @@ +package web + +type HTTPError struct { + Message string `json:"message" example:"invalid format"` + Error string `json:"error,omitempty" example:""` + Data interface{} `json:"data,omitempty" swaggerignore:"true"` +} + +const ( + APIErrorInvalidRequestFormat = "Invalid Request Format" + APIErrorInternalDatabase = "Internal Database Error" + APIErrorNotFound = "Not found" +) diff --git a/web/main.go b/web/main.go new file mode 100644 index 0000000..e00d22b --- /dev/null +++ b/web/main.go @@ -0,0 +1,61 @@ +package web + +import ( + "github.com/bdlm/log" + "github.com/gin-gonic/gin" + "gorm.io/gorm" + // acme + "github.com/gin-gonic/autotls" + "golang.org/x/crypto/acme/autocert" +) + +// Service to store Configuration and Webserver wide objects +// (like DB Connection) +type Service struct { + // config + Listen string `toml:"listen"` + AccessLog bool `toml:"access_log"` + Webroot string `toml:"webroot"` + ACME struct { + Enable bool `toml:"enable"` + Domains []string `toml:"domains"` + Cache string `toml:"cache"` + } `toml:"acme"` + Session struct { + Name string `toml:"name"` + Secret string `toml:"secret"` + } `toml:"session"` + // internal + DB *gorm.DB `toml:"-"` +} + +// Run to startup all related web parts +// (e.g. configure the server, metrics, and finally bind routing) +func (config *Service) Run() error { + gin.EnableJsonDecoderDisallowUnknownFields() + gin.SetMode(gin.ReleaseMode) + r := gin.New() + // catch crashed + r.Use(gin.Recovery()) + + if config.AccessLog { + r.Use(gin.Logger()) + log.Debug("request logging enabled") + } + config.LoadSession(r) + config.Bind(r) + + if config.ACME.Enable { + if config.Listen != "" { + log.Panic("For ACME / Let's Encrypt it is not possible to set `listen`") + } + m := autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(config.ACME.Domains...), + Cache: autocert.DirCache(config.ACME.Cache), + } + return autotls.RunWithManager(r, &m) + } else { + return r.Run(config.Listen) + } +} diff --git a/web/main_test.go b/web/main_test.go new file mode 100644 index 0000000..efb3895 --- /dev/null +++ b/web/main_test.go @@ -0,0 +1 @@ +package web diff --git a/web/metrics/main.go b/web/metrics/main.go new file mode 100644 index 0000000..dfe6860 --- /dev/null +++ b/web/metrics/main.go @@ -0,0 +1,64 @@ +package metrics + +import ( + "strings" + + "github.com/gin-gonic/gin" + + // gin-prometheus + "github.com/chenjiandongx/ginprom" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" + // db metrics + gormPrometheus "gorm.io/plugin/prometheus" + + "dev.sum7.eu/genofire/golang-lib/web" +) + +var ( + NAMESPACE string = "service" + VERSION string = "" + UP func() bool = func() bool { + return true + } +) + +func init() { + web.ModuleRegister(func(r *gin.Engine, ws *web.Service) { + r.Use(ginprom.PromMiddleware(&ginprom.PromOpts{ + EndpointLabelMappingFn: func(c *gin.Context) string { + url := c.Request.URL.Path + for _, p := range c.Params { + url = strings.Replace(url, p.Value, ":"+p.Key, 1) + } + return url + }, + })) + + prometheus.MustRegister(prometheus.NewGaugeFunc( + prometheus.GaugeOpts{ + Namespace: NAMESPACE, + Name: "up", + Help: "is current version of service running", + ConstLabels: prometheus.Labels{"version": VERSION}, + }, + func() float64 { + if UP() { + return 1 + } + return 0 + }, + )) + + if ws.DB != nil { + ws.DB.Use(gormPrometheus.New(gormPrometheus.Config{ + DBName: NAMESPACE, + RefreshInterval: 15, + })) + + } + + r.GET("/metrics", ginprom.PromHandler(promhttp.Handler())) + }) +} diff --git a/web/metrics/main_test.go b/web/metrics/main_test.go new file mode 100644 index 0000000..56a490e --- /dev/null +++ b/web/metrics/main_test.go @@ -0,0 +1,19 @@ +package metrics + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/web/webtest" +) + +func TestMetricsLoaded(t *testing.T) { + assert := assert.New(t) + s := webtest.New(assert) + assert.NotNil(s) + + // GET + s.Request(http.MethodGet, "/metrics", nil, http.StatusOK, nil) +} diff --git a/web/module.go b/web/module.go new file mode 100644 index 0000000..02ffc27 --- /dev/null +++ b/web/module.go @@ -0,0 +1,26 @@ +package web + +import ( + "github.com/bdlm/log" + "github.com/gin-contrib/static" + "github.com/gin-gonic/gin" +) + +var ( + modules []ModuleRegisterFunc +) + +type ModuleRegisterFunc func(*gin.Engine, *Service) + +func ModuleRegister(f ModuleRegisterFunc) { + modules = append(modules, f) +} + +func (ws *Service) Bind(r *gin.Engine) { + for _, f := range modules { + f(r, ws) + } + + log.Infof("loaded %d modules", len(modules)) + r.Use(static.Serve("/", static.LocalFile(ws.Webroot, false))) +} diff --git a/http/request.go b/web/request.go similarity index 96% rename from http/request.go rename to web/request.go index 5ac5171..6b7183d 100644 --- a/http/request.go +++ b/web/request.go @@ -1,4 +1,4 @@ -package http +package web import ( "encoding/json" diff --git a/web/session.go b/web/session.go new file mode 100644 index 0000000..d0a9206 --- /dev/null +++ b/web/session.go @@ -0,0 +1,12 @@ +package web + +import ( + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/cookie" + "github.com/gin-gonic/gin" +) + +func (config *Service) LoadSession(r *gin.Engine) { + store := cookie.NewStore([]byte(config.Session.Secret)) + r.Use(sessions.Sessions(config.Session.Name, store)) +} diff --git a/web/webtest/main.go b/web/webtest/main.go new file mode 100644 index 0000000..589065d --- /dev/null +++ b/web/webtest/main.go @@ -0,0 +1,124 @@ +package webtest + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "net/http/httptest" + "strings" + + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" + + "dev.sum7.eu/genofire/golang-lib/database" + "dev.sum7.eu/genofire/golang-lib/web" +) + +type testServer struct { + db *database.Database + gin *gin.Engine + ws *web.Service + assert *assert.Assertions + lastCookies []*http.Cookie +} + +type Login struct { + Username string `json:"username"` + Password string `json:"password"` +} + +func New(assert *assert.Assertions) *testServer { + // db setup + dbConfig := database.Database{ + Connection: "user=root password=root dbname=defaultdb host=localhost port=26257 sslmode=disable", + Testdata: true, + Debug: false, + LogLevel: 0, + } + err := dbConfig.Run() + if err != nil && err != database.ErrNothingToMigrate { + fmt.Println(err.Error()) + assert.Nil(err) + } + assert.NotNil(dbConfig.DB) + + // api setup + gin.EnableJsonDecoderDisallowUnknownFields() + gin.SetMode(gin.TestMode) + + ws := &web.Service{ + DB: dbConfig.DB, + } + ws.Session.Name = "mysession" + ws.Session.Secret = "hidden" + + r := gin.Default() + ws.LoadSession(r) + ws.Bind(r) + return &testServer{ + db: &dbConfig, + gin: r, + ws: ws, + assert: assert, + } +} +func (this *testServer) DatabaseMigration(f func(db *database.Database)) { + f(this.db) + this.db.MigrateTestdata() +} +func (this *testServer) Request(method, url string, body interface{}, expectCode int, jsonObj interface{}) { + var jsonBody io.Reader + if body != nil { + if strBody, ok := body.(string); ok { + jsonBody = strings.NewReader(strBody) + } else { + jsonBodyArray, err := json.Marshal(body) + this.assert.Nil(err, "no request created") + jsonBody = bytes.NewBuffer(jsonBodyArray) + } + } + req, err := http.NewRequest(method, url, jsonBody) + this.assert.Nil(err, "no request created") + if len(this.lastCookies) > 0 { + for _, c := range this.lastCookies { + req.AddCookie(c) + } + } + w := httptest.NewRecorder() + this.gin.ServeHTTP(w, req) + + // valid statusCode + this.assert.Equal(expectCode, w.Code, "expected http status code") + if expectCode != w.Code { + fmt.Printf("wrong status code, body:%v\n", w.Body) + return + } + + if jsonObj != nil { + // fetch JSON + err = json.NewDecoder(w.Body).Decode(jsonObj) + this.assert.Nil(err, "decode json") + } + + result := w.Result() + if result != nil { + cookies := result.Cookies() + if len(cookies) > 0 { + this.lastCookies = cookies + } + } +} + +func (this *testServer) Login(login Login) { + // POST: correct login + this.Request(http.MethodPost, "/api/v1/auth/login", &login, http.StatusOK, nil) +} + +func (this *testServer) TestLogin() { + this.Login(Login{ + Username: "admin", + Password: "CHANGEME", + }) +} diff --git a/web/webtest/main_test.go b/web/webtest/main_test.go new file mode 100644 index 0000000..3bd8a6d --- /dev/null +++ b/web/webtest/main_test.go @@ -0,0 +1 @@ +package webtest diff --git a/web/ws/const.go b/web/ws/const.go new file mode 100644 index 0000000..f4309d3 --- /dev/null +++ b/web/ws/const.go @@ -0,0 +1,7 @@ +package ws + +const ( + BodyError = "error" + BodySet = "set" + BodyGet = "get" +) diff --git a/web/ws/main.go b/web/ws/main.go new file mode 100644 index 0000000..a1e30e0 --- /dev/null +++ b/web/ws/main.go @@ -0,0 +1,172 @@ +package ws + +import ( + "context" + "net/http" + "sync" + "time" + + "github.com/bdlm/log" + "github.com/gin-gonic/gin" + "golang.org/x/time/rate" + + "nhooyr.io/websocket" + "nhooyr.io/websocket/wsjson" +) + +type WebsocketEndpoint struct { + // publishLimiter controls the rate limit applied to the publish endpoint. + // + // Defaults to one publish every 100ms with a burst of 8. + publishLimiter *rate.Limiter + + subscribersMu sync.Mutex + Subscribers map[*Subscriber]struct{} + + // Message Handler + handlers map[string]MessageHandleFunc + DefaultMessageHandler MessageHandleFunc + OnOpen SubscriberEventFunc + OnClose SubscriberEventFunc +} + +// MessageHandleFunc for handling messages +type MessageHandleFunc func(ctx context.Context, msg *Message) + +type SubscriberEventFunc func(s *Subscriber, msg chan<- *Message) + +// Message on websocket +type Message struct { + Type string `json:"type"` + Body map[string]interface{} `json:"body"` + Reply chan<- *Message `json:"-"` + Subscriber *Subscriber `json:"-"` +} + +func NewEndpoint() *WebsocketEndpoint { + return &WebsocketEndpoint{ + publishLimiter: rate.NewLimiter(rate.Every(time.Millisecond*100), 8), + Subscribers: make(map[*Subscriber]struct{}), + handlers: make(map[string]MessageHandleFunc), + } +} +func (this *WebsocketEndpoint) Handler(ctx *gin.Context) { + c, err := websocket.Accept(ctx.Writer, ctx.Request, &websocket.AcceptOptions{ + InsecureSkipVerify: true, + }) + if err != nil { + ctx.JSON(http.StatusBadRequest, false) + return + } + defer c.Close(websocket.StatusInternalError, "") + + err = this.addSubscriber(ctx, c) + + if websocket.CloseStatus(err) == websocket.StatusNormalClosure || + websocket.CloseStatus(err) == websocket.StatusGoingAway { + return + } + log.Errorf("subscriber stopped: %s", err) +} + +func (this *WebsocketEndpoint) AddMessageHandler(typ string, f MessageHandleFunc) { + this.handlers[typ] = f +} + +type Subscriber struct { + out chan *Message + closeSlow func() +} + +func (this *WebsocketEndpoint) readWorker(ctx context.Context, c *websocket.Conn, s *Subscriber) error { + for { + var msg Message + err := wsjson.Read(ctx, c, &msg) + if err != nil { + return err + } + log.WithField("type", msg.Type).Debug("receive") + msg.Subscriber = s + msg.Reply = s.out + if handler, ok := this.handlers[msg.Type]; ok { + handler(ctx, &msg) + } else if this.DefaultMessageHandler != nil { + this.DefaultMessageHandler(ctx, &msg) + } + } +} + +func (this *WebsocketEndpoint) addSubscriber(ctxGin *gin.Context, c *websocket.Conn) error { + s := &Subscriber{ + out: make(chan *Message, 10), + closeSlow: func() { + c.Close(websocket.StatusPolicyViolation, "connection too slow to keep up with messages") + }, + } + + this.subscribersMu.Lock() + this.Subscribers[s] = struct{}{} + this.subscribersMu.Unlock() + defer func() { + this.subscribersMu.Lock() + delete(this.Subscribers, s) + this.subscribersMu.Unlock() + if this.OnClose != nil { + this.OnClose(s, s.out) + } + log.Debug("websocket closed") + }() + + if this.OnOpen != nil { + this.OnOpen(s, s.out) + } + + ctx := ctxGin.Request.Context() + + go func() { + err := this.readWorker(ctx, c, s) + if websocket.CloseStatus(err) == websocket.StatusNormalClosure || + websocket.CloseStatus(err) == websocket.StatusGoingAway { + return + } + log.Errorf("websocket reading error: %s", err) + }() + log.Debug("websocket started") + + for { + select { + case msg := <-s.out: + err := writeTimeout(ctx, time.Second*5, c, msg) + if err != nil { + return err + } + case <-ctx.Done(): + return ctx.Err() + } + } +} + +func writeTimeout(ctx context.Context, timeout time.Duration, c *websocket.Conn, msg *Message) error { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + return wsjson.Write(ctx, c, msg) +} + +func (this *WebsocketEndpoint) Broadcast(msg *Message) { + this.subscribersMu.Lock() + defer this.subscribersMu.Unlock() + + this.publishLimiter.Wait(context.Background()) + + for s := range this.Subscribers { + if s == msg.Subscriber { + continue + } + select { + case s.out <- msg: + default: + go s.closeSlow() + } + } +} diff --git a/web/ws/main_test.go b/web/ws/main_test.go new file mode 100644 index 0000000..9859295 --- /dev/null +++ b/web/ws/main_test.go @@ -0,0 +1 @@ +package ws diff --git a/websocket/client.go b/websocket/client.go deleted file mode 100644 index 4ee9afb..0000000 --- a/websocket/client.go +++ /dev/null @@ -1,122 +0,0 @@ -package websocket - -import ( - "github.com/google/uuid" - "github.com/bdlm/log" - - "github.com/gorilla/websocket" -) - -const channelBufSize = 1000 - -// Client of Websocket Server Connection -type Client struct { - id uuid.UUID - server *Server - ws *websocket.Conn - out chan *Message - writeQuit chan bool - readQuit chan bool -} - -// NewClient by websocket -func NewClient(s *Server, ws *websocket.Conn) *Client { - if ws == nil { - log.WithField("modul", "websocket").Panic("client cannot be created without websocket") - } - return &Client{ - server: s, - ws: ws, - id: uuid.New(), // fallback id (for testing) - out: make(chan *Message, channelBufSize), - writeQuit: make(chan bool), - readQuit: make(chan bool), - } -} - -// GetID of Client ( UUID or Address to Client) -func (c *Client) GetID() string { - if c.ws != nil { - return c.ws.RemoteAddr().String() - } - return c.id.String() -} - -// Write Message to Client -func (c *Client) Write(msg *Message) { - select { - case c.out <- msg: - default: - c.server.delClient(c) - c.Close() - } -} - -// Close Client -func (c *Client) Close() { - c.writeQuit <- true - c.readQuit <- true - log.WithField("modul", "websocket").Info("client disconnecting...", c.GetID()) -} - -// Listen write and read request via channel -func (c *Client) Listen() { - go c.listenWrite() - c.server.addClient(c) - c.listenRead() -} - -// handleInput manage session and valide message before send to server -func (c *Client) handleInput(msg *Message) { - msg.From = c - if sm := c.server.sessionManager; sm != nil && sm.HandleMessage(msg) { - return - } - if ok, err := msg.Validate(); ok { - msg.server = c.server - c.server.msgChanIn <- msg - } else { - log.WithField("modul", "websocket").Println("no valid msg for:", c.GetID(), "error:", err, "\nmessage:", msg) - } -} - -// listenWrite request via channel -func (c *Client) listenWrite() { - for { - select { - case msg := <-c.out: - websocket.WriteJSON(c.ws, msg) - - case <-c.writeQuit: - c.server.delClient(c) - close(c.out) - close(c.writeQuit) - return - } - } -} - -// listenRead request via channel -func (c *Client) listenRead() { - for { - select { - - case <-c.readQuit: - c.server.delClient(c) - close(c.readQuit) - return - - default: - var msg Message - err := websocket.ReadJSON(c.ws, &msg) - if websocket.IsCloseError(err, websocket.CloseGoingAway) { - return - } else if err != nil { - log.WithField("modul", "websocket").Warnf("error on reading %s: %s", c.GetID(), err) - return - } else { - c.handleInput(&msg) - } - } - } -} diff --git a/websocket/client_test.go b/websocket/client_test.go deleted file mode 100644 index 62b22a7..0000000 --- a/websocket/client_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package websocket - -import ( - "testing" - - "github.com/google/uuid" - "github.com/gorilla/websocket" - "github.com/stretchr/testify/assert" -) - -func TestClient(t *testing.T) { - assert := assert.New(t) - - chanMsg := make(chan *Message) - sm := NewSessionManager() - - srv := NewServer(chanMsg, sm) - - assert.Panics(func() { - NewClient(srv, nil) - }) - - client := NewClient(srv, &websocket.Conn{}) - assert.NotNil(client) - - client = &Client{ - server: srv, - id: uuid.New(), - out: make(chan *Message, channelBufSize), - writeQuit: make(chan bool), - readQuit: make(chan bool), - } - - client.handleInput(&Message{}) - - go client.handleInput(&Message{Subject: "a"}) - msg := <-chanMsg - assert.Equal("a", msg.Subject) - - // msg catched by sessionManager -> not read from chanMsg needed - client.handleInput(&Message{ - ID: uuid.New(), - Subject: SessionMessageInit, - }) - -} diff --git a/websocket/doc.go b/websocket/doc.go deleted file mode 100644 index 9261ab6..0000000 --- a/websocket/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package websocket to handling connection and session by messages and there subject -package websocket diff --git a/websocket/handler.go b/websocket/handler.go deleted file mode 100644 index 088ad5a..0000000 --- a/websocket/handler.go +++ /dev/null @@ -1,70 +0,0 @@ -package websocket - -import ( - "net/http" - - "github.com/google/uuid" -) - -// MessageHandleFunc for handling messages -type MessageHandleFunc func(msg *Message) - -// WebsocketHandlerService to handle every Message on there Subject by Handlers -type WebsocketHandlerService struct { - inputMSG chan *Message - server *Server - handlers map[string]MessageHandleFunc - FallbackHandler MessageHandleFunc -} - -// NewWebsocketHandlerService with Websocket Server -func NewWebsocketHandlerService() *WebsocketHandlerService { - ws := WebsocketHandlerService{ - handlers: make(map[string]MessageHandleFunc), - inputMSG: make(chan *Message), - } - ws.server = NewServer(ws.inputMSG, NewSessionManager()) - return &ws -} - -func (ws *WebsocketHandlerService) messageHandler() { - for msg := range ws.inputMSG { - if handler, ok := ws.handlers[msg.Subject]; ok { - handler(msg) - } else if ws.FallbackHandler != nil { - ws.FallbackHandler(msg) - } - } -} - -// SetHandler for a message type by subject -func (ws *WebsocketHandlerService) SetHandler(subject string, f MessageHandleFunc) { - ws.handlers[subject] = f -} - -// SendAll see Server.SendAll -func (ws *WebsocketHandlerService) SendAll(msg *Message) { - if server := ws.server; server != nil { - server.SendAll(msg) - } -} - -// SendSession see message to all connection of one session -func (ws *WebsocketHandlerService) SendSession(id uuid.UUID, msg *Message) { - if server := ws.server; server != nil { - if mgmt := server.sessionManager; mgmt != nil { - mgmt.Send(id, msg) - } - } -} - -// Listen on net/http server at `path` and start running handling -func (ws *WebsocketHandlerService) Listen(path string) { - http.HandleFunc(path, ws.server.Handler) - go ws.messageHandler() -} - -// Close webserver -func (ws *WebsocketHandlerService) Close() { - close(ws.inputMSG) -} diff --git a/websocket/handler_test.go b/websocket/handler_test.go deleted file mode 100644 index b381b47..0000000 --- a/websocket/handler_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package websocket - -import ( - "sync" - "testing" - - "github.com/google/uuid" - - "github.com/stretchr/testify/assert" -) - -func TestHandler(t *testing.T) { - assert := assert.New(t) - - chanMsg := make(chan *Message) - handlerService := NewWebsocketHandlerService() - assert.NotNil(handlerService) - - handlerService.inputMSG = chanMsg - handlerService.server.msgChanIn = chanMsg - - wg := sync.WaitGroup{} - - handlerService.SetHandler("dummy", func(msg *Message) { - assert.Equal("expected", msg.Body) - wg.Done() - }) - wg.Add(1) - - handlerService.Listen("path") - defer handlerService.Close() - - chanMsg <- &Message{Subject: "dummy", Body: "expected"} - - wg.Wait() - - wg.Add(1) - handlerService.FallbackHandler = func(msg *Message) { - assert.Equal("unexpected", msg.Body) - wg.Done() - } - chanMsg <- &Message{Subject: "mist", Body: "unexpected"} - wg.Wait() - - handlerService.SendAll(&Message{Subject: "dummy", Body: "100% maybe"}) - handlerService.SendSession(uuid.New(), &Message{Subject: "dummy", Body: "100% maybe"}) -} diff --git a/websocket/msg.go b/websocket/msg.go deleted file mode 100644 index d8aa796..0000000 --- a/websocket/msg.go +++ /dev/null @@ -1,91 +0,0 @@ -package websocket - -import ( - "errors" - - "github.com/google/uuid" -) - -// Message which send over websocket -type Message struct { - server *Server - ID uuid.UUID `json:"id,omitempty"` - Session uuid.UUID `json:"-"` - From *Client `json:"-"` - Subject string `json:"subject,omitempty"` - Body interface{} `json:"body,omitempty"` -} - -// Validate is it valid message to forward -func (msg *Message) Validate() (bool, error) { - if msg.Subject == "" { - return false, errors.New("no subject definied") - } - if msg.From == nil { - return false, errors.New("no sender definied") - } - return true, nil -} - -// Replay to request -func (msg *Message) Replay(body interface{}) error { - return msg.Answer(msg.Subject, body) -} - -// Answer to replay at a request -func (msg *Message) Answer(subject string, body interface{}) error { - if msg.From == nil { - return errors.New("Message not received by a websocket Server") - } - msg.From.Write(&Message{ - ID: msg.ID, - Session: msg.Session, - From: msg.From, - Subject: subject, - Body: body, - }) - return nil -} - -// ReplaySession to replay all of current Session -func (msg *Message) ReplaySession(body interface{}) error { - return msg.AnswerSession(msg.Subject, body) -} - -// AnswerSession to replay all of current Session -func (msg *Message) AnswerSession(subject string, body interface{}) error { - if msg.server == nil { - return errors.New("Message not received by a websocket Server") - } - if msg.server.sessionManager == nil { - return errors.New("websocket Server run without SessionManager") - } - msg.server.sessionManager.Send(msg.Session, &Message{ - ID: msg.ID, - Session: msg.Session, - From: msg.From, - Subject: subject, - Body: body, - }) - return nil -} - -// ReplayEverybody to replay all connection on Server -func (msg *Message) ReplayEverybody(body interface{}) error { - return msg.AnswerEverybody(msg.Subject, body) -} - -// AnswerEverybody to replay all connection on Server -func (msg *Message) AnswerEverybody(subject string, body interface{}) error { - if msg.server == nil { - return errors.New("Message not received by a websocket Server") - } - msg.server.SendAll(&Message{ - ID: msg.ID, - Session: msg.Session, - From: msg.From, - Subject: subject, - Body: body, - }) - return nil -} diff --git a/websocket/msg_test.go b/websocket/msg_test.go deleted file mode 100644 index c6320db..0000000 --- a/websocket/msg_test.go +++ /dev/null @@ -1,189 +0,0 @@ -package websocket - -import ( - "sync" - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/assert" -) - -func TestMSGValidate(t *testing.T) { - assert := assert.New(t) - - msg := &Message{} - assert.False(msg.Validate()) - - msg.Subject = "login" - assert.False(msg.Validate()) - - msg.From = &Client{} - assert.True(msg.Validate()) - - msg.Subject = "" - assert.False(msg.Validate()) -} - -func TestMSGReplay(t *testing.T) { - assert := assert.New(t) - - out := make(chan *Message, channelBufSize) - client := &Client{ - id: uuid.New(), - out: out, - writeQuit: make(chan bool), - readQuit: make(chan bool), - } - - conversationID := uuid.New() - - msg := &Message{ - ID: conversationID, - Subject: "lola", - } - err := msg.Replay(nil) - assert.Error(err) - - msg.From = client - - done := make(chan bool) - defer close(done) - - go func() { - err := msg.Replay("hi") - assert.NoError(err) - done <- true - }() - msg = <-out - <-done - - assert.Equal(conversationID, msg.ID) - assert.Equal(uuid.Nil, msg.Session) - assert.Equal(client, msg.From) - assert.Equal("lola", msg.Subject) - assert.Equal("hi", msg.Body) -} - -func TestMSGSession(t *testing.T) { - assert := assert.New(t) - - srv := NewServer(nil, nil) - assert.NotNil(srv) - - sessionID := uuid.New() - - conversationID := uuid.New() - msg := &Message{ - Session: sessionID, - ID: conversationID, - Subject: "lola", - } - - err := msg.ReplaySession("error") - assert.Error(err) - - msg.server = srv - err = msg.ReplaySession("error") - assert.Error(err) - - srv.sessionManager = NewSessionManager() - - out1 := make(chan *Message, 3) - c1 := &Client{ - id: uuid.New(), - out: out1, - server: srv, - } - - out2 := make(chan *Message, 3) - c2 := &Client{ - id: uuid.New(), - out: out2, - server: srv, - } - srv.addClient(c1) - srv.addClient(c2) - - wgSession := sync.WaitGroup{} - wg := sync.WaitGroup{} - client := func(out chan *Message) { - for msg := range out { - if msg.Subject == SessionMessageInit { - msg.ID = sessionID - msg.From.handleInput(msg) - wgSession.Done() - } else { - assert.Equal("lola", msg.Subject) - assert.Equal("hi", msg.Body) - assert.Equal(conversationID, msg.ID) - assert.Equal(sessionID, msg.Session) - wg.Done() - } - } - } - wg.Add(2) - wgSession.Add(2) - go client(out1) - go client(out2) - wgSession.Wait() - - err = msg.ReplaySession("hi") - assert.NoError(err) - wg.Wait() - - srv.delClient(c2) - srv.delClient(c1) -} - -func TestMSGEverbody(t *testing.T) { - assert := assert.New(t) - - srv := NewServer(nil, nil) - assert.NotNil(srv) - - out1 := make(chan *Message, 2) - c1 := &Client{ - id: uuid.New(), - out: out1, - server: srv, - } - - out2 := make(chan *Message, 2) - c2 := &Client{ - id: uuid.New(), - out: out2, - server: srv, - } - srv.addClient(c1) - srv.addClient(c2) - - wg := sync.WaitGroup{} - - conversationID := uuid.New() - msg := &Message{ - ID: conversationID, - Subject: "lola", - } - err := msg.ReplayEverybody("error") - assert.Error(err) - - client := func(out chan *Message) { - msg := <-out - assert.Equal("lola", msg.Subject) - assert.Equal("hi", msg.Body) - assert.Equal(conversationID, msg.ID) - assert.Equal(uuid.Nil, msg.Session) - wg.Done() - } - wg.Add(2) - go client(out1) - go client(out2) - - msg.server = srv - err = msg.ReplayEverybody("hi") - assert.NoError(err) - wg.Wait() - - srv.delClient(c2) - srv.delClient(c1) -} diff --git a/websocket/server.go b/websocket/server.go deleted file mode 100644 index 237bf59..0000000 --- a/websocket/server.go +++ /dev/null @@ -1,80 +0,0 @@ -package websocket - -import ( - "net/http" - "sync" - - "github.com/gorilla/websocket" - "github.com/bdlm/log" -) - -// Server of websocket -type Server struct { - msgChanIn chan *Message - clients map[string]*Client - clientsMutex sync.Mutex - sessionManager *SessionManager - upgrader websocket.Upgrader -} - -// NewServer to get a new Server for websockets -func NewServer(msgChanIn chan *Message, sessionManager *SessionManager) *Server { - return &Server{ - clients: make(map[string]*Client), - msgChanIn: msgChanIn, - sessionManager: sessionManager, - upgrader: websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024, - }, - } -} - -// Handler of websocket Server for binding on webserver -func (s *Server) Handler(w http.ResponseWriter, r *http.Request) { - conn, err := s.upgrader.Upgrade(w, r, nil) - if err != nil { - log.WithField("modul", "websocket").Warnf("error during upgrade to websocket: %s", err) - return - } - client := NewClient(s, conn) - defer client.Close() - client.Listen() -} - -func (s *Server) addClient(c *Client) { - if c == nil { - return - } - if id := c.GetID(); id != "" { - s.clientsMutex.Lock() - s.clients[id] = c - s.clientsMutex.Unlock() - if s.sessionManager != nil { - s.sessionManager.Init(c) - } - } -} - -func (s *Server) delClient(c *Client) { - if c == nil { - return - } - if id := c.GetID(); id != "" { - s.clientsMutex.Lock() - delete(s.clients, id) - s.clientsMutex.Unlock() - if s.sessionManager != nil { - s.sessionManager.Remove(c) - } - } -} - -// SendAll to Send a message on every Client -func (s *Server) SendAll(msg *Message) { - s.clientsMutex.Lock() - defer s.clientsMutex.Unlock() - for _, c := range s.clients { - c.Write(msg) - } -} diff --git a/websocket/server_test.go b/websocket/server_test.go deleted file mode 100644 index f0c2322..0000000 --- a/websocket/server_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package websocket - -import ( - "net/http" - "net/http/httptest" - "sync" - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/assert" -) - -func TestServer(t *testing.T) { - assert := assert.New(t) - - srv := NewServer(nil, NewSessionManager()) - assert.NotNil(srv) - - req, _ := http.NewRequest("GET", "url", nil) - w := httptest.NewRecorder() - srv.Handler(w, req) - - out := make(chan *Message) - c := &Client{ - out: out, - server: srv, - } - srv.addClient(nil) - go srv.addClient(c) - msg := <-out - assert.Equal(SessionMessageInit, msg.Subject) - - srv.delClient(nil) - srv.delClient(c) -} - -func TestServerSendAll(t *testing.T) { - assert := assert.New(t) - srv := NewServer(nil, nil) - assert.NotNil(srv) - - out1 := make(chan *Message, 2) - c1 := &Client{ - id: uuid.New(), - out: out1, - server: srv, - } - - out2 := make(chan *Message, 2) - c2 := &Client{ - id: uuid.New(), - out: out2, - server: srv, - } - srv.addClient(c1) - srv.addClient(c2) - - wg := sync.WaitGroup{} - - client := func(out chan *Message) { - msg := <-out - assert.Equal("hi", msg.Subject) - wg.Done() - } - wg.Add(2) - go client(out1) - go client(out2) - - srv.SendAll(&Message{ - Subject: "hi", - }) - wg.Wait() - - srv.delClient(c2) - srv.delClient(c1) -} diff --git a/websocket/session.go b/websocket/session.go deleted file mode 100644 index cdd7aeb..0000000 --- a/websocket/session.go +++ /dev/null @@ -1,95 +0,0 @@ -package websocket - -import ( - "sync" - - "github.com/google/uuid" -) - -// SessionMessageInit subject in messages -const SessionMessageInit = "session_init" - -// SessionManager to handle reconnected websocket -type SessionManager struct { - sessionToClient map[uuid.UUID]map[string]*Client - clientToSession map[string]uuid.UUID - sync.Mutex -} - -// NewSessionManager to get a new SessionManager -func NewSessionManager() *SessionManager { - return &SessionManager{ - sessionToClient: make(map[uuid.UUID]map[string]*Client), - clientToSession: make(map[string]uuid.UUID), - } -} - -// Init Session for given Client -func (s *SessionManager) Init(c *Client) { - c.Write(&Message{ - From: c, - Subject: SessionMessageInit, - }) -} - -// HandleMessage of client for Session -func (s *SessionManager) HandleMessage(msg *Message) bool { - if msg == nil { - return false - } - if msg.ID != uuid.Nil && msg.Subject == SessionMessageInit && msg.From != nil { - s.Lock() - defer s.Unlock() - list := s.sessionToClient[msg.ID] - if list == nil { - list = make(map[string]*Client) - } - id := msg.From.GetID() - list[id] = msg.From - s.clientToSession[id] = msg.ID - s.sessionToClient[msg.ID] = list - return true - } - if msg.From != nil { - id := msg.From.GetID() - msg.Session = s.clientToSession[id] - } - - return false -} - -// Remove clients from SessionManagerer -// - 1. result: clients removed from session manager -// - 2. result: session closed and all clients removed -func (s *SessionManager) Remove(c *Client) (client bool, session bool) { - if c == nil { - return false, false - } - if id := c.GetID(); id != "" { - session := s.clientToSession[id] - defer delete(s.clientToSession, id) - if session != uuid.Nil { - s.Lock() - defer s.Unlock() - clients := s.sessionToClient[session] - delete(clients, id) - if len(clients) > 0 { - s.sessionToClient[session] = clients - return true, false - } - delete(s.sessionToClient, session) - return true, true - } - } - return false, false -} - -// Send a message to a specific Session (and all his Websocket clients) -func (s *SessionManager) Send(id uuid.UUID, msg *Message) { - s.Lock() - defer s.Unlock() - clients := s.sessionToClient[id] - for _, c := range clients { - c.Write(msg) - } -} diff --git a/websocket/session_test.go b/websocket/session_test.go deleted file mode 100644 index 747082e..0000000 --- a/websocket/session_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package websocket - -import ( - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/assert" -) - -func TestSessionManager(t *testing.T) { - assert := assert.New(t) - - session := NewSessionManager() - assert.NotNil(session) - - out := make(chan *Message, channelBufSize) - client := &Client{ - id: uuid.New(), - out: out, - writeQuit: make(chan bool), - readQuit: make(chan bool), - } - - go session.Init(client) - msg := <-out - assert.Equal(SessionMessageInit, msg.Subject) - - result := session.HandleMessage(nil) - assert.False(result) - - msgFillSession := &Message{} - result = session.HandleMessage(msgFillSession) - assert.False(result) - - result = session.HandleMessage(&Message{ - ID: uuid.New(), - From: client, - }) - assert.False(result) - - sessionID := uuid.New() - result = session.HandleMessage(&Message{ - ID: sessionID, - From: client, - Subject: SessionMessageInit, - }) - assert.True(result) - - go session.Send(sessionID, &Message{ - Subject: "some trash", - }) - msg = <-out - assert.Equal("some trash", msg.Subject) - - // a client need to disconnected - c, s := session.Remove(nil) - assert.False(c) - assert.False(s) - - out2 := make(chan *Message, channelBufSize) - client2 := &Client{ - id: uuid.New(), - out: out2, - writeQuit: make(chan bool), - readQuit: make(chan bool), - } - - go session.Init(client2) - msg = <-out2 - result = session.HandleMessage(&Message{ - ID: sessionID, - From: client2, - Subject: SessionMessageInit, - }) - assert.True(result) - - // remove first client of session - c, s = session.Remove(client) - assert.True(c) - assert.False(s) - - // remove last client of session - c, s = session.Remove(client2) - assert.True(c) - assert.True(s) - - // all client disconnected already - c, s = session.Remove(client2) - assert.False(c) - assert.False(s) -}