[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2018-02-23 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r170405906
 
 

 ##
 File path: server/broker/store.go
 ##
 @@ -0,0 +1,167 @@
+//Copyright 2017 Huawei Technologies Co., Ltd
+//
+//Licensed 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 broker
+
+import (
+   "sync"
+
+   "github.com/ServiceComb/service-center/pkg/async"
+   "github.com/ServiceComb/service-center/pkg/util"
+   sstore "github.com/ServiceComb/service-center/server/core/backend/store"
+   pb "github.com/ServiceComb/service-center/server/core/proto"
+)
+
+const (
+   PARTICIPANT sstore.StoreType = iota
+   VERSION
+   PACT
+   PACT_VERSION
+   PACT_TAG
+   VERIFICATION
+   PACT_LATEST
+   typeEnd
+)
+
+var TypeNames = []string{
+   PARTICIPANT:  "PARTICIPANT",
+   VERSION:  "VERSION",
+   PACT: "PACT",
+   PACT_VERSION: "PACT_VERSION",
+   PACT_TAG: "PACT_TAG",
+   VERIFICATION: "VERIFICATION",
+   PACT_LATEST:  "PACT_LATEST",
+}
+
+var TypeRoots = map[sstore.StoreType]string{
+   PARTICIPANT:  GetBrokerParticipantKey(""),
+   VERSION:  GetBrokerVersionKey(""),
+   PACT: GetBrokerPactKey(""),
+   PACT_VERSION: GetBrokerPactVersionKey(""),
+   PACT_TAG: GetBrokerTagKey(""),
+   VERIFICATION: GetBrokerVerificationKey(""),
+   PACT_LATEST:  GetBrokerLatestKey(""),
+}
+
+var store = {}
+
+func Store() *BKvStore {
+   return store
+}
+
+func (s *BKvStore) StoreSize(t sstore.StoreType) int {
+   return 100
+}
+
+func (s *BKvStore) dispatchEvent(t sstore.StoreType, evt *sstore.KvEvent) {
+   s.bindexers[t].OnCacheEvent(evt)
+   select {
+   case <-s.Ready():
+   default:
+   if evt.Action == pb.EVT_CREATE {
+   evt.Action = pb.EVT_INIT
+   }
+   }
+   sstore.EventProxy(t).OnEvent(evt)
 
 Review comment:
   please remove lines 71 to 78.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2017-12-22 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r158572280
 
 

 ##
 File path: server/broker/store.go
 ##
 @@ -0,0 +1,167 @@
+//Copyright 2017 Huawei Technologies Co., Ltd
+//
+//Licensed 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 broker
+
+import (
+   "sync"
+
+   "github.com/ServiceComb/service-center/pkg/async"
+   "github.com/ServiceComb/service-center/pkg/util"
+   sstore "github.com/ServiceComb/service-center/server/core/backend/store"
+   pb "github.com/ServiceComb/service-center/server/core/proto"
+)
+
+const (
+   PARTICIPANT sstore.StoreType = iota
+   VERSION
+   PACT
+   PACT_VERSION
+   PACT_TAG
+   VERIFICATION
+   PACT_LATEST
+   typeEnd
+)
+
+var TypeNames = []string{
+   PARTICIPANT:  "PARTICIPANT",
+   VERSION:  "VERSION",
+   PACT: "PACT",
+   PACT_VERSION: "PACT_VERSION",
+   PACT_TAG: "PACT_TAG",
+   VERIFICATION: "VERIFICATION",
+   PACT_LATEST:  "PACT_LATEST",
+}
+
+var TypeRoots = map[sstore.StoreType]string{
+   PARTICIPANT:  GetBrokerParticipantKey(""),
+   VERSION:  GetBrokerVersionKey(""),
+   PACT: GetBrokerPactKey(""),
+   PACT_VERSION: GetBrokerPactVersionKey(""),
+   PACT_TAG: GetBrokerTagKey(""),
+   VERIFICATION: GetBrokerVerificationKey(""),
+   PACT_LATEST:  GetBrokerLatestKey(""),
+}
+
+var store = {}
+
+func Store() *BKvStore {
+   return store
+}
+
+func (s *BKvStore) StoreSize(t sstore.StoreType) int {
+   return 100
+}
+
+func (s *BKvStore) dispatchEvent(t sstore.StoreType, evt *sstore.KvEvent) {
+   s.bindexers[t].OnCacheEvent(evt)
+   select {
+   case <-s.Ready():
+   default:
+   if evt.Action == pb.EVT_CREATE {
+   evt.Action = pb.EVT_INIT
+   }
+   }
+   sstore.EventProxy(t).OnEvent(evt)
+}
+
+func (s *BKvStore) newStore(t sstore.StoreType, opts 
...sstore.KvCacherCfgOption) {
+   opts = append(opts,
+   sstore.WithKey(TypeRoots[t]),
+   sstore.WithInitSize(s.StoreSize(t)),
+   sstore.WithEventFunc(func(evt *sstore.KvEvent) { 
s.dispatchEvent(t, evt) }),
+   )
+   s.newIndexer(t, sstore.NewKvCacher(opts...))
+}
+
+func (s *BKvStore) store() {
+   for t := sstore.StoreType(0); t != typeEnd; t++ {
+   s.newStore(t)
+   }
+   for _, i := range s.bindexers {
+   <-i.Ready()
+   }
+   util.SafeCloseChan(s.bready)
+
+   util.Logger().Debugf("all indexers are ready")
+}
+
+func init() {
+   store.Initialize()
+
+   //sstore.AddEventHandleFunc(LEASE, store.onLeaseEvent)
+}
+
+type BKvStore struct {
+   *sstore.KvStore
+   bindexers map[sstore.StoreType]*sstore.Indexer
+   basyncTaskSvc *async.AsyncTaskService
+   block sync.RWMutex
+   breadychan struct{}
+   bisClose  bool
+}
+
+func (s *BKvStore) Initialize() {
+   s.KvStore = sstore.Store()
+   s.KvStore.Initialize()
+   s.bindexers = make(map[sstore.StoreType]*sstore.Indexer)
+   s.basyncTaskSvc = async.NewAsyncTaskService()
+   s.bready = make(chan struct{})
+
+   for i := sstore.StoreType(0); i != typeEnd; i++ {
+   store.newNullStore(i)
+   }
+}
+
+func (s *BKvStore) newNullStore(t sstore.StoreType) {
+   s.newIndexer(t, sstore.NullCacher)
+}
+
+func (s *BKvStore) newIndexer(t sstore.StoreType, cacher sstore.Cacher) {
+   indexer := sstore.NewCacheIndexer(t, cacher)
+   s.bindexers[t] = indexer
+   indexer.Run()
+}
+
+func (s *BKvStore) Run() {
 
 Review comment:
   This func does not been call at all, so the cache mechanism is not work here.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2017-12-22 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r158572233
 
 

 ##
 File path: server/broker/store.go
 ##
 @@ -0,0 +1,167 @@
+//Copyright 2017 Huawei Technologies Co., Ltd
+//
+//Licensed 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 broker
+
+import (
+   "sync"
+
+   "github.com/ServiceComb/service-center/pkg/async"
+   "github.com/ServiceComb/service-center/pkg/util"
+   sstore "github.com/ServiceComb/service-center/server/core/backend/store"
+   pb "github.com/ServiceComb/service-center/server/core/proto"
+)
+
+const (
+   PARTICIPANT sstore.StoreType = iota
+   VERSION
+   PACT
+   PACT_VERSION
+   PACT_TAG
+   VERIFICATION
+   PACT_LATEST
+   typeEnd
+)
+
+var TypeNames = []string{
+   PARTICIPANT:  "PARTICIPANT",
+   VERSION:  "VERSION",
+   PACT: "PACT",
+   PACT_VERSION: "PACT_VERSION",
+   PACT_TAG: "PACT_TAG",
+   VERIFICATION: "VERIFICATION",
+   PACT_LATEST:  "PACT_LATEST",
+}
+
+var TypeRoots = map[sstore.StoreType]string{
+   PARTICIPANT:  GetBrokerParticipantKey(""),
+   VERSION:  GetBrokerVersionKey(""),
+   PACT: GetBrokerPactKey(""),
+   PACT_VERSION: GetBrokerPactVersionKey(""),
+   PACT_TAG: GetBrokerTagKey(""),
+   VERIFICATION: GetBrokerVerificationKey(""),
+   PACT_LATEST:  GetBrokerLatestKey(""),
+}
+
+var store = {}
+
+func Store() *BKvStore {
+   return store
+}
+
+func (s *BKvStore) StoreSize(t sstore.StoreType) int {
+   return 100
+}
+
+func (s *BKvStore) dispatchEvent(t sstore.StoreType, evt *sstore.KvEvent) {
+   s.bindexers[t].OnCacheEvent(evt)
+   select {
+   case <-s.Ready():
+   default:
+   if evt.Action == pb.EVT_CREATE {
+   evt.Action = pb.EVT_INIT
+   }
+   }
+   sstore.EventProxy(t).OnEvent(evt)
 
 Review comment:
   Thank you for contributing codes in service-center, I think the KVstore pkg 
is not easy to extend for contributors. So I will make it easy in the feature.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2017-12-22 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r158571645
 
 

 ##
 File path: server/broker/store.go
 ##
 @@ -0,0 +1,167 @@
+//Copyright 2017 Huawei Technologies Co., Ltd
+//
+//Licensed 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 broker
+
+import (
+   "sync"
+
+   "github.com/ServiceComb/service-center/pkg/async"
+   "github.com/ServiceComb/service-center/pkg/util"
+   sstore "github.com/ServiceComb/service-center/server/core/backend/store"
+   pb "github.com/ServiceComb/service-center/server/core/proto"
+)
+
+const (
+   PARTICIPANT sstore.StoreType = iota
+   VERSION
+   PACT
+   PACT_VERSION
+   PACT_TAG
+   VERIFICATION
+   PACT_LATEST
+   typeEnd
+)
+
+var TypeNames = []string{
+   PARTICIPANT:  "PARTICIPANT",
+   VERSION:  "VERSION",
+   PACT: "PACT",
+   PACT_VERSION: "PACT_VERSION",
+   PACT_TAG: "PACT_TAG",
+   VERIFICATION: "VERIFICATION",
+   PACT_LATEST:  "PACT_LATEST",
+}
+
+var TypeRoots = map[sstore.StoreType]string{
+   PARTICIPANT:  GetBrokerParticipantKey(""),
+   VERSION:  GetBrokerVersionKey(""),
+   PACT: GetBrokerPactKey(""),
+   PACT_VERSION: GetBrokerPactVersionKey(""),
+   PACT_TAG: GetBrokerTagKey(""),
+   VERIFICATION: GetBrokerVerificationKey(""),
+   PACT_LATEST:  GetBrokerLatestKey(""),
+}
+
+var store = {}
+
+func Store() *BKvStore {
+   return store
+}
+
+func (s *BKvStore) StoreSize(t sstore.StoreType) int {
+   return 100
+}
+
+func (s *BKvStore) dispatchEvent(t sstore.StoreType, evt *sstore.KvEvent) {
+   s.bindexers[t].OnCacheEvent(evt)
+   select {
+   case <-s.Ready():
+   default:
+   if evt.Action == pb.EVT_CREATE {
+   evt.Action = pb.EVT_INIT
+   }
+   }
+   sstore.EventProxy(t).OnEvent(evt)
+}
+
+func (s *BKvStore) newStore(t sstore.StoreType, opts 
...sstore.KvCacherCfgOption) {
+   opts = append(opts,
+   sstore.WithKey(TypeRoots[t]),
+   sstore.WithInitSize(s.StoreSize(t)),
+   sstore.WithEventFunc(func(evt *sstore.KvEvent) { 
s.dispatchEvent(t, evt) }),
+   )
+   s.newIndexer(t, sstore.NewKvCacher(opts...))
+}
+
+func (s *BKvStore) store() {
+   for t := sstore.StoreType(0); t != typeEnd; t++ {
+   s.newStore(t)
+   }
+   for _, i := range s.bindexers {
+   <-i.Ready()
+   }
+   util.SafeCloseChan(s.bready)
+
+   util.Logger().Debugf("all indexers are ready")
+}
+
+func init() {
+   store.Initialize()
+
+   //sstore.AddEventHandleFunc(LEASE, store.onLeaseEvent)
+}
+
+type BKvStore struct {
+   *sstore.KvStore
+   bindexers map[sstore.StoreType]*sstore.Indexer
+   basyncTaskSvc *async.AsyncTaskService
 
 Review comment:
   I think the basyncTaskSvc is no used here.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2017-12-22 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r158571556
 
 

 ##
 File path: server/broker/broker.go
 ##
 @@ -0,0 +1,26 @@
+//Copyright 2017 Huawei Technologies Co., Ltd
 
 Review comment:
   ServiceComb already moved in Apache infra, please update the lisence.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing

2017-12-22 Thread GitBox
little-cui commented on a change in pull request #220: SC-49 Pact broker module 
for consumer-driven contract testing
URL: 
https://github.com/apache/incubator-servicecomb-service-center/pull/220#discussion_r158571480
 
 

 ##
 File path: server/interceptor/access/access.go
 ##
 @@ -37,11 +37,11 @@ func Intercept(w http.ResponseWriter, r *http.Request) 
error {
 
r.Body = http.MaxBytesReader(w, r.Body, 
core.ServerInfo.Config.MaxBodyBytes)
 
-   if !validate.IsRequestURI(r.RequestURI) {
-   err := fmt.Errorf("Invalid Request URI %s", r.RequestURI)
+   /*if !validate.IsRequestURI(r.RequestURI) {
 
 Review comment:
   Why disenable this check? Is there some conflict?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services