little-cui commented on a change in pull request #1040:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1040#discussion_r647154164



##########
File path: datasource/datasource.go
##########
@@ -17,12 +17,27 @@
 
 package datasource
 
+import (
+       "context"
+)
+
 // DataSource is the DAO layer
 type DataSource interface {
-       SystemManager
-       AccountManager
-       RoleManager
-       DependencyManager
-       MetadataManager
-       SCManager
+       SystemManager() SystemManager
+       AccountManager() AccountManager
+       RoleManager() RoleManager
+       DependencyManager() DependencyManager
+       MetadataManager() MetadataManager
+       SCManager() SCManager
+}
+
+type DataEvent struct {
+       Type string
+       Data interface{}
+}
+type Watcher interface {
+       Result() <-chan *DataEvent
+}
+type DataWatcher interface {

Review comment:
       事件监听的接口应该独立一个文件或pkg

##########
File path: datasource/etcd/version.go
##########
@@ -50,43 +48,8 @@ func (ds *DataSource) LoadServerVersion(ctx context.Context) 
error {
        return nil
 }
 
-func (ds *DataSource) UpgradeServerVersion(ctx context.Context) error {
-       bytes, err := json.Marshal(config.Server)
-       if err != nil {
-               return err
-       }
-       _, err = client.Instance().Do(ctx,
-               client.PUT, client.WithStrKey(path.GetServerInfoKey()), 
client.WithValue(bytes))
-       if err != nil {
-               return err
-       }
-       return nil
-}
-
-func (ds *DataSource) UpgradeVersion(ctx context.Context) error {
-       lock, err := mux.Lock(mux.GlobalLock)
-
-       if err != nil {
-               log.Errorf(err, "wait for server ready failed")
-               return err
-       }
-       if ds.needUpgrade(ctx) {
-               config.Server.Version = version.Ver().Version
-
-               if err := ds.UpgradeServerVersion(ctx); err != nil {
-                       log.Errorf(err, "upgrade server version failed")
-                       os.Exit(1)
-               }
-       }
-       err = lock.Unlock()
-       if err != nil {
-               log.Error("", err)
-       }
-       return err
-}
-
-func (ds *DataSource) needUpgrade(ctx context.Context) bool {
-       err := ds.LoadServerVersion(ctx)
+func needUpgrade(ctx context.Context) bool {
+       err := loadServerVersion(ctx)

Review comment:
       这部分逻辑删除的原因是什么?原有的设计是用于记录当前运行的sc版本跟之前运行的版本差异,提供给scctl等工具做迁移做判断使用




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


Reply via email to