This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push: new f97a85e SCB-1549 peer to peer event notification (#58) f97a85e is described below commit f97a85e927d0d14894b6db33710778e2effbc075 Author: Shawn <xiaoliang.t...@gmail.com> AuthorDate: Sat Dec 28 17:09:33 2019 +0800 SCB-1549 peer to peer event notification (#58) --- .travis.yml | 5 +- client/adaptor/kie_client.go | 21 +- client/adaptor/kie_client_test.go | 68 +++--- client/client.go | 14 +- client/client_test.go | 12 +- cmd/kieserver/main.go | 35 +-- go.mod | 18 +- go.sum | 257 ++++++++++++++++++--- pkg/common/common.go | 3 +- pkg/model/kv.go | 2 +- server/config/config.go | 9 +- server/config/config_test.go | 3 +- server/config/struct.go | 7 + server/pubsub/bus.go | 126 ++++++++++ .../{config/config_test.go => pubsub/bus_test.go} | 56 +++-- server/pubsub/event_handler.go | 63 +++++ .../v1/v1_suite_test.go => pubsub/options.go} | 20 +- server/pubsub/struct.go | 117 ++++++++++ .../v1/v1_suite_test.go => pubsub/struct_test.go} | 41 +++- server/resource/v1/common.go | 71 +++++- server/resource/v1/doc_struct.go | 11 +- server/resource/v1/kv_resource.go | 161 +++++++------ server/resource/v1/kv_resource_test.go | 27 ++- server/resource/v1/v1_suite_test.go | 1 + server/service/mongo/kv/kv_dao.go | 8 +- server/service/mongo/kv/kv_service.go | 9 +- 26 files changed, 894 insertions(+), 271 deletions(-) diff --git a/.travis.yml b/.travis.yml index a425a01..f9147ae 100755 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ language: go sudo: required go: - - 1.11 + - 1.13 install: true before_script: @@ -43,7 +43,7 @@ jobs: - bash scripts/travis/goConstChecker.sh - stage: GoLint Checker script: - - go get -u github.com/golang/lint/golint + - go get -u golang.org/x/lint - bash scripts/travis/goLintChecker.sh - stage: GoCyclo Checker script: @@ -51,6 +51,7 @@ jobs: - bash scripts/travis/goCycloChecker.sh - stage: Unit Test script: + - export GOPROXY=https://goproxy.io - GO111MODULE=on go mod download - GO111MODULE=on go mod vendor - bash scripts/travis/start_deps.sh diff --git a/client/adaptor/kie_client.go b/client/adaptor/kie_client.go index a640e8a..03b7ea2 100644 --- a/client/adaptor/kie_client.go +++ b/client/adaptor/kie_client.go @@ -20,17 +20,16 @@ package adaptor import ( "context" "errors" - "github.com/apache/servicecomb-kie/client" "github.com/apache/servicecomb-kie/pkg/model" - "github.com/go-chassis/go-chassis-config" + "github.com/go-chassis/go-archaius/source/remote" "github.com/go-mesh/openlogging" ) // Client contains the implementation of Client type Client struct { KieClient *client.Client - opts config.Options + opts remote.Options } const ( @@ -39,7 +38,7 @@ const ( ) // NewClient init the necessary objects needed for seamless communication to Kie Server -func NewClient(options config.Options) (config.Client, error) { +func NewClient(options remote.Options) (remote.Client, error) { kieClient := &Client{ opts: options, } @@ -85,12 +84,10 @@ func (c *Client) PullConfig(key, contentType string, labels map[string]string) ( openlogging.GetLogger().Error("Error in Querying the Response from Kie: " + err.Error()) return nil, err } - for _, doc := range configurationsValue { - for _, kvDoc := range doc.Data { - if key == kvDoc.Key { - openlogging.GetLogger().Debugf("The Key Value of : ", kvDoc.Value) - return doc, nil - } + for _, kvDoc := range configurationsValue.Data { + if key == kvDoc.Key { + openlogging.GetLogger().Debugf("The Key Value of : ", kvDoc.Value) + return kvDoc, nil } } return nil, errors.New("can not find value") @@ -136,10 +133,10 @@ func (c *Client) Watch(f func(map[string]interface{}), errHandler func(err error } //Options return settings -func (c *Client) Options() config.Options { +func (c *Client) Options() remote.Options { return c.opts } func init() { - config.InstallConfigClientPlugin(Name, NewClient) + remote.InstallConfigClientPlugin(Name, NewClient) } diff --git a/client/adaptor/kie_client_test.go b/client/adaptor/kie_client_test.go index cfd6954..20443e9 100644 --- a/client/adaptor/kie_client_test.go +++ b/client/adaptor/kie_client_test.go @@ -22,7 +22,7 @@ import ( "encoding/json" "fmt" "github.com/apache/servicecomb-kie/pkg/model" - config "github.com/go-chassis/go-chassis-config" + "github.com/go-chassis/go-archaius/source/remote" "github.com/stretchr/testify/assert" "net/http" "os" @@ -37,10 +37,10 @@ func init() { func TestKieClient_NewKieClient(t *testing.T) { gopath := os.Getenv("GOPATH") os.Setenv("CHASSIS_HOME", gopath+"src/github.com/go-chassis/go-chassis/examples/discovery/server/") - _, err := NewClient(config.Options{Labels: map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + _, err := NewClient(remote.Options{Labels: map[string]string{ + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }, ServerURI: "http://127.0.0.1:49800", Endpoint: "http://127.0.0.1:49800"}) assert.Equal(t, err, nil) @@ -52,15 +52,15 @@ func TestKieClient_PullConfig(t *testing.T) { helper := startHttpServer(":49800", "/v1/test/kie/kv/test") gopath := os.Getenv("GOPATH") os.Setenv("CHASSIS_HOME", gopath+"src/github.com/go-chassis/go-chassis/examples/discovery/server/") - kieClient, err := NewClient(config.Options{Labels: map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + kieClient, err := NewClient(remote.Options{Labels: map[string]string{ + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }, ServerURI: "http://127.0.0.1:49800", Endpoint: "http://127.0.0.1:49800"}) _, err = kieClient.PullConfig("test", "1", map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }) //assert.Equal(t, resp.StatusCode, 404) assert.Equal(t, err.Error(), "can not find value") @@ -76,15 +76,15 @@ func TestKieClient_PullConfigs(t *testing.T) { helper := startHttpServer(":49800", "/v1/calculator/kie/kv?q=version:0.0.1+app:+env:+servicename:calculator") gopath := os.Getenv("GOPATH") os.Setenv("CHASSIS_HOME", gopath+"src/github.com/go-chassis/go-chassis/examples/discovery/server/") - kieClient, err := NewClient(config.Options{Labels: map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + kieClient, err := NewClient(remote.Options{Labels: map[string]string{ + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }, ServerURI: "http://127.0.0.1:49800", Endpoint: "http://127.0.0.1:49800"}) _, err = kieClient.PullConfigs(map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }) //assert.Equal(t, resp.StatusCode, 404) assert.Equal(t, err.Error(), "can not find value") @@ -100,17 +100,17 @@ func TestKieClient_PushConfigs(t *testing.T) { helper := startHttpServer(":49800", "/") gopath := os.Getenv("GOPATH") os.Setenv("CHASSIS_HOME", gopath+"src/github.com/go-chassis/go-chassis/examples/discovery/server/") - kieClient, err := NewClient(config.Options{Labels: map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + kieClient, err := NewClient(remote.Options{Labels: map[string]string{ + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }, ServerURI: "http://127.0.0.1:49800", Endpoint: "http://127.0.0.1:49800"}) data := make(map[string]interface{}) data["test_info"] = "test_info" _, err = kieClient.PushConfigs(data, map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }) //assert.Equal(t, resp.StatusCode, 404) assert.Equal(t, err.Error(), "json: cannot unmarshal array into Go value of type model.KVDoc") @@ -126,19 +126,19 @@ func TestKieClient_DeleteConfigs(t *testing.T) { helper := startHttpServer(":49800", "/v1/calculator/kie/kv/?kvID=s") gopath := os.Getenv("GOPATH") os.Setenv("CHASSIS_HOME", gopath+"src/github.com/go-chassis/go-chassis/examples/discovery/server/") - kieClient, err := NewClient(config.Options{Labels: map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + kieClient, err := NewClient(remote.Options{Labels: map[string]string{ + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }, ServerURI: "http://127.0.0.1:49800", Endpoint: "http://127.0.0.1:49800"}) data := []string{"1"} _, err = kieClient.DeleteConfigsByKeys(data, map[string]string{ - config.LabelVersion: "1", - config.LabelApp: "", - config.LabelService: "test", + remote.LabelVersion: "1", + remote.LabelApp: "", + remote.LabelService: "test", }) //assert.Equal(t, resp.StatusCode, 404) - assert.Equal(t, "delete 1 failed,http status [200 OK], body [[{\"data\":null}]]", err.Error()) + assert.Equal(t, "delete 1 failed,http status [200 OK], body [[{}]]", err.Error()) // Shutdown the helper server gracefully if err := helper.Shutdown(context.Background()); err != nil { panic(err) diff --git a/client/client.go b/client/client.go index 51bca74..5d63d1e 100644 --- a/client/client.go +++ b/client/client.go @@ -123,7 +123,7 @@ func (c *Client) Put(ctx context.Context, kv model.KVRequest, opts ...OpOption) } //Get get value of a key -func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*model.KVResponse, error) { +func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) (*model.KVResponse, error) { options := GetOptions{} for _, o := range opts { o(&options) @@ -131,7 +131,13 @@ func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*mod if options.Project == "" { options.Project = defaultProject } - url := fmt.Sprintf("%s/%s/%s/%s/%s", c.opts.Endpoint, version, options.Project, APIPathKV, key) + labels := "" + if len(options.Labels) != 0 { + for k, v := range options.Labels[0] { + labels = labels + k + ":" + v + "," + } + } + url := fmt.Sprintf("%s/%s/%s/%s/%s?label=%s", c.opts.Endpoint, version, options.Project, APIPathKV, key, strings.TrimSuffix(labels, ",")) h := http.Header{} resp, err := c.c.Do(ctx, "GET", url, h, nil) if err != nil { @@ -149,7 +155,7 @@ func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*mod })) return nil, fmt.Errorf("get %s failed,http status [%s], body [%s]", key, resp.Status, b) } - var kvs []*model.KVResponse + var kvs *model.KVResponse err = json.Unmarshal(b, &kvs) if err != nil { openlogging.Error("unmarshal kv failed:" + err.Error()) @@ -181,7 +187,7 @@ func (c *Client) Search(ctx context.Context, opts ...GetOption) ([]*model.KVResp if options.Labels != nil && len(options.Labels) > 0 { lableReq = strings.TrimRight(lableReq, common.QueryByLabelsCon) } - url := fmt.Sprintf("%s/%s/%s/%s?%s", c.opts.Endpoint, version, options.Project, APIPathKV, lableReq) + url := fmt.Sprintf("%s/%s/%s/%s?%s", c.opts.Endpoint, version, options.Project, "kie/summary", lableReq) h := http.Header{} resp, err := c.c.Do(ctx, "GET", url, h, nil) if err != nil { diff --git a/client/client_test.go b/client/client_test.go index eff33bb..7c58b8c 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -93,9 +93,10 @@ var _ = Describe("Client", func() { Expect(res.Project).Should(Equal("")) Expect(res.Domain).Should(Equal("")) }) - kvs, _ := c1.Get(context.TODO(), "app.properties", WithGetProject("test")) + kvs, _ := c1.Get(context.TODO(), "app.properties", + WithGetProject("test"), WithLabels(map[string]string{"service": "tester"})) It("should exactly 1 kv", func() { - Expect(len(kvs)).Should(Equal(1)) + Expect(kvs).Should(Not(BeNil())) }) }) }) @@ -111,7 +112,7 @@ var _ = Describe("Client", func() { kvBody.Value = "100s" kvBody.ValueType = "string" kvBody.Labels = make(map[string]string) - kvBody.Labels["evn"] = "test" + kvBody.Labels["env"] = "test" kv, err := client2.Put(context.TODO(), kvBody, WithProject("test")) It("should not be error", func() { Ω(err).ShouldNot(HaveOccurred()) @@ -121,9 +122,10 @@ var _ = Describe("Client", func() { Expect(kv.Project).To(Equal("")) Expect(kv.Domain).To(Equal("")) }) - kvs, err := client2.Get(context.TODO(), "time", WithGetProject("test")) + kvs, err := client2.Get(context.TODO(), "time", + WithGetProject("test"), WithLabels(map[string]string{"env": "test"})) It("should return exactly 1 kv", func() { - Expect(len(kvs)).Should(Equal(1)) + Expect(kvs).Should(Not(BeNil())) Expect(err).Should(BeNil()) }) client3, err := New(Config{ diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go index e0b65fb..4bba02f 100644 --- a/cmd/kieserver/main.go +++ b/cmd/kieserver/main.go @@ -18,6 +18,7 @@ package main import ( + "github.com/apache/servicecomb-kie/server/pubsub" "github.com/apache/servicecomb-kie/server/service" "os" @@ -34,14 +35,6 @@ const ( defaultConfigFile = "/etc/servicecomb-kie/kie-conf.yaml" ) -//ConfigFromCmd store cmd params -type ConfigFromCmd struct { - ConfigFile string -} - -//Configs is a pointer of struct ConfigFromCmd -var Configs *ConfigFromCmd - // parseConfigFromCmd func parseConfigFromCmd(args []string) (err error) { app := cli.NewApp() @@ -51,25 +44,24 @@ func parseConfigFromCmd(args []string) (err error) { cli.StringFlag{ Name: "config", Usage: "config file, example: --config=kie-conf.yaml", - Destination: &Configs.ConfigFile, + Destination: &config.Configurations.ConfigFile, Value: defaultConfigFile, }, cli.StringFlag{ Name: "name", Usage: "node name, example: --name=kie0", - Destination: &Configs.ConfigFile, + Destination: &config.Configurations.NodeName, EnvVar: "NODE_NAME", }, cli.StringFlag{ Name: "peer-addr", - Usage: "peer address any node address in a cluster, example: --peer-addr=10.1.1.10:5000", - Destination: &Configs.ConfigFile, + Usage: "kie use this ip port to join a kie cluster, example: --peer-addr=10.1.1.10:5000", + Destination: &config.Configurations.PeerAddr, EnvVar: "PEER_ADDR", - }, - cli.StringFlag{ + }, cli.StringFlag{ Name: "listen-peer-addr", - Usage: "peer address, example: --listen-peer-addr=0.0.0.0:5000", - Destination: &Configs.ConfigFile, + Usage: "listen on ip port, kie receive events example: --listen-peer-addr=10.1.1.10:5000", + Destination: &config.Configurations.ListenPeerAddr, EnvVar: "LISTEN_PEER_ADDR", }, } @@ -81,13 +73,8 @@ func parseConfigFromCmd(args []string) (err error) { return } -//Init get config and parses those command -func Init() error { - Configs = &ConfigFromCmd{} - return parseConfigFromCmd(os.Args) -} func main() { - if err := Init(); err != nil { + if err := parseConfigFromCmd(os.Args); err != nil { openlogging.Fatal(err.Error()) } chassis.RegisterSchema("rest", &v1.KVResource{}) @@ -95,12 +82,14 @@ func main() { if err := chassis.Init(); err != nil { openlogging.Fatal(err.Error()) } - if err := config.Init(Configs.ConfigFile); err != nil { + if err := config.Init(); err != nil { openlogging.Fatal(err.Error()) } if err := service.DBInit(); err != nil { openlogging.Fatal(err.Error()) } + pubsub.Init() + pubsub.Start() if err := chassis.Run(); err != nil { openlogging.Fatal("service exit: " + err.Error()) } diff --git a/go.mod b/go.mod index 39f57e5..3e2ae1e 100644 --- a/go.mod +++ b/go.mod @@ -3,21 +3,21 @@ module github.com/apache/servicecomb-kie require ( github.com/emicklei/go-restful v2.11.1+incompatible github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4 - github.com/go-chassis/go-archaius v0.24.0 - github.com/go-chassis/go-chassis v1.7.6 - github.com/go-chassis/go-chassis-config v0.15.0 - github.com/go-chassis/go-restful-swagger20 v1.0.2-0.20191118130439-7eec0f2639f6 // indirect - github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2 + github.com/go-chassis/go-archaius v1.0.0 + github.com/go-chassis/go-chassis v1.8.2-0.20191227102336-e3ac2ea137b1 + github.com/go-chassis/paas-lager v1.1.1 github.com/go-mesh/openlogging v1.0.1 github.com/golang/snappy v0.0.1 // indirect - github.com/onsi/ginkgo v1.8.0 - github.com/onsi/gomega v1.5.0 - github.com/stretchr/testify v1.3.0 + github.com/hashicorp/serf v0.8.5 + github.com/onsi/ginkgo v1.10.1 + github.com/onsi/gomega v1.7.0 + github.com/satori/go.uuid v1.2.0 + github.com/stretchr/testify v1.4.0 github.com/urfave/cli v1.20.0 github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect github.com/xdg/stringprep v1.0.0 // indirect go.mongodb.org/mongo-driver v1.0.3 - gopkg.in/yaml.v2 v2.2.1 + gopkg.in/yaml.v2 v2.2.4 ) go 1.13 diff --git a/go.sum b/go.sum index 8181297..bdf601c 100644 --- a/go.sum +++ b/go.sum @@ -1,90 +1,193 @@ +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= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= +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 h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/cenkalti/backoff v2.0.0+incompatible h1:5IIPUHhlnUZbcHQsQou5k1Tn58nJkeJL9U+ig5CHJbY= github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/emicklei/go-restful v2.8.0+incompatible h1:wN8GCRDPGHguIynsnBartv5GUgGUg1LAU7+xnSn1j7Q= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.8.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.11.1+incompatible h1:CjKsv3uWcCMvySPQYKxO8XX3f9zD4FeZRsW4G0B4ffE= github.com/emicklei/go-restful v2.11.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-chassis/foundation v0.0.0-20190621030543-c3b63f787f4c h1:p+Y6yq7RwHmYjEr/vwdVYGacBqFCc2lPQfNRIC3vRIs= -github.com/go-chassis/foundation v0.0.0-20190621030543-c3b63f787f4c/go.mod h1:21/ajGtgJlWTCeM0TxGJdRhO8bJkKirWyV8Stlh6g6c= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chassis/foundation v0.1.0/go.mod h1:21/ajGtgJlWTCeM0TxGJdRhO8bJkKirWyV8Stlh6g6c= github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4 h1:wx8JXvg/n4i8acXsBJ5zIkiK7EO2kn/HuEjKK3kSgv8= github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4/go.mod h1:21/ajGtgJlWTCeM0TxGJdRhO8bJkKirWyV8Stlh6g6c= -github.com/go-chassis/go-archaius v0.24.0 h1:ubNgs3Rv067PI7t37ZJoIMaPPHIBWV+ni/e7XAdW1hU= -github.com/go-chassis/go-archaius v0.24.0/go.mod h1:5kKZrxGYvKNorKamngLdPe3vVasAtIeB5vDcAv8Vg9I= -github.com/go-chassis/go-chassis v1.7.3-0.20191018125535-1a99ab41f7ea h1:Gm7df0N6uafuCCPvdMrihLvzKEu4Xl6yd2QYmqj2UG0= -github.com/go-chassis/go-chassis v1.7.3-0.20191018125535-1a99ab41f7ea/go.mod h1:Zdiwu/crt8XWcwWJOu9MoE3Ld0KHJwSPtAkEHYlOErI= -github.com/go-chassis/go-chassis v1.7.4-0.20191029093300-ce79305826f9 h1:IqUVYJ7/VNvIn+OzZ8+H1lCONQpFSBdZPBguBwanKso= -github.com/go-chassis/go-chassis v1.7.4-0.20191029093300-ce79305826f9/go.mod h1:QJGDHyfKjt1gZjMXfdUbl+TJkOcdn7WuZpPjzRWbn+8= -github.com/go-chassis/go-chassis v1.7.4-0.20191031115844-2d2fe55920d0 h1:jgfAkHzGcoq+6OOMihP4z0nFC76C0oWHwru2t2tHN9A= -github.com/go-chassis/go-chassis v1.7.4-0.20191031115844-2d2fe55920d0/go.mod h1:QJGDHyfKjt1gZjMXfdUbl+TJkOcdn7WuZpPjzRWbn+8= -github.com/go-chassis/go-chassis v1.7.6 h1:z6DxdoYxOjwQMilxCsl4XsscLzmXCYjOqlBpK2kgrv4= -github.com/go-chassis/go-chassis v1.7.6/go.mod h1:AjWYNxGhVZznFNlq+ggHkpVisJahPoDn3iKAJtQZBG0= -github.com/go-chassis/go-chassis-config v0.14.0 h1:OnM9sx2GalDC7vEIhPecRpQlVa8hz10NOB41+9tii5A= -github.com/go-chassis/go-chassis-config v0.14.0/go.mod h1:qzvK/aoAv0O/khmF6ehW6RgELrF1JR2F555T9izoo2A= +github.com/go-chassis/go-archaius v1.0.0 h1:grSgvtpJsyYk0+1UiSqShF6+Zv0L6SWdsOUNi49bVTQ= +github.com/go-chassis/go-archaius v1.0.0/go.mod h1:Px2evF91zbMr78UQ+lwehjEwXelwgvTtHzIeODsBEEE= +github.com/go-chassis/go-chassis v1.8.1 h1:YWCrVRwPHy2/JIxa3jUxjISH1Z9y93SvUuAkwXVC6kk= +github.com/go-chassis/go-chassis v1.8.1/go.mod h1:vI0rU2FNAtGi6owfYKXBVj6cvq633/n+8bqbsVfib7E= +github.com/go-chassis/go-chassis v1.8.2-0.20191227102336-e3ac2ea137b1 h1:7cVyV9MzmpzCPobya0nlxAkUTLPpT3iGmnvCAu5R/gE= +github.com/go-chassis/go-chassis v1.8.2-0.20191227102336-e3ac2ea137b1/go.mod h1:vI0rU2FNAtGi6owfYKXBVj6cvq633/n+8bqbsVfib7E= github.com/go-chassis/go-chassis-config v0.15.0 h1:cTsUl7r3eo2tFoACHADnymwO/5ebb6RVNTj11kxjiZ8= github.com/go-chassis/go-chassis-config v0.15.0/go.mod h1:yuaprnRdObPhYaHVKaocBQPoLfoBFaFmzApM2nRROws= -github.com/go-chassis/go-restful-swagger20 v1.0.1 h1:HdGto0xroWGK504XN0Um7JBc0OPMHDlWwedkd2mTGII= -github.com/go-chassis/go-restful-swagger20 v1.0.1/go.mod h1:s+06mcAnGsVYQ2sqM4ZPiMJeRj7BTeAM/4gkhZNcsjA= -github.com/go-chassis/go-restful-swagger20 v1.0.2-0.20191029071646-8c0119f661c5 h1:jlUonIaxwdVZrP27t2mPKHDuBz913nXznn4dOtvHzPg= -github.com/go-chassis/go-restful-swagger20 v1.0.2-0.20191029071646-8c0119f661c5/go.mod h1:s+06mcAnGsVYQ2sqM4ZPiMJeRj7BTeAM/4gkhZNcsjA= -github.com/go-chassis/go-restful-swagger20 v1.0.2-0.20191118130439-7eec0f2639f6 h1:zuva9KaX7UrWLo9oNHUQZgX6zb70RY5xvtie17PlZpE= -github.com/go-chassis/go-restful-swagger20 v1.0.2-0.20191118130439-7eec0f2639f6/go.mod h1:s+06mcAnGsVYQ2sqM4ZPiMJeRj7BTeAM/4gkhZNcsjA= -github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2 h1:iORWPbIQ81tJPKWs9TNvcjCQnqvyTlL41F9ILgiTcyM= +github.com/go-chassis/go-restful-swagger20 v1.0.2 h1:Zq74EQP7IjlJK/PnYP/rF3Ptk2QskZVPoNgiVwtvpFM= +github.com/go-chassis/go-restful-swagger20 v1.0.2/go.mod h1:ZK4hlfS6Q6E46ViezAjn6atrzoteyWl1OBEpUBn/36k= github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2/go.mod h1:tILYbn3+0jjCxhY6/ue9L8eRq+VJ60U6VYIdugqchB4= +github.com/go-chassis/paas-lager v1.1.1 h1:/6wqawUGjPCpd57A/tzJzgC4MnEhNuigbayQS+2VWPQ= +github.com/go-chassis/paas-lager v1.1.1/go.mod h1:tILYbn3+0jjCxhY6/ue9L8eRq+VJ60U6VYIdugqchB4= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-mesh/openlogging v1.0.1 h1:6raaXo8SK+wuQX1VoNi6QJCSf1fTOFWh7f5f6b2ZEmY= github.com/go-mesh/openlogging v1.0.1/go.mod h1:qaKi+amO+hsGin2q1GmW+/NcbZpMPnTufwrWzDmIuuU= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +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/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= +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/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= +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.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1 h1:sNCoNyDEvN1xa+X0baata4RdcpKwcMS6DH+xwfqPgjw= +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 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0 h1:WhIgCr5a7AaVH6jPUwjtRuuE7/RDufnUvzIr48smyxs= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3 h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.5 h1:ZynDUIQiA8usmRgPdGPHFdPnb1wgGI9tK3mO9hcAJjc= +github.com/hashicorp/serf v0.8.5/go.mod h1:UpNcs7fFbpKIyZaUuSW6EPiH+eZC7OuyFD+wc1oal+k= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 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/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/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/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 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/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee h1:kK7VuFVykgt0LfMSloWYjDOt4TnOcL0AxF0/rDq2VkM= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/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-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1 h1:K47Rk0v/fkEfwfQet2KWhscE0cJzjgCCDBG2KHZoVno= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -95,17 +198,27 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 h1:/K3IL0Z1quvmJ7X0A1AwNEK7CRkVK3YwfOU/QAL4WGg= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.2.0 h1:HHl1DSRbEQN2i8tJmtS6ViPyHx35+p51amrdsiTCrkg= github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= +github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 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/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= @@ -114,32 +227,100 @@ github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= go.mongodb.org/mongo-driver v1.0.3 h1:GKoji1ld3tw2aC+GX1wbr/J2fX13yNacEYoJ8Nhr0yU= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.uber.org/ratelimit v0.1.0 h1:U2AruXqeTb4Eh9sYQSTrMhH8Cb7M0Ian2ibBOnBcnAw= -go.uber.org/ratelimit v0.1.0/go.mod h1:2X8KaoNd1J0lZV+PxJk/5+DGbO/tpwLR1m++a7FnB/Y= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/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-20190820162420-60c769a6c586 h1:7KByu05hhLed2MO29w7p1XfZvZ13m8mub3shuVftRs0= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +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/net v0.0.0-20170114055629-f2499483f923/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-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/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-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-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +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/oauth2 v0.0.0-20190604053449-0f29369cfe45/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 h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= 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 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +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-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190209173611-3b5209105503/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6rX82//Yeok1vMlizfQ= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/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-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.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-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 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/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= 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 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= +k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo= +k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= +k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg= +k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= +k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6 h1:p0Ai3qVtkbCG/Af26dBmU0E1W58NID3hSSh7cMyylpM= +k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/pkg/common/common.go b/pkg/common/common.go index 01253e2..05b7ae3 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -21,13 +21,14 @@ package common const ( QueryParamQ = "q" QueryByLabelsCon = "&" + QueryParamWait = "wait" ) //http headers const ( HeaderMatch = "X-Match" HeaderDepth = "X-Depth" - HeaderTenant = "X-Domain-Name" + HeaderTenant = "X-Domain" HeaderContentType = "Content-Type" HeaderAccept = "Accept" ) diff --git a/pkg/model/kv.go b/pkg/model/kv.go index f603fe8..a9a8952 100644 --- a/pkg/model/kv.go +++ b/pkg/model/kv.go @@ -32,7 +32,7 @@ type KVResponse struct { PageNum int `json:"num,omitempty"` Size int `json:"size,omitempty"` Total int `json:"total,omitempty"` - Data []*KVDoc `json:"data"` + Data []*KVDoc `json:"data,omitempty"` } //LabelDocResponse is label struct diff --git a/server/config/config.go b/server/config/config.go index de573d0..37ebaaf 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -25,16 +25,15 @@ import ( ) //Configurations is kie config items -var Configurations *Config +var Configurations = &Config{} //Init initiate config files -func Init(file string) error { - if err := archaius.AddFile(file, archaius.WithFileHandler(util.UseFileNameAsKeyContentAsValue)); err != nil { +func Init() error { + if err := archaius.AddFile(Configurations.ConfigFile, archaius.WithFileHandler(util.UseFileNameAsKeyContentAsValue)); err != nil { return err } - _, filename := filepath.Split(file) + _, filename := filepath.Split(Configurations.ConfigFile) content := archaius.GetString(filename, "") - Configurations = &Config{} return yaml.Unmarshal([]byte(content), Configurations) } diff --git a/server/config/config_test.go b/server/config/config_test.go index 75ca3ae..427118b 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -44,7 +44,8 @@ db: assert.NoError(t, err) _, err = io.WriteString(f1, string(b)) assert.NoError(t, err) - err = config.Init("test.yaml") + config.Configurations.ConfigFile = "test.yaml" + err = config.Init() assert.NoError(t, err) assert.Equal(t, 10, config.GetDB().PoolSize) assert.Equal(t, "mongodb://admin:123@127.0.0.1:27017/kie", config.GetDB().URI) diff --git a/server/config/struct.go b/server/config/struct.go index d3ad4da..c3c32a4 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -20,6 +20,13 @@ package config //Config is yaml file struct type Config struct { DB DB `yaml:"db"` + + //config from cli + ConfigFile string + NodeName string + ListenPeerAddr string + PeerAddr string + AdvertiseAddr string } //DB is yaml file struct to set mongodb config diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go new file mode 100644 index 0000000..a67ca8f --- /dev/null +++ b/server/pubsub/bus.go @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pubsub + +import ( + "encoding/json" + "github.com/apache/servicecomb-kie/server/config" + "github.com/go-mesh/openlogging" + "github.com/hashicorp/serf/cmd/serf/command/agent" + "github.com/hashicorp/serf/serf" + "sync" +) + +var once sync.Once +var bus *Bus + +//const +const ( + EventKVChange = "kv-changed" +) + +var mutexObservers sync.RWMutex +var topics sync.Map + +//Bus is message bug +type Bus struct { + agent *agent.Agent +} + +//Init create serf agent +func Init() { + once.Do(func() { + ac := agent.DefaultConfig() + if config.Configurations.ListenPeerAddr != "" { + ac.BindAddr = config.Configurations.ListenPeerAddr + } + if config.Configurations.AdvertiseAddr != "" { + ac.AdvertiseAddr = config.Configurations.AdvertiseAddr + } + sc := serf.DefaultConfig() + if config.Configurations.NodeName != "" { + sc.NodeName = config.Configurations.NodeName + } + ac.UserEventSizeLimit = 512 + a, err := agent.Create(ac, sc, nil) + if err != nil { + openlogging.Fatal("can not sync key value change events to other kie nodes:" + err.Error()) + } + bus = &Bus{ + agent: a, + } + if config.Configurations.PeerAddr != "" { + err := join([]string{config.Configurations.PeerAddr}) + if err != nil { + openlogging.Fatal("lost event message") + } else { + openlogging.Info("join kie node:" + config.Configurations.PeerAddr) + } + } + }) +} + +//Start start serf agent +func Start() { + err := bus.agent.Start() + if err != nil { + openlogging.Fatal("can not sync key value change events to other kie nodes" + err.Error()) + } + openlogging.Info("kie message bus started") + bus.agent.RegisterEventHandler(&EventHandler{}) +} +func join(addresses []string) error { + _, err := bus.agent.Join(addresses, false) + if err != nil { + return err + } + return nil +} + +//Publish send event +func Publish(event *KVChangeEvent) error { + b, err := json.Marshal(event) + if err != nil { + return err + } + return bus.agent.UserEvent(EventKVChange, b, true) + +} + +//ObserveOnce observe key changes by (key or labels) or (key and labels) +func ObserveOnce(o *Observer, topic *Topic) error { + topic.Format() + b, err := json.Marshal(topic) + if err != nil { + return err + } + t := string(b) + observers, ok := topics.Load(t) + if !ok { + topics.Store(t, map[string]*Observer{ + o.UUID: o, + }) + openlogging.Info("new topic:" + t) + return nil + } + mutexObservers.Lock() + observers.(map[string]*Observer)[o.UUID] = o + mutexObservers.Unlock() + openlogging.Debug("add new observer for topic:" + t) + return nil +} diff --git a/server/config/config_test.go b/server/pubsub/bus_test.go similarity index 58% copy from server/config/config_test.go copy to server/pubsub/bus_test.go index 75ca3ae..8105e2a 100644 --- a/server/config/config_test.go +++ b/server/pubsub/bus_test.go @@ -15,37 +15,43 @@ * limitations under the License. */ -package config_test +package pubsub_test import ( "github.com/apache/servicecomb-kie/server/config" - "github.com/go-chassis/go-archaius" - "github.com/stretchr/testify/assert" - "io" - "os" + "github.com/apache/servicecomb-kie/server/pubsub" + uuid "github.com/satori/go.uuid" "testing" ) func TestInit(t *testing.T) { - err := archaius.Init() - assert.NoError(t, err) - b := []byte(` -db: - uri: mongodb://admin:123@127.0.0.1:27017/kie - type: mongodb - poolSize: 10 - ssl: false - sslCA: - sslCert: + config.Configurations = &config.Config{} + pubsub.Init() + pubsub.Start() -`) - defer os.Remove("test.yaml") - f1, err := os.Create("test.yaml") - assert.NoError(t, err) - _, err = io.WriteString(f1, string(b)) - assert.NoError(t, err) - err = config.Init("test.yaml") - assert.NoError(t, err) - assert.Equal(t, 10, config.GetDB().PoolSize) - assert.Equal(t, "mongodb://admin:123@127.0.0.1:27017/kie", config.GetDB().URI) + o := &pubsub.Observer{ + UUID: uuid.NewV4().String(), + Event: make(chan *pubsub.KVChangeEvent, 1), + } + _ = pubsub.ObserveOnce(o, &pubsub.Topic{ + Key: "some_key", + Project: "1", + DomainID: "2", + Labels: map[string]string{ + "a": "b", + "c": "d", + }, + }) + _ = pubsub.Publish(&pubsub.KVChangeEvent{ + Key: "some_key", + Action: "put", + Labels: map[string]string{ + "a": "b", + "c": "d", + }, + Project: "1", + DomainID: "2", + }) + e := <-o.Event + t.Log(e.Key) } diff --git a/server/pubsub/event_handler.go b/server/pubsub/event_handler.go new file mode 100644 index 0000000..338c5a7 --- /dev/null +++ b/server/pubsub/event_handler.go @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pubsub + +import ( + "github.com/go-mesh/openlogging" + "github.com/hashicorp/serf/serf" + "strings" +) + +//EventHandler handler serf custom event +type EventHandler struct { +} + +//HandleEvent send event to subscribers +func (h *EventHandler) HandleEvent(e serf.Event) { + openlogging.Info("receive event:" + e.EventType().String()) + switch e.EventType().String() { + case "user": + if strings.Contains(e.String(), EventKVChange) { + ue := e.(serf.UserEvent) + ke, err := NewKVChangeEvent(ue.Payload) + if err != nil { + openlogging.Error("invalid json:" + string(ue.Payload)) + } + openlogging.Debug("kv event:" + ke.Key) + topics.Range(func(key, value interface{}) bool { //range all topics + t, err := ParseTopicString(key.(string)) + if err != nil { + openlogging.Error("can not parse topic:" + key.(string)) + return true + } + if t.Match(ke) { + observers := value.(map[string]*Observer) + mutexObservers.Lock() + defer mutexObservers.Unlock() + for k, v := range observers { + v.Event <- ke + delete(observers, k) + } + } + return true + }) + } + + } + +} diff --git a/server/resource/v1/v1_suite_test.go b/server/pubsub/options.go similarity index 77% copy from server/resource/v1/v1_suite_test.go copy to server/pubsub/options.go index 422226d..87e7757 100644 --- a/server/resource/v1/v1_suite_test.go +++ b/server/pubsub/options.go @@ -15,19 +15,11 @@ * limitations under the License. */ -package v1_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - _ "github.com/apache/servicecomb-kie/server/service/mongo" -) - -func TestV1(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "V1 Suite") +package pubsub +//Options is serf options +type Options struct { + BindAddr string + AdvertiseAddr string + RPCAddr string } diff --git a/server/pubsub/struct.go b/server/pubsub/struct.go new file mode 100644 index 0000000..3cb3449 --- /dev/null +++ b/server/pubsub/struct.go @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pubsub + +import ( + "encoding/json" + "errors" + "sort" + "strings" +) + +//KVChangeEvent is event between kie nodes, and broadcast by serf +type KVChangeEvent struct { + Key string + Action string //include: put,delete + Labels map[string]string + DomainID string + Project string +} + +//NewKVChangeEvent create a struct base on event payload +func NewKVChangeEvent(payload []byte) (*KVChangeEvent, error) { + ke := &KVChangeEvent{} + err := json.Unmarshal(payload, ke) + return ke, err +} + +//Topic can be subscribe +type Topic struct { + Key string `json:"key,omitempty"` + Labels map[string]string `json:"-"` + LabelsFormat string `json:"labels,omitempty"` + DomainID string `json:"domainID,omitempty"` + Project string `json:"project,omitempty"` +} + +//ParseTopicString parse topic string to topic struct +func ParseTopicString(s string) (*Topic, error) { + t := &Topic{ + Labels: make(map[string]string), + } + err := json.Unmarshal([]byte(s), t) + if err != nil { + return nil, err + } + ls := strings.Split(t.LabelsFormat, "::") + if len(ls) != 0 { + for _, l := range ls { + s := strings.Split(l, "=") + if len(s) != 2 { + return nil, errors.New("invalid label:" + l) + } + t.Labels[s[0]] = s[1] + } + } + return t, err +} + +//Match compare event with topic +func (t *Topic) Match(event *KVChangeEvent) bool { + match := false + if t.Key != "" { + if t.Key == event.Key { + match = true + } + } + for k, v := range t.Labels { + if event.Labels[k] != v { + return false + } + match = true + } + return match +} + +//Format format to string +func (t *Topic) Format() string { + sb := strings.Builder{} + s := make([]string, 0, len(t.Labels)) + for k := range t.Labels { + s = append(s, k) + } + sort.Strings(s) + for i, k := range s { + sb.WriteString(k) + sb.WriteString("=") + sb.WriteString(t.Labels[k]) + if i != (len(s) - 1) { + sb.WriteString("::") + } + } + t.LabelsFormat = sb.String() + return t.LabelsFormat +} + +//Observer represents a client polling request +type Observer struct { + UUID string + RemoteIP string + UserAgent string + Event chan *KVChangeEvent +} diff --git a/server/resource/v1/v1_suite_test.go b/server/pubsub/struct_test.go similarity index 54% copy from server/resource/v1/v1_suite_test.go copy to server/pubsub/struct_test.go index 422226d..6ce46f9 100644 --- a/server/resource/v1/v1_suite_test.go +++ b/server/pubsub/struct_test.go @@ -15,19 +15,42 @@ * limitations under the License. */ -package v1_test +package pubsub_test import ( + "encoding/json" + "github.com/apache/servicecomb-kie/server/pubsub" "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - _ "github.com/apache/servicecomb-kie/server/service/mongo" ) -func TestV1(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "V1 Suite") +func TestTopic_String(t *testing.T) { + topic := &pubsub.Topic{ + Key: "test", + Labels: map[string]string{ + "a": "b", + "c": "d", + }, + } + t.Log(topic) + b, _ := json.Marshal(topic) + t.Log(string(b)) + topic = &pubsub.Topic{ + Labels: map[string]string{ + "a": "b", + "c": "d", + }, + } + t.Log(topic) + b, _ = json.Marshal(topic) + t.Log(string(b)) + topic = &pubsub.Topic{ + Key: "test", + } + t.Log(topic) + b, _ = json.Marshal(topic) + t.Log(string(b)) + mock := []byte(`{"key":"some_key","labels":"a=b::c=d","domainID":"2","project":"1"}`) + topic, _ = pubsub.ParseTopicString(string(mock)) + t.Log(topic) } diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go index 7207a53..8bb3f1c 100644 --- a/server/resource/v1/common.go +++ b/server/resource/v1/common.go @@ -21,9 +21,12 @@ import ( "encoding/json" "errors" "fmt" + "github.com/apache/servicecomb-kie/server/pubsub" + uuid "github.com/satori/go.uuid" "net/http" "strconv" "strings" + "time" "github.com/apache/servicecomb-kie/pkg/common" "github.com/apache/servicecomb-kie/pkg/model" @@ -37,9 +40,10 @@ import ( //const of server const ( MsgDomainMustNotBeEmpty = "domain must not be empty" - MsgIllegalLabels = "label's value can not be empty, " + - "label can not be duplicated, please check your query parameters" + MsgIllegalLabels = "label value can not be empty, " + + "label can not be duplicated, please check query parameters" MsgIllegalDepth = "X-Depth must be number" + MsgInvalidWait = "wait param should be formed with number and time unit like 5s,100ms, and less than 5m" ErrKvIDMustNotEmpty = "must supply kv id if you want to remove key" ) @@ -105,7 +109,7 @@ func ErrLog(action string, kv *model.KVDoc, err error) { //InfoLog record info func InfoLog(action string, kv *model.KVDoc) { openlogging.Info( - fmt.Sprintf("[%s] [%s:%s] in [%s] success", action, kv.Key, kv.Value, kv.Domain)) + fmt.Sprintf("[%s] [%s] success", action, kv.Key)) } func readRequest(ctx *restful.Context, v interface{}) error { @@ -131,3 +135,64 @@ func writeResponse(ctx *restful.Context, v interface{}) error { } return ctx.WriteJSON(v, goRestful.MIME_JSON) // json is default } +func getLabels(labelStr string) (map[string]string, error) { + labelsSlice := strings.Split(labelStr, ",") + labels := make(map[string]string, len(labelsSlice)) + for _, v := range labelsSlice { + v := strings.Split(v, ":") + if len(v) != 2 { + return nil, errors.New(MsgIllegalLabels) + } + labels[v[0]] = v[1] + } + return labels, nil +} +func wait(d time.Duration, rctx *restful.Context, topic *pubsub.Topic) bool { + result := true + if d != 0 { + o := &pubsub.Observer{ + UUID: uuid.NewV4().String(), + RemoteIP: rctx.ReadRequest().RemoteAddr, + UserAgent: rctx.ReadHeader("User-Agent"), + Event: make(chan *pubsub.KVChangeEvent, 1), + } + pubsub.ObserveOnce(o, topic) + select { + case <-time.After(d): + result = false + case <-o.Event: + } + } + return result +} +func getWaitDuration(rctx *restful.Context) string { + wait := rctx.ReadQueryParameter(common.QueryParamWait) + if wait == "" { + wait = "0s" + } + return wait +} +func checkPagination(limitStr, offsetStr string) (int64, int64, error) { + var err error + var limit, offset int64 + if limitStr != "" { + limit, err = strconv.ParseInt(limitStr, 10, 64) + if err != nil { + return 0, 0, err + } + if limit < 1 || limit > 50 { + return 0, 0, errors.New("invalid limit number") + } + } + + if offsetStr != "" { + offset, err = strconv.ParseInt(offsetStr, 10, 64) + if err != nil { + return 0, 0, errors.New("invalid offset number") + } + if offset < 1 { + return 0, 0, errors.New("invalid offset number") + } + } + return limit, offset, err +} diff --git a/server/resource/v1/doc_struct.go b/server/resource/v1/doc_struct.go index b0afbb0..9f008c1 100644 --- a/server/resource/v1/doc_struct.go +++ b/server/resource/v1/doc_struct.go @@ -44,6 +44,13 @@ var ( "for example: /v1/test/kie/kv?q=app:mall&q=app:mall+service:cart, " + "that will query key values from 2 kinds of labels", } + DocQueryWait = &restful.Parameters{ + DataType: "string", + Name: common.QueryParamWait, + ParamType: goRestful.QueryParameterKind, + Desc: "wait until any kv changed, for example wait=5s, server will not response until 5 seconds, " + + "during that time window, if any kv changed, server will response", + } DocQueryKVIDParameters = &restful.Parameters{ DataType: "string", Name: "kvID", @@ -58,9 +65,9 @@ var ( } DocQueryLabelParameters = &restful.Parameters{ DataType: "string", - Name: "any", + Name: "label", ParamType: goRestful.QueryParameterKind, - Desc: "label pairs", + Desc: "label pairs,for example &label=service:order&label=version:1.0.0", } DocQueryLabelIDParameters = &restful.Parameters{ DataType: "string", diff --git a/server/resource/v1/kv_resource.go b/server/resource/v1/kv_resource.go index b8e2010..8c407ea 100644 --- a/server/resource/v1/kv_resource.go +++ b/server/resource/v1/kv_resource.go @@ -19,13 +19,13 @@ package v1 import ( + "github.com/apache/servicecomb-kie/server/pubsub" "net/http" - "strconv" + "time" "github.com/apache/servicecomb-kie/pkg/common" "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/server/service" - goRestful "github.com/emicklei/go-restful" "github.com/go-chassis/go-chassis/server/restful" "github.com/go-mesh/openlogging" @@ -58,6 +58,16 @@ func (r *KVResource) Put(context *restful.Context) { WriteErrResponse(context, http.StatusInternalServerError, err.Error(), common.ContentTypeText) return } + err = pubsub.Publish(&pubsub.KVChangeEvent{ + Key: kv.Key, + Labels: kv.Labels, + Project: project, + DomainID: kv.Domain, + Action: "put", + }) + if err != nil { + openlogging.Warn("lost kv change event:" + err.Error()) + } InfoLog("put", kv) err = writeResponse(context, kv) if err != nil { @@ -67,97 +77,117 @@ func (r *KVResource) Put(context *restful.Context) { } //GetByKey search key by label and key -func (r *KVResource) GetByKey(context *restful.Context) { +func (r *KVResource) GetByKey(rctx *restful.Context) { var err error - key := context.ReadPathParameter("key") + key := rctx.ReadPathParameter("key") if key == "" { - WriteErrResponse(context, http.StatusBadRequest, "key must not be empty", common.ContentTypeText) + WriteErrResponse(rctx, http.StatusBadRequest, "key must not be empty", common.ContentTypeText) return } - project := context.ReadPathParameter("project") - values := context.ReadRequest().URL.Query() - labels := make(map[string]string, len(values)) - for k, v := range values { - if len(v) != 1 { - WriteErrResponse(context, http.StatusBadRequest, MsgIllegalLabels, common.ContentTypeText) + project := rctx.ReadPathParameter("project") + labelStr := rctx.ReadQueryParameter("label") + var labels map[string]string + if labelStr != "" { + labels, err = getLabels(labelStr) + if err != nil { + WriteErrResponse(rctx, http.StatusBadRequest, MsgIllegalLabels, common.ContentTypeText) return } - labels[k] = v[0] } - domain := ReadDomain(context) + domain := ReadDomain(rctx) if domain == nil { - WriteErrResponse(context, http.StatusInternalServerError, MsgDomainMustNotBeEmpty, common.ContentTypeText) + WriteErrResponse(rctx, http.StatusInternalServerError, MsgDomainMustNotBeEmpty, common.ContentTypeText) return } - d, err := ReadFindDepth(context) - if err != nil { - WriteErrResponse(context, http.StatusBadRequest, MsgIllegalDepth, common.ContentTypeText) + waitStr := getWaitDuration(rctx) + d, err := time.ParseDuration(waitStr) + if err != nil || d > 5*time.Minute { + WriteErrResponse(rctx, http.StatusBadRequest, MsgInvalidWait, common.ContentTypeText) return } - kvs, err := service.KVService.FindKV(context.Ctx, domain.(string), project, - service.WithKey(key), service.WithLabels(labels), service.WithDepth(d)) - if err != nil { - if err == service.ErrKeyNotExists { - WriteErrResponse(context, http.StatusNotFound, err.Error(), common.ContentTypeText) + changed := wait(d, rctx, &pubsub.Topic{ + Key: key, + Labels: labels, + Project: project, + DomainID: domain.(string), + }) + if changed { + kv, err := service.KVService.List(rctx.Ctx, domain.(string), project, + key, labels, 0, 0) + if err != nil { + if err == service.ErrKeyNotExists { + WriteErrResponse(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText) + return + } + WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText) return } - WriteErrResponse(context, http.StatusInternalServerError, err.Error(), common.ContentTypeText) + err = writeResponse(rctx, kv) + if err != nil { + openlogging.Error(err.Error()) + } return } - err = writeResponse(context, kvs) - if err != nil { - openlogging.Error(err.Error()) - } - + rctx.WriteHeader(http.StatusNotModified) } //List TODO pagination func (r *KVResource) List(rctx *restful.Context) { + var err error project := rctx.ReadPathParameter("project") domain := ReadDomain(rctx) if domain == nil { WriteErrResponse(rctx, http.StatusInternalServerError, MsgDomainMustNotBeEmpty, common.ContentTypeText) return } - var limit int64 = 20 - var offset int64 = 0 - labels := make(map[string]string, 0) - var err error - for k, v := range rctx.ReadRequest().URL.Query() { - if k == "limit" { - limit, err = strconv.ParseInt(v[0], 10, 64) - if err != nil { - WriteErrResponse(rctx, http.StatusBadRequest, "invalid limit number", common.ContentTypeText) - } - if limit < 1 || limit > 50 { - WriteErrResponse(rctx, http.StatusBadRequest, "invalid limit number", common.ContentTypeText) - } - continue - } - if k == "offset" { - offset, err = strconv.ParseInt(v[0], 10, 64) - if err != nil { - WriteErrResponse(rctx, http.StatusBadRequest, "invalid offset number", common.ContentTypeText) - } - if offset < 1 { - WriteErrResponse(rctx, http.StatusBadRequest, "invalid offset number", common.ContentTypeText) - } - continue + labelStr := rctx.ReadQueryParameter("label") + var labels map[string]string + if labelStr != "" { + labels, err = getLabels(labelStr) + if err != nil { + WriteErrResponse(rctx, http.StatusBadRequest, MsgIllegalLabels, common.ContentTypeText) + return } - labels[k] = v[0] } - result, err := service.KVService.List(rctx.Ctx, domain.(string), project, "", labels, int(limit), int(offset)) + limitStr := rctx.ReadPathParameter("limit") + offsetStr := rctx.ReadPathParameter("offset") + limit, offset, err := checkPagination(limitStr, offsetStr) if err != nil { - openlogging.Error("can not find by labels", openlogging.WithTags(openlogging.Tags{ - "err": err.Error(), - })) - WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText) + WriteErrResponse(rctx, http.StatusBadRequest, err.Error(), common.ContentTypeText) return } - err = writeResponse(rctx, result) - if err != nil { - openlogging.Error(err.Error()) + waitStr := getWaitDuration(rctx) + d, err := time.ParseDuration(waitStr) + if err != nil || d > 5*time.Minute { + WriteErrResponse(rctx, http.StatusBadRequest, MsgInvalidWait, common.ContentTypeText) + return } + changed := wait(d, rctx, &pubsub.Topic{ + Labels: labels, + Project: project, + DomainID: domain.(string), + }) + if changed { + result, err := service.KVService.List(rctx.Ctx, domain.(string), project, "", labels, int(limit), int(offset)) + if err != nil { + if err == service.ErrKeyNotExists { + WriteErrResponse(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText) + return + } + openlogging.Error("can not find by labels", openlogging.WithTags(openlogging.Tags{ + "err": err.Error(), + })) + WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText) + return + } + err = writeResponse(rctx, result) + if err != nil { + openlogging.Error(err.Error()) + } + return + } + rctx.WriteHeader(http.StatusNotModified) + } //Search search key only by label @@ -270,7 +300,6 @@ func (r *KVResource) URLPatterns() []restful.Route { FuncDesc: "get key values by key and labels", Parameters: []*restful.Parameters{ DocPathProject, DocPathKey, - DocHeaderDepth, DocQueryLabelParameters, }, Returns: []*restful.Returns{ @@ -284,9 +313,9 @@ func (r *KVResource) URLPatterns() []restful.Route { Produces: []string{goRestful.MIME_JSON, common.ContentTypeYaml}, }, { Method: http.MethodGet, - Path: "/v1/{project}/kie/kv", + Path: "/v1/{project}/kie/summary", ResourceFunc: r.Search, - FuncDesc: "search key values by labels combination", + FuncDesc: "search key values by labels combination, it returns multiple labels group", Parameters: []*restful.Parameters{ DocPathProject, DocQueryCombination, }, @@ -301,11 +330,11 @@ func (r *KVResource) URLPatterns() []restful.Route { Produces: []string{goRestful.MIME_JSON, common.ContentTypeYaml}, }, { Method: http.MethodGet, - Path: "/v1/{project}/kie/kv:list", + Path: "/v1/{project}/kie/kv", ResourceFunc: r.List, FuncDesc: "list key values by labels and key", Parameters: []*restful.Parameters{ - DocPathProject, DocQueryLabelParameters, + DocPathProject, DocQueryLabelParameters, DocQueryWait, }, Returns: []*restful.Returns{ { diff --git a/server/resource/v1/kv_resource_test.go b/server/resource/v1/kv_resource_test.go index 5fe878b..dc1de85 100644 --- a/server/resource/v1/kv_resource_test.go +++ b/server/resource/v1/kv_resource_test.go @@ -20,9 +20,11 @@ package v1_test import ( "bytes" "encoding/json" + "github.com/apache/servicecomb-kie/server/pubsub" "github.com/apache/servicecomb-kie/server/service" + log "github.com/go-chassis/paas-lager" + "github.com/go-mesh/openlogging" "io/ioutil" - "log" "net/http" "net/http/httptest" @@ -40,19 +42,30 @@ import ( ) var _ = Describe("v1 kv resource", func() { + log.Init(log.Config{ + Writers: []string{"stdout"}, + LoggerLevel: "DEBUG", + LogFormatText: false, + }) + + logger := log.NewLogger("ut") + openlogging.SetLogger(logger) //for UT config.Configurations = &config.Config{ - DB: config.DB{}, + DB: config.DB{}, + ListenPeerAddr: "127.0.0.1:4000", + AdvertiseAddr: "127.0.0.1:4000", } config.Configurations.DB.URI = "mongodb://kie:123@127.0.0.1:27017" err := service.DBInit() if err != nil { panic(err) } + pubsub.Init() + pubsub.Start() Describe("put kv", func() { Context("valid param", func() { kv := &model.KVDoc{ - Key: "timeout", Value: "1s", Labels: map[string]string{"service": "tester"}, } @@ -62,10 +75,7 @@ var _ = Describe("v1 kv resource", func() { chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name()) r.Header.Set("Content-Type", "application/json") kvr := &v1.KVResource{} - c, err := restfultest.New(kvr, chain) - It("should not return error", func() { - Expect(err).Should(BeNil()) - }) + c, _ := restfultest.New(kvr, chain) resp := httptest.NewRecorder() c.ServeHTTP(resp, r) @@ -88,7 +98,7 @@ var _ = Describe("v1 kv resource", func() { }) Describe("list kv", func() { Context("with no label", func() { - r, _ := http.NewRequest("GET", "/v1/test/kie/kv:list", nil) + r, _ := http.NewRequest("GET", "/v1/test/kie/kv?label=service:tester", nil) noopH := &noop.NoopAuthHandler{} chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name()) r.Header.Set("Content-Type", "application/json") @@ -104,7 +114,6 @@ var _ = Describe("v1 kv resource", func() { It("should not return err", func() { Expect(err).Should(BeNil()) }) - log.Println(string(body)) result := &model.KVResponse{} err = json.Unmarshal(body, result) It("should not return err", func() { diff --git a/server/resource/v1/v1_suite_test.go b/server/resource/v1/v1_suite_test.go index 422226d..31569b8 100644 --- a/server/resource/v1/v1_suite_test.go +++ b/server/resource/v1/v1_suite_test.go @@ -27,6 +27,7 @@ import ( ) func TestV1(t *testing.T) { + RegisterFailHandler(Fail) RunSpecs(t, "V1 Suite") diff --git a/server/service/mongo/kv/kv_dao.go b/server/service/mongo/kv/kv_dao.go index 526efc2..207ac8a 100644 --- a/server/service/mongo/kv/kv_dao.go +++ b/server/service/mongo/kv/kv_dao.go @@ -117,8 +117,12 @@ func findKV(ctx context.Context, domain string, project string, opts service.Fin if opts.Key != "" { filter["key"] = opts.Key } - for k, v := range opts.Labels { - filter["labels."+k] = v + if len(opts.Labels) != 0 { + for k, v := range opts.Labels { + filter["labels."+k] = v + } + } else { + filter["labels"] = "" } cur, err := collection.Find(ctx, filter) diff --git a/server/service/mongo/kv/kv_service.go b/server/service/mongo/kv/kv_service.go index 6b2e86e..7f3c3b8 100644 --- a/server/service/mongo/kv/kv_service.go +++ b/server/service/mongo/kv/kv_service.go @@ -49,11 +49,6 @@ func (s *Service) CreateOrUpdate(ctx context.Context, kv *model.KVDoc) (*model.K if kv.Domain == "" { return nil, session.ErrMissingDomain } - if len(kv.Labels) == 0 { - kv.Labels = map[string]string{ - "default": "default", - } - } //check whether the project has certain labels or not labelID, err := label.Exist(ctx, kv.Domain, kv.Project, kv.Labels) @@ -205,7 +200,6 @@ func (s *Service) List(ctx context.Context, domain, project, key string, labels result := &model.KVResponse{} for cur.Next(ctx) { curKV := &model.KVDoc{} - if err := cur.Decode(curKV); err != nil { openlogging.Error("decode to KVs error: " + err.Error()) return nil, err @@ -213,6 +207,9 @@ func (s *Service) List(ctx context.Context, domain, project, key string, labels clearPart(curKV) result.Data = append(result.Data, curKV) } + if len(result.Data) == 0 { + return nil, service.ErrKeyNotExists + } return result, nil }