servicecomb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] little-cui commented on a change in pull request #220: SC-49 Pact broker module for consumer-driven contract testing
Date Thu, 01 Jan 1970 00:00:00 GMT
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_r170405594
 
 

 ##########
 File path: server/broker/store.go
 ##########
 @@ -0,0 +1,175 @@
+/*
+ * 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 broker
+
+import (
+	"sync"
+
+	"github.com/apache/incubator-servicecomb-service-center/pkg/async"
+	"github.com/apache/incubator-servicecomb-service-center/pkg/util"
+	sstore "github.com/apache/incubator-servicecomb-service-center/server/core/backend/store"
+	pb "github.com/apache/incubator-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 = &BKvStore{}
+
+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) }),
 
 Review comment:
   please remove the method 'dispatchEvent' and the option 'WithEventFunc', or will cause
an error.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message