[GitHub] [servicecomb-service-center] robotLJW commented on a change in pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


robotLJW commented on a change in pull request #1191:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1191#discussion_r776195307



##
File path: datasource/dlock/dlock.go
##
@@ -0,0 +1,32 @@
+/*
+ * 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 dlock
+
+import (
+   "errors"
+)
+
+var ErrDLockNotExists = errors.New("DLock is nil")

Review comment:
   修改成 do not exists




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] robotLJW commented on a change in pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


robotLJW commented on a change in pull request #1191:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1191#discussion_r776195182



##
File path: datasource/dlock/init.go
##
@@ -0,0 +1,56 @@
+/*
+ * 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 dlock
+
+import (
+   "fmt"
+
+   "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+type engine func(opts Options) (DLock, error)

Review comment:
   修改成initfunc

##
File path: datasource/etcd/dlock.go
##
@@ -0,0 +1,88 @@
+/*
+ * 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/go-chassis/openlog"
+   "github.com/little-cui/etcdadpt"
+
+   "github.com/apache/servicecomb-service-center/datasource/dlock"
+)
+
+func init() {
+   dlock.Install("etcd", NewDLock)
+   dlock.Install("embeded_etcd", NewDLock)
+   dlock.Install("embedded_etcd", NewDLock)
+}
+
+func NewDLock(opts dlock.Options) (dlock.DLock, error) {
+   return {lockMap: make(map[string]*etcdadpt.DLock)}, nil
+}
+
+type DB struct {
+   lockMap map[string]*etcdadpt.DLock

Review comment:
   添加了读写锁




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


tianxiaoliang commented on a change in pull request #1191:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1191#discussion_r776184565



##
File path: datasource/dlock/dlock.go
##
@@ -0,0 +1,32 @@
+/*
+ * 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 dlock

Review comment:
   包注释




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


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



##
File path: datasource/dlock/dlock.go
##
@@ -0,0 +1,32 @@
+/*
+ * 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 dlock
+
+import (
+   "errors"
+)
+
+var ErrDLockNotExists = errors.New("DLock is nil")

Review comment:
   描述不准确,应该是不存在




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


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



##
File path: datasource/etcd/dlock.go
##
@@ -0,0 +1,88 @@
+/*
+ * 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/go-chassis/openlog"
+   "github.com/little-cui/etcdadpt"
+
+   "github.com/apache/servicecomb-service-center/datasource/dlock"
+)
+
+func init() {
+   dlock.Install("etcd", NewDLock)
+   dlock.Install("embeded_etcd", NewDLock)
+   dlock.Install("embedded_etcd", NewDLock)
+}
+
+func NewDLock(opts dlock.Options) (dlock.DLock, error) {
+   return {lockMap: make(map[string]*etcdadpt.DLock)}, nil
+}
+
+type DB struct {
+   lockMap map[string]*etcdadpt.DLock

Review comment:
   线程不安全

##
File path: datasource/dlock/init.go
##
@@ -0,0 +1,56 @@
+/*
+ * 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 dlock
+
+import (
+   "fmt"
+
+   "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+type engine func(opts Options) (DLock, error)

Review comment:
   需要改名




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] robotLJW opened a new pull request #1191: [feat] add dlock service, implemented etcd's dlock mechanism

2021-12-28 Thread GitBox


robotLJW opened a new pull request #1191:
URL: https://github.com/apache/servicecomb-service-center/pull/1191


   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks 
pass. A more thorough check will be performed on your pull request 
automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [ ] Never comment source code, delete it.
- [ ] UT should has "context, subject, expected result" result as test case 
name, when you call t.Run().
   ---
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #1190: Refactor: add self registry service

2021-12-28 Thread GitBox


tianxiaoliang merged pull request #1190:
URL: https://github.com/apache/servicecomb-service-center/pull/1190


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-service-center] branch master updated: Refactor: add self registry service (#1190)

2021-12-28 Thread tianxiaoliang
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-service-center.git


The following commit(s) were added to refs/heads/master by this push:
 new 35b4680  Refactor: add self registry service (#1190)
35b4680 is described below

commit 35b46800a60df832170c10964fca48d897fc052c
Author: little-cui 
AuthorDate: Wed Dec 29 09:49:04 2021 +0800

Refactor: add self registry service (#1190)
---
 datasource/engine.go   |   2 -
 datasource/engine_test.go  |  98 ---
 datasource/etcd/engine.go  | 139 -
 datasource/mongo/engine.go | 138 
 server/api_server.go   |   9 +-
 server/datacache/cache.go  |   8 --
 .../service/registry/registry.go   |  70 +++
 7 files changed, 18 insertions(+), 446 deletions(-)

diff --git a/datasource/engine.go b/datasource/engine.go
index d2c3265..1c2d6d5 100644
--- a/datasource/engine.go
+++ b/datasource/engine.go
@@ -25,8 +25,6 @@ import (
 
 // SCManager contains the APIs of registration of SC itself
 type SCManager interface {
-   SelfRegister(ctx context.Context) error
-   SelfUnregister(ctx context.Context) error
UpgradeVersion(ctx context.Context) error
GetClusters(ctx context.Context) (etcdadpt.Clusters, error)
 }
diff --git a/datasource/engine_test.go b/datasource/engine_test.go
deleted file mode 100644
index cc3a048..000
--- a/datasource/engine_test.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 datasource_test
-
-import (
-   "context"
-   "fmt"
-
-   "github.com/apache/servicecomb-service-center/datasource/etcd/path"
-
-   "github.com/apache/servicecomb-service-center/pkg/util"
-   apt "github.com/apache/servicecomb-service-center/server/core"
-   pb "github.com/go-chassis/cari/discovery"
-   . "github.com/onsi/ginkgo"
-   . "github.com/onsi/gomega"
-)
-
-// map[domainProject][serviceName]*serviceCleanInfo
-var svcCleanInfos = make(map[string]map[string]*serviceCleanInfo)
-
-type serviceCleanInfo struct {
-   ServiceName  string
-   ServiceIdstring
-   WithInstance bool
-   ShouldClear  bool
-}
-
-func getContextWith(domain string, project string) context.Context {
-   return util.WithNoCache(util.SetDomainProject(context.Background(), 
domain, project))
-}
-
-func createService(domain string, project string, name string, withInstance 
bool, shouldClear bool) {
-   By(fmt.Sprintf("create service: %s, with instance: %t, should clear: 
%t", name, withInstance, shouldClear))
-   svc := {
-   Service: {
-   AppId:   "clear",
-   ServiceName: name,
-   Version: "1.0",
-   },
-   }
-   if withInstance {
-   svc.Instances = []*pb.MicroServiceInstance{
-   {
-   Endpoints: []string{"http://127.0.0.1:80"},
-   HostName:  "1",
-   },
-   }
-   }
-   ctx := getContextWith(domain, project)
-   svcResp, err := apt.ServiceAPI.Create(ctx, svc)
-   Expect(err).To(BeNil())
-   Expect(svcResp).NotTo(BeNil())
-   Expect(svcResp.Response.GetCode()).To(Equal(pb.ResponseSuccess))
-   info := {
-   ServiceName:  name,
-   ServiceId:svcResp.ServiceId,
-   WithInstance: withInstance,
-   ShouldClear:  shouldClear,
-   }
-   domainProject := domain + path.SPLIT + project
-   m, ok := svcCleanInfos[domainProject]
-   if !ok {
-   m = make(map[string]*serviceCleanInfo)
-   svcCleanInfos[domainProject] = m
-   }
-   m[name] = info
-}
-
-func checkServiceCleared(domain string, project string) {
-   domainProject := domain + path.SPLIT + project
-   m := svcCleanInfos[domainProject]
-   for _, v := range m {
-   

[GitHub] [servicecomb-service-center] little-cui opened a new pull request #1190: Refactor: add self registry service

2021-12-28 Thread GitBox


little-cui opened a new pull request #1190:
URL: https://github.com/apache/servicecomb-service-center/pull/1190


   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks 
pass. A more thorough check will be performed on your pull request 
automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [ ] Never comment source code, delete it.
- [ ] UT should has "context, subject, expected result" result as test case 
name, when you call t.Run().
   ---
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #1189: Refactor: RBAC datasource interface

2021-12-28 Thread GitBox


tianxiaoliang merged pull request #1189:
URL: https://github.com/apache/servicecomb-service-center/pull/1189


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-service-center] branch master updated: Optimize: refactor rbac datasource interface (#1189)

2021-12-28 Thread tianxiaoliang
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-service-center.git


The following commit(s) were added to refs/heads/master by this push:
 new 7243b23  Optimize: refactor rbac datasource interface (#1189)
7243b23 is described below

commit 7243b23e6aed5ea789bb27f17faf8cd4df88a22a
Author: little-cui 
AuthorDate: Wed Dec 29 09:28:44 2021 +0800

Optimize: refactor rbac datasource interface (#1189)
---
 datasource/account_test.go | 121 -
 datasource/datasource.go   |   3 -
 datasource/etcd/account.go |  46 +---
 datasource/etcd/account_lock.go|  31 ++
 datasource/etcd/etcd.go|  28 +
 datasource/etcd/role.go|  31 +++---
 datasource/manager.go  |  19 +---
 datasource/mongo/account.go|  40 ---
 datasource/mongo/account_lock.go   |  33 +++---
 datasource/mongo/mongo.go  |  28 +
 datasource/mongo/role.go   |  36 +++---
 datasource/{ => rbac}/account.go   |  20 ++--
 datasource/rbac/account_test.go| 118 
 datasource/{schema => rbac}/init.go|  12 +-
 .../buildin/role.go => datasource/rbac/options.go  |  17 +--
 .../buildin/role.go => datasource/rbac/rbac.go |  18 +--
 datasource/{ => rbac}/role.go  |   2 +-
 datasource/{ => rbac}/role_test.go |  46 
 datasource/schema/init.go  |   8 +-
 server/job/account/account_test.go |  18 +--
 server/plugin/quota/buildin/account.go |   4 +-
 server/plugin/quota/buildin/role.go|   4 +-
 server/resource/rbac/auth_resource.go  |  24 ++--
 server/resource/rbac/auth_resource_test.go |   4 +-
 server/resource/rbac/role_resource_test.go |  26 ++---
 server/service/account/account.go  |  28 ++---
 server/service/account/account_test.go |  42 +++
 server/service/rbac/account_service.go |  56 +-
 server/service/rbac/blocker.go |   6 +-
 server/service/rbac/blocker_test.go|  10 +-
 server/service/rbac/decision.go|  24 ++--
 server/service/rbac/perm_service.go|  14 +--
 server/service/rbac/role_service.go|  51 +
 33 files changed, 447 insertions(+), 521 deletions(-)

diff --git a/datasource/account_test.go b/datasource/account_test.go
deleted file mode 100644
index a6e839b..000
--- a/datasource/account_test.go
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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 datasource_test
-
-import (
-   "context"
-   "strconv"
-   "testing"
-   "time"
-
-   "github.com/go-chassis/cari/rbac"
-
-   "github.com/apache/servicecomb-service-center/datasource"
-   "github.com/stretchr/testify/assert"
-)
-
-var (
-   a1 = rbac.Account{
-   ID:  "1-2-3",
-   Name:"test-account1",
-   Password:"tnuocca-tset",
-   Roles:   []string{"admin"},
-   TokenExpirationTime: "2020-12-30",
-   CurrentPassword: "tnuocca-tset1",
-   }
-   a2 = rbac.Account{
-   ID:  "1-2-3-4",
-   Name:"test-account2",
-   Password:"tnuocca-tset",
-   Roles:   []string{"admin"},
-   TokenExpirationTime: "2020-12-30",
-   CurrentPassword: "tnuocca-tset2",
-   }
-)
-
-func TestAccount(t *testing.T) {
-   t.Run("add and get account", func(t *testing.T) {
-   err := 
datasource.GetAccountManager().CreateAccount(context.Background(), )
-   assert.NoError(t, err)
-   err = 

[GitHub] [servicecomb-service-center] little-cui opened a new pull request #1189: Optimize: refactor rbac datasource interface

2021-12-28 Thread GitBox


little-cui opened a new pull request #1189:
URL: https://github.com/apache/servicecomb-service-center/pull/1189


   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks 
pass. A more thorough check will be performed on your pull request 
automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [ ] Never comment source code, delete it.
- [ ] UT should has "context, subject, expected result" result as test case 
name, when you call t.Run().
   ---
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] little-cui merged pull request #1188: [fix] modify ci to use mongo replica set

2021-12-28 Thread GitBox


little-cui merged pull request #1188:
URL: https://github.com/apache/servicecomb-service-center/pull/1188


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-service-center] branch master updated: [fix] modify ci to use mongo replica set (#1188)

2021-12-28 Thread littlecui
This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
 new f450576  [fix] modify ci to use mongo replica set (#1188)
f450576 is described below

commit f4505760f46c65be3c73608d50497b4ed2d3c85c
Author: robotljw <790504...@qq.com>
AuthorDate: Tue Dec 28 21:25:51 2021 +0800

[fix] modify ci to use mongo replica set (#1188)
---
 .github/workflows/eventbase-ci.yml | 10 +++---
 .github/workflows/static_check.yml |  2 ++
 scripts/docker-compose.yaml| 28 
 scripts/ut_test_in_docker.sh   |  2 --
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/eventbase-ci.yml 
b/.github/workflows/eventbase-ci.yml
index a2a0f57..84e474d 100644
--- a/.github/workflows/eventbase-ci.yml
+++ b/.github/workflows/eventbase-ci.yml
@@ -9,16 +9,12 @@ jobs:
 with:
   go-version: 1.16
 id: go
-  - name: Start MongoDB
-uses: supercharge/mongodb-github-action@1.7.0
-with:
-  mongodb-version: 4.2
-  mongodb-replica-set: test-rs
-  mongodb-port: 27017
   - name: Check out source code
 uses: actions/checkout@v1
   - name: UT test
 run: |
+  sudo docker-compose -f ./scripts/docker-compose.yaml up -d
+  sleep 20
   export TEST_DB_MODE=mongo
   export TEST_DB_URI=mongodb://127.0.0.1:27017
   cd eventbase
@@ -31,7 +27,7 @@ jobs:
 with:
   go-version: 1.16
 id: go
-  - name: Check out code into the Go module directory
+  - name: Check out source code
 uses: actions/checkout@v1
   - name: UT for etcd
 run: |
diff --git a/.github/workflows/static_check.yml 
b/.github/workflows/static_check.yml
index 7155654..b012651 100644
--- a/.github/workflows/static_check.yml
+++ b/.github/workflows/static_check.yml
@@ -40,6 +40,8 @@ jobs:
 uses: actions/checkout@v1
   - name: UT-MONGO
 run: |
+  sudo docker-compose -f ./scripts/docker-compose.yaml up -d
+  sleep 20
   bash -x scripts/ut_test_in_docker.sh mongo
   integration-test:
 runs-on: ubuntu-latest
diff --git a/scripts/docker-compose.yaml b/scripts/docker-compose.yaml
new file mode 100644
index 000..115d08e
--- /dev/null
+++ b/scripts/docker-compose.yaml
@@ -0,0 +1,28 @@
+## ---
+## 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.
+## ---
+version: '3.3'
+services:
+  mongo:
+image: mongo:4.2
+command: mongod --replSet my-replica-set --port 27017 --bind_ip_all
+ports:
+  - 27017:27017
+environment:
+  MONGO_INITDB_DATABASE: servicecomb
+healthcheck:
+  test: test $$(echo 
"rs.initiate({_id:'my-replica-set',members:[{_id:0,host:\"127.0.0.1:27017\"}]}).ok
 || rs.status().ok" | mongo --port 27017 --quiet) -eq 1
+  interval: 10s
\ No newline at end of file
diff --git a/scripts/ut_test_in_docker.sh b/scripts/ut_test_in_docker.sh
index 2337cb9..6ecaa0f 100644
--- a/scripts/ut_test_in_docker.sh
+++ b/scripts/ut_test_in_docker.sh
@@ -44,8 +44,6 @@ if [ ${db_name} == "etcd" ];then
   done
   echo "${green}Etcd is running..${reset}"
 elif [ ${db_name} == "mongo" ];then
-  echo "${green}Starting mongo in docker${reset}"
-  docker run -d -p 27017:27017 --name mongo mongo
   while ! nc -z 127.0.0.1 27017; do
 echo "Waiting mongo to launch on 27017..."
 sleep 1


[GitHub] [servicecomb-kie] little-cui merged pull request #237: remove sync pool to avoid complicated code, the price is performance

2021-12-28 Thread GitBox


little-cui merged pull request #237:
URL: https://github.com/apache/servicecomb-kie/pull/237


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-kie] branch master updated: remove sync pool to avoid complicated code, the price is performance (#237)

2021-12-28 Thread littlecui
This is an automated email from the ASF dual-hosted git repository.

littlecui 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 fd48a20  remove sync pool to avoid complicated code, the price is 
performance (#237)
fd48a20 is described below

commit fd48a20a4058d4d02ad0e23e77fb85b04db75219
Author: Shawn 
AuthorDate: Tue Dec 28 20:02:30 2021 +0800

remove sync pool to avoid complicated code, the price is performance (#237)
---
 go.sum   | 145 +++
 server/pubsub/bus.go |   5 +-
 server/pubsub/struct.go  |   9 +++
 server/resource/v1/common.go |  29 -
 4 files changed, 170 insertions(+), 18 deletions(-)

diff --git a/go.sum b/go.sum
index a2bfb9d..ab328c2 100644
--- a/go.sum
+++ b/go.sum
@@ -6,33 +6,54 @@ cloud.google.com/go v0.44.2/go.mod 
h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxK
 cloud.google.com/go v0.45.1/go.mod 
h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
 cloud.google.com/go v0.46.3 h1:AVXDdKsrtX33oR9fbCMu/+c1o8Ofjq6Ku/MInaLVg5Y=
 cloud.google.com/go v0.46.3/go.mod 
h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go/bigquery v1.0.1 
h1:hL+ycaJpVE9M7nLoiXb/Pn10ENE2u+oddxbD8uu0ZVU=
 cloud.google.com/go/bigquery v1.0.1/go.mod 
h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/datastore v1.0.0 
h1:Kt+gOPPp2LEPWp8CSfxhsM8ik9CcyE/gYu+0r+RnZvM=
 cloud.google.com/go/datastore v1.0.0/go.mod 
h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/firestore v1.1.0 
h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY=
 cloud.google.com/go/firestore v1.1.0/go.mod 
h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/pubsub v1.0.1 
h1:W9tAK3E57P75u0XLLR82LZyw8VpAnhmyTOxW9qzmyj8=
 cloud.google.com/go/pubsub v1.0.1/go.mod 
h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/storage v1.0.0 
h1:VV2nUM3wwLLGh9lSABFgZMjInyUbJeaRSE64WuAIQ+4=
 cloud.google.com/go/storage v1.0.0/go.mod 
h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 
h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod 
h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+github.com/Azure/go-autorest/autorest v0.9.0 
h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs=
 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 
h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU=
 github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod 
h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
+github.com/Azure/go-autorest/autorest/date v0.1.0 
h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM=
 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 
h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0=
 github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod 
h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
+github.com/Azure/go-autorest/logger v0.1.0 
h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=
 github.com/Azure/go-autorest/logger v0.1.0/go.mod 
h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
+github.com/Azure/go-autorest/tracing v0.5.0 
h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k=
 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/BurntSushi/toml v0.4.1 
h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
 github.com/BurntSushi/toml v0.4.1/go.mod 
h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 
h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod 
h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 
h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0=
 github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod 
h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
+github.com/OneOfOne/xxhash v1.2.2 
h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
 github.com/OneOfOne/xxhash v1.2.2/go.mod 
h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/PuerkitoBio/purell v1.0.0 
h1:0GoNN3taZV6QI81IXgCbxMyEaJDXMSIjArYBCYzVVvs=
 github.com/PuerkitoBio/purell v1.0.0/go.mod 
h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2 
h1:JCHLVE3B+kJde7bIEo5N4J+ZbLhp0J1Fs+ulyRws4gE=
 github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod 

[servicecomb-service-center] branch master updated: Feature: add schema retire cron job (#1187)

2021-12-28 Thread tianxiaoliang
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-service-center.git


The following commit(s) were added to refs/heads/master by this push:
 new a1387cc  Feature: add schema retire cron job (#1187)
a1387cc is described below

commit a1387cc7a53d010f69437e0cc864761f6681406f
Author: little-cui 
AuthorDate: Tue Dec 28 19:40:25 2021 +0800

Feature: add schema retire cron job (#1187)
---
 datasource/etcd/path/key_convertor.go  | 89 +-
 datasource/etcd/path/key_convertor_test.go |  8 +-
 datasource/etcd/path/key_generator.go  |  5 --
 datasource/etcd/retire.go  | 88 +
 datasource/etcd/schema.go  | 54 -
 datasource/mongo/retire.go |  2 +-
 datasource/mongo/schema.go |  8 +-
 datasource/retire.go   | 11 +--
 datasource/schema/schema.go|  4 +-
 etc/conf/app.yaml  |  4 +-
 go.mod |  1 +
 go.sum |  2 +
 integration/instances_test.go  | 24 +++---
 server/job/disco/retire.go | 44 +--
 .../disco/retire.go => job/disco/schema.go}| 28 ++-
 server/service/disco/retire.go | 15 
 server/service/disco/retire_test.go| 55 -
 server/service/disco/schema_test.go| 28 +--
 18 files changed, 255 insertions(+), 215 deletions(-)

diff --git a/datasource/etcd/path/key_convertor.go 
b/datasource/etcd/path/key_convertor.go
index 7c93604..7e0ee8c 100644
--- a/datasource/etcd/path/key_convertor.go
+++ b/datasource/etcd/path/key_convertor.go
@@ -23,39 +23,45 @@ import (
 
"github.com/apache/servicecomb-service-center/pkg/util"
"github.com/go-chassis/cari/discovery"
+   "github.com/go-chassis/foundation/stringutil"
 )
 
-func ToResponse(key []byte) (keys []string) {
+func splitKey(key []byte) (keys []string) {
return strings.Split(util.BytesToStringWithNoCopy(key), SPLIT)
 }
 
-func GetInfoFromSvcKV(key []byte) (serviceID, domainProject string) {
-   keys := ToResponse(key)
+func getLast2Keys(key []byte) (string, string) {
+   keys := splitKey(key)
l := len(keys)
-   if l < 4 {
-   return
+   if l < 3 {
+   return "", ""
}
-   serviceID = keys[l-1]
-   domainProject = fmt.Sprintf("%s/%s", keys[l-3], keys[l-2])
-   return
+   return fmt.Sprintf("%s/%s", keys[l-3], keys[l-2]), keys[l-1]
 }
 
-func GetInfoFromInstKV(key []byte) (serviceID, instanceID, domainProject 
string) {
-   keys := ToResponse(key)
+func getLast3Keys(key []byte) (string, string, string) {
+   keys := splitKey(key)
l := len(keys)
if l < 4 {
-   return
+   return "", "", ""
}
-   serviceID = keys[l-2]
-   instanceID = keys[l-1]
-   domainProject = fmt.Sprintf("%s/%s", keys[l-4], keys[l-3])
+   return fmt.Sprintf("%s/%s", keys[l-4], keys[l-3]), keys[l-2], keys[l-1]
+}
+
+func GetInfoFromSvcKV(key []byte) (serviceID, domainProject string) {
+   domainProject, serviceID = getLast2Keys(key)
+   return
+}
+
+func GetInfoFromInstKV(key []byte) (serviceID, instanceID, domainProject 
string) {
+   domainProject, serviceID, instanceID = getLast3Keys(key)
return
 }
 
 func GetInfoFromDomainKV(key []byte) (domain string) {
-   keys := ToResponse(key)
+   keys := splitKey(key)
l := len(keys)
-   if l < 2 {
+   if l < 1 {
return
}
domain = keys[l-1]
@@ -63,27 +69,21 @@ func GetInfoFromDomainKV(key []byte) (domain string) {
 }
 
 func GetInfoFromProjectKV(key []byte) (domain, project string) {
-   keys := ToResponse(key)
+   keys := splitKey(key)
l := len(keys)
if l < 2 {
-   return
+   return "", ""
}
return keys[l-2], keys[l-1]
 }
 
 func GetInfoFromTagKV(key []byte) (serviceID, domainProject string) {
-   keys := ToResponse(key)
-   l := len(keys)
-   if l < 3 {
-   return
-   }
-   serviceID = keys[l-1]
-   domainProject = fmt.Sprintf("%s/%s", keys[l-3], keys[l-2])
+   domainProject, serviceID = getLast2Keys(key)
return
 }
 
 func GetInfoFromSvcIndexKV(key []byte) *discovery.MicroServiceKey {
-   keys := ToResponse(key)
+   keys := splitKey(key)
l := len(keys)
if l < 6 {
return nil
@@ -103,43 +103,28 @@ func GetInfoFromSvcAliasKV(key []byte) 
*discovery.MicroServiceKey {
 }
 
 func GetInfoFromSchemaRefKV(key []byte) (domainProject, serviceID, schemaID 
string) {
-   return 

[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #1187: Feature: add schema retire cron job

2021-12-28 Thread GitBox


tianxiaoliang merged pull request #1187:
URL: https://github.com/apache/servicecomb-service-center/pull/1187


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] robotLJW opened a new pull request #1188: [fix] modify ci to use mongo replica set

2021-12-28 Thread GitBox


robotLJW opened a new pull request #1188:
URL: https://github.com/apache/servicecomb-service-center/pull/1188


   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks 
pass. A more thorough check will be performed on your pull request 
automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [ ] Never comment source code, delete it.
- [ ] UT should has "context, subject, expected result" result as test case 
name, when you call t.Run().
   ---
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #1185: [feat] add task and tombstone ut in eventbase

2021-12-28 Thread GitBox


tianxiaoliang merged pull request #1185:
URL: https://github.com/apache/servicecomb-service-center/pull/1185


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-service-center] branch master updated: [feat] add task and tombstone ut in eventbase (#1185)

2021-12-28 Thread tianxiaoliang
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-service-center.git


The following commit(s) were added to refs/heads/master by this push:
 new 1e58aa0  [feat] add task and tombstone ut in eventbase (#1185)
1e58aa0 is described below

commit 1e58aa0464c6f4ac7ddd08c6c2a52635900449b1
Author: robotljw <790504...@qq.com>
AuthorDate: Tue Dec 28 17:23:01 2021 +0800

[feat] add task and tombstone ut in eventbase (#1185)
---
 .github/workflows/eventbase-ci.yml |  45 +++
 eventbase/README.md|  37 ++
 eventbase/datasource/etcd/task/task_dao.go |   8 +-
 eventbase/datasource/etcd/task/task_dao_test.go| 146 -
 .../datasource/etcd/tombstone/tombstone_dao.go |   4 +-
 .../etcd/tombstone/tombstone_dao_test.go   | 113 
 eventbase/datasource/mongo/model/types.go  |   3 +-
 eventbase/datasource/mongo/mongo.go|   4 +-
 eventbase/datasource/mongo/task/task_dao.go|  10 +-
 eventbase/datasource/mongo/task/task_dao_test.go   | 145 
 .../datasource/mongo/tombstone/tombstone_dao.go|   7 +-
 .../mongo/tombstone/tombstone_dao_test.go  | 112 
 eventbase/datasource/options.go|  12 +-
 eventbase/datasource/tlsutil/tlsutil_test.go   |  73 ---
 eventbase/datasource/tombstone.go  |   4 +-
 eventbase/go.mod   |   3 +-
 eventbase/go.sum   |   6 +-
 .../tombstone_request.go => model/request.go}  |  10 +-
 eventbase/service/task/task_svc.go |  10 +-
 eventbase/service/task/task_svc_test.go| 118 +
 eventbase/service/tombstone/tombstone_svc.go   |   6 +-
 eventbase/service/tombstone/tombstone_svc_test.go  | 100 ++
 eventbase/test/test.go |  56 +++-
 scripts/ut_test_in_docker.sh   |   4 +-
 24 files changed, 398 insertions(+), 638 deletions(-)

diff --git a/.github/workflows/eventbase-ci.yml 
b/.github/workflows/eventbase-ci.yml
new file mode 100644
index 000..a2a0f57
--- /dev/null
+++ b/.github/workflows/eventbase-ci.yml
@@ -0,0 +1,45 @@
+name: eventbase merge check
+on: [ push, pull_request ]
+jobs:
+  mongo-storage:
+runs-on: ubuntu-latest
+steps:
+  - name: Set up Go
+uses: actions/setup-go@v1
+with:
+  go-version: 1.16
+id: go
+  - name: Start MongoDB
+uses: supercharge/mongodb-github-action@1.7.0
+with:
+  mongodb-version: 4.2
+  mongodb-replica-set: test-rs
+  mongodb-port: 27017
+  - name: Check out source code
+uses: actions/checkout@v1
+  - name: UT test
+run: |
+  export TEST_DB_MODE=mongo
+  export TEST_DB_URI=mongodb://127.0.0.1:27017
+  cd eventbase
+  go test -short -covermode=atomic $(go list ./... | grep -v etcd | 
grep -v third_party | grep -v examples)
+  etcd-storage:
+runs-on: ubuntu-latest
+steps:
+  - name: Set up Go
+uses: actions/setup-go@v1
+with:
+  go-version: 1.16
+id: go
+  - name: Check out code into the Go module directory
+uses: actions/checkout@v1
+  - name: UT for etcd
+run: |
+  time docker run -d -p 2379:2379 --name etcd quay.io/coreos/etcd etcd 
-name etcd --advertise-client-urls http://0.0.0.0:2379 --listen-client-urls 
http://0.0.0.0:2379
+  while ! nc -z 127.0.0.1 2379; do
+sleep 1
+  done
+  export TEST_DB_MODE=etcd
+  export TEST_DB_URI=http://127.0.0.1:2379
+  cd eventbase
+  time go test -short -covermode=atomic $(go list ./... | grep -v 
mongo | grep -v third_party | grep -v examples)
\ No newline at end of file
diff --git a/eventbase/README.md b/eventbase/README.md
new file mode 100644
index 000..93ddf88
--- /dev/null
+++ b/eventbase/README.md
@@ -0,0 +1,37 @@
+# eventbase
+
+eventbase provides the crud interface of task and tombstone.
+
+### package
+
+**bootstrap**:used to start initial loading.
+
+**datasource**: realize the dao operation of etcd and mongo on task and 
tombstone.
+
+**domain**: task and tombstone request.
+
+**service**: Interfaces exposed by task and tombstone.
+
+**test**: test parameters.
+
+### how to use
+
+```go
+import (
+   _ "github.com/apache/servicecomb-service-center/eventbase/bootstrap"
+   "github.com/apache/servicecomb-service-center/eventbase/datasource"
+   )
+
+func Init(){
+dbCfg := db.Config{
+   Kind: "etcd",
+   URI: "http://127.0.0.1:2379;,
+   Timeout: 10 * time.Second,
+}
+err := datasource.Init(dbCfg)
+...
+datasource.GetDataSource().TaskDao()
+

[GitHub] [servicecomb-service-center] robotLJW commented on a change in pull request #1185: [feat] add task and tombstone ut in eventbase

2021-12-28 Thread GitBox


robotLJW commented on a change in pull request #1185:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1185#discussion_r775802397



##
File path: eventbase/datasource/etcd/task/task_dao_test.go
##
@@ -46,29 +43,29 @@ func init() {
 func TestTask(t *testing.T) {

Review comment:
   确实,测试用例应该抽取到上层的service,我这边的测试用例还是有重复,为了减少ci的时延,还是先删除了




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] robotLJW commented on a change in pull request #1185: [feat] add task and tombstone ut in eventbase

2021-12-28 Thread GitBox


robotLJW commented on a change in pull request #1185:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1185#discussion_r775801999



##
File path: eventbase/service/tombstone/tombstone_svc.go
##
@@ -23,18 +23,18 @@ import (
"github.com/go-chassis/cari/sync"
 
"github.com/apache/servicecomb-service-center/eventbase/datasource"
-   "github.com/apache/servicecomb-service-center/eventbase/request"
+   "github.com/apache/servicecomb-service-center/eventbase/domain"

Review comment:
   已经修改成 model 




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1185: [feat] add task and tombstone ut in eventbase

2021-12-28 Thread GitBox


tianxiaoliang commented on a change in pull request #1185:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1185#discussion_r775790164



##
File path: eventbase/datasource/etcd/task/task_dao_test.go
##
@@ -46,29 +43,29 @@ func init() {
 func TestTask(t *testing.T) {

Review comment:
   UT应该提交到更上层,不要依赖具体实现,比如etcd,而是针对接口做测试,UT里控制具体实现




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1185: [feat] add task and tombstone ut in eventbase

2021-12-28 Thread GitBox


tianxiaoliang commented on a change in pull request #1185:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1185#discussion_r775787781



##
File path: eventbase/service/tombstone/tombstone_svc.go
##
@@ -23,18 +23,18 @@ import (
"github.com/go-chassis/cari/sync"
 
"github.com/apache/servicecomb-service-center/eventbase/datasource"
-   "github.com/apache/servicecomb-service-center/eventbase/request"
+   "github.com/apache/servicecomb-service-center/eventbase/domain"

Review comment:
   叫model吧,保持风格一致




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org