You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/06/03 07:28:17 UTC

[GitHub] [servicecomb-service-center] zenlint commented on a change in pull request #549: [SCB-1307] Switch storage to etcd and add mock storage to tests

zenlint commented on a change in pull request #549: [SCB-1307] Switch storage to etcd and add mock storage to tests
URL: https://github.com/apache/servicecomb-service-center/pull/549#discussion_r289716307
 
 

 ##########
 File path: syncer/etcd/agent.go
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * 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 etcd
+
+import (
+	"github.com/apache/servicecomb-service-center/pkg/log"
+	"github.com/apache/servicecomb-service-center/syncer/servicecenter"
+	"github.com/coreos/etcd/embed"
+	"github.com/coreos/etcd/etcdserver/api/v3client"
+)
+
+// Agent warps the embed etcd
+type Agent struct {
+	conf    *Config
+	etcd    *embed.Etcd
+	storage servicecenter.Storage
+}
+
+// NewAgent new etcd agent with config
+func NewAgent(conf *Config) *Agent {
+	return &Agent{conf: conf}
+}
+
+// Run etcd agent
+func (a *Agent) Run() error {
+	etcd, err := embed.StartEtcd(a.conf.Config)
+	if err != nil {
+		return err
+	}
+	select {
+	case <-etcd.Server.ReadyNotify():
+		log.Info("ready notify")
+	case <-etcd.Server.StopNotify():
 
 Review comment:
   I think  although this is a rare occurrence, syncer should capture it, suggest to return an err like `etcd.Servcer.Err()` when etcd return through the `StopNotify`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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