You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2019/05/09 08:12:47 UTC

[servicecomb-kie] branch master updated (a1c0700 -> 151158f)

This is an automated email from the ASF dual-hosted git repository.

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


    from a1c0700  Add project introduction
     new 6afc216  add kv data access api
     new 65b7c24  fix based on comments
     new 151158f  Merge pull request #2 from tianxiaoliang/master

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 deployments/docker/docker-compose.yaml |  35 ++++
 go.mod                                 |  16 ++
 pkg/model/kv.go                        |  41 +++++
 pkg/model/kv_test.go                   |  45 +++++
 server/config/config.go                |  44 +++++
 server/config/config_test.go           |  51 ++++++
 server/config/struct.go                |  29 ++++
 server/kv/errors.go                    |  35 ++++
 server/kv/kv.go                        |  62 +++++++
 server/kv/kv_test.go                   | 192 +++++++++++++++++++++
 server/kv/model_suite_test.go          |  44 +++++
 server/kv/mongodb.go                   | 304 +++++++++++++++++++++++++++++++++
 server/kv/options.go                   |  49 ++++++
 13 files changed, 947 insertions(+)
 create mode 100644 deployments/docker/docker-compose.yaml
 create mode 100644 go.mod
 create mode 100644 pkg/model/kv.go
 create mode 100644 pkg/model/kv_test.go
 create mode 100644 server/config/config.go
 create mode 100644 server/config/config_test.go
 create mode 100644 server/config/struct.go
 create mode 100644 server/kv/errors.go
 create mode 100644 server/kv/kv.go
 create mode 100644 server/kv/kv_test.go
 create mode 100644 server/kv/model_suite_test.go
 create mode 100644 server/kv/mongodb.go
 create mode 100644 server/kv/options.go


[servicecomb-kie] 01/06: Init the project documents

Posted by li...@apache.org.
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

commit e66eaec7b280a60ba4d94f88a660da201b7d6e91
Author: Willem Jiang <ji...@huawei.com>
AuthorDate: Mon Apr 29 14:23:28 2019 +0800

    Init the project documents
---
 .gitignore |  24 ++++++++
 LICENSE    | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 NOTICE     |   5 ++
 README.md  |  19 ++++++
 4 files changed, 249 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..901a1e4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+bin/
+output
+**/*.coverprofile
+**/coverage.out
+**/coverage.txt
+**/*.log
+
+*.iml
+.idea/
+**/*junit.xml
+**/*.exe
+**/*.tgz
+
+vendor/**
+!vendor/manifest
+
+# for local UT
+**/conf/
+!etc/conf/
+etc/data/
+etc/ssl/
+tmp/
+glide.lock
+go.sum
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   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.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..effa6a2
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache ServiceComb Kie
+Copyright 2019-2019 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..91353db
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
+# Apache-ServiceComb-Kie
+
+Introduction of the project
+
+## Features
+
+## Quick Start
+
+## Contact
+
+Bugs: [issues](https://issues.apache.org/jira/browse/SCB)
+
+## Contributing
+
+See [Contribution guide](/CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
+
+## Reporting Issues
+
+See reporting bugs for details about reporting any issues.


[servicecomb-kie] 06/06: Merge pull request #2 from tianxiaoliang/master

Posted by li...@apache.org.
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

commit 151158fd1e9ce7c3fe8650b587f0f8520afcddcd
Merge: a1c0700 65b7c24
Author: little-cui <su...@qq.com>
AuthorDate: Thu May 9 16:12:43 2019 +0800

    Merge pull request #2 from tianxiaoliang/master
    
    add kv data access api

 deployments/docker/docker-compose.yaml |  35 ++++
 go.mod                                 |  16 ++
 pkg/model/kv.go                        |  41 +++++
 pkg/model/kv_test.go                   |  45 +++++
 server/config/config.go                |  44 +++++
 server/config/config_test.go           |  51 ++++++
 server/config/struct.go                |  29 ++++
 server/kv/errors.go                    |  35 ++++
 server/kv/kv.go                        |  62 +++++++
 server/kv/kv_test.go                   | 192 +++++++++++++++++++++
 server/kv/model_suite_test.go          |  44 +++++
 server/kv/mongodb.go                   | 304 +++++++++++++++++++++++++++++++++
 server/kv/options.go                   |  49 ++++++
 13 files changed, 947 insertions(+)


[servicecomb-kie] 04/06: add kv data access api

Posted by li...@apache.org.
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

commit 6afc216839e28680776a539407cfb30cf83ecd5d
Author: tian <xi...@gmail.com>
AuthorDate: Tue May 7 19:25:30 2019 +0800

    add kv data access api
---
 deployments/docker/docker-compose.yaml |  19 +++
 go.mod                                 |  16 ++
 pkg/model/kv.go                        |  49 ++++++
 pkg/model/kv_test.go                   |  45 +++++
 server/config/config.go                |  44 +++++
 server/config/config_test.go           |  51 ++++++
 server/config/struct.go                |  29 ++++
 server/kv/errors.go                    |  35 ++++
 server/kv/kv.go                        |  62 +++++++
 server/kv/kv_test.go                   | 192 +++++++++++++++++++++
 server/kv/model_suite_test.go          |  44 +++++
 server/kv/mongodb.go                   | 304 +++++++++++++++++++++++++++++++++
 server/kv/options.go                   |  49 ++++++
 13 files changed, 939 insertions(+)

diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml
new file mode 100644
index 0000000..2c87590
--- /dev/null
+++ b/deployments/docker/docker-compose.yaml
@@ -0,0 +1,19 @@
+version: '3.1'
+services:
+  mongo:
+    image: mongo
+    restart: always
+    ports:
+      - 27017:27017
+    environment:
+      MONGO_INITDB_ROOT_USERNAME: kie
+      MONGO_INITDB_ROOT_PASSWORD: 123
+
+  mongo-express:
+    image: mongo-express
+    restart: always
+    ports:
+      - 8081:8081
+    environment:
+      ME_CONFIG_MONGODB_ADMINUSERNAME: kie
+      ME_CONFIG_MONGODB_ADMINPASSWORD: 123
\ No newline at end of file
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..da3d3eb
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,16 @@
+module github.com/apache/servicecomb-kie
+
+require (
+	github.com/go-chassis/go-archaius v0.14.0
+	github.com/go-chassis/go-chassis v1.4.0 // indirect
+	github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2
+	github.com/go-mesh/openlogging v1.0.1-0.20181205082104-3d418c478b2d
+	github.com/onsi/ginkgo v1.8.0
+	github.com/onsi/gomega v1.5.0
+	github.com/stretchr/testify v1.2.2
+	github.com/urfave/cli v1.20.0 // indirect
+	github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
+	github.com/xdg/stringprep v1.0.0 // indirect
+	go.mongodb.org/mongo-driver v1.0.0
+	gopkg.in/yaml.v2 v2.2.1
+)
diff --git a/pkg/model/kv.go b/pkg/model/kv.go
new file mode 100644
index 0000000..1c31fc0
--- /dev/null
+++ b/pkg/model/kv.go
@@ -0,0 +1,49 @@
+/*
+ * 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 model
+
+import (
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+type Labels map[string]string
+
+//func (m Labels) ToString() string {
+//	sb := strings.Builder{}
+//	for k, v := range m {
+//		sb.WriteString(k + "=" + v + ",")
+//	}
+//	return sb.String()
+//}
+
+type KV struct {
+	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
+	Key       string             `json:"key"`
+	Value     string             `json:"value"`
+	ValueType string             `json:"valueType"`        //ini,json,text,yaml,properties
+	Domain    string             `json:"domain"`           //tenant info
+	Labels    map[string]string  `json:"labels,omitempty"` //key has labels
+	Checker   string             `json:"check,omitempty"`  //python script
+	Revision  int                `json:"revision"`
+}
+type KVHistory struct {
+	KID      string `json:"id,omitempty" bson:"kvID"`
+	Value    string `json:"value"`
+	Checker  string `json:"check,omitempty"` //python script
+	Revision int    `json:"revision"`
+}
diff --git a/pkg/model/kv_test.go b/pkg/model/kv_test.go
new file mode 100644
index 0000000..cbb05c0
--- /dev/null
+++ b/pkg/model/kv_test.go
@@ -0,0 +1,45 @@
+/*
+ * 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 model_test
+
+import (
+	"encoding/json"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestKV_UnmarshalJSON(t *testing.T) {
+	kv := &model.KV{
+		Value: "test",
+		Labels: map[string]string{
+			"test": "env",
+		},
+	}
+	b, _ := json.Marshal(kv)
+	t.Log(string(b))
+
+	var kv2 model.KV
+	err := json.Unmarshal([]byte(` 
+        {"value": "1","labels":{"test":"env"}}
+    `), &kv2)
+	assert.NoError(t, err)
+	assert.Equal(t, "env", kv2.Labels["test"])
+	assert.Equal(t, "1", kv2.Value)
+
+}
diff --git a/server/config/config.go b/server/config/config.go
new file mode 100644
index 0000000..7e03731
--- /dev/null
+++ b/server/config/config.go
@@ -0,0 +1,44 @@
+/*
+ * 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 config
+
+import (
+	"github.com/go-chassis/go-archaius"
+	"github.com/go-chassis/go-archaius/sources/file-source"
+	"gopkg.in/yaml.v2"
+	"path/filepath"
+)
+
+var configurations *Config
+
+func Init(file string) error {
+	if err := archaius.AddFile(file, archaius.WithFileHandler(filesource.UseFileNameAsKeyContentAsValue)); err != nil {
+		return err
+	}
+	_, filename := filepath.Split(file)
+	content := archaius.GetString(filename, "")
+	configurations = &Config{}
+	if err := yaml.Unmarshal([]byte(content), configurations); err != nil {
+		return err
+	}
+	return nil
+}
+
+func GetDB() DB {
+	return configurations.DB
+}
diff --git a/server/config/config_test.go b/server/config/config_test.go
new file mode 100644
index 0000000..75ca3ae
--- /dev/null
+++ b/server/config/config_test.go
@@ -0,0 +1,51 @@
+/*
+ * 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 config_test
+
+import (
+	"github.com/apache/servicecomb-kie/server/config"
+	"github.com/go-chassis/go-archaius"
+	"github.com/stretchr/testify/assert"
+	"io"
+	"os"
+	"testing"
+)
+
+func TestInit(t *testing.T) {
+	err := archaius.Init()
+	assert.NoError(t, err)
+	b := []byte(`
+db:
+  uri: mongodb://admin:123@127.0.0.1:27017/kie
+  type: mongodb
+  poolSize: 10
+  ssl: false
+  sslCA:
+  sslCert:
+
+`)
+	defer os.Remove("test.yaml")
+	f1, err := os.Create("test.yaml")
+	assert.NoError(t, err)
+	_, err = io.WriteString(f1, string(b))
+	assert.NoError(t, err)
+	err = config.Init("test.yaml")
+	assert.NoError(t, err)
+	assert.Equal(t, 10, config.GetDB().PoolSize)
+	assert.Equal(t, "mongodb://admin:123@127.0.0.1:27017/kie", config.GetDB().URI)
+}
diff --git a/server/config/struct.go b/server/config/struct.go
new file mode 100644
index 0000000..cbfb644
--- /dev/null
+++ b/server/config/struct.go
@@ -0,0 +1,29 @@
+/*
+ * 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 config
+
+type Config struct {
+	DB DB `yaml:"db"`
+}
+type DB struct {
+	URI      string   `yaml:"uri"`
+	PoolSize int      `yaml:"poolSize"`
+	SSL      bool     `yaml:"ssl"`
+	CABundle []string `yaml:"sslCA"`
+	Cert     string   `yaml:"sslCert"`
+}
diff --git a/server/kv/errors.go b/server/kv/errors.go
new file mode 100644
index 0000000..958a015
--- /dev/null
+++ b/server/kv/errors.go
@@ -0,0 +1,35 @@
+/*
+ * 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 kv
+
+import (
+	"errors"
+	"fmt"
+
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/go-mesh/openlogging"
+)
+
+//ErrAction will wrap raw error to biz error and return
+//it record audit log for mongodb operation failure like find, insert, update, deletion
+func ErrAction(action, key string, labels model.Labels, domain string, err error) error {
+	msg := fmt.Sprintf("can not [%s] [%s] in [%s] with [%s],err: %s", action, key, domain, labels, err.Error())
+	openlogging.Error(msg)
+	return errors.New(msg)
+
+}
diff --git a/server/kv/kv.go b/server/kv/kv.go
new file mode 100644
index 0000000..9513e60
--- /dev/null
+++ b/server/kv/kv.go
@@ -0,0 +1,62 @@
+/*
+ * 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 kv
+
+import (
+	"crypto/tls"
+	"errors"
+	"time"
+	"github.com/apache/servicecomb-kie/server/config"
+	"github.com/apache/servicecomb-kie/pkg/model"
+)
+
+var ErrMissingDomain = errors.New("domain info missing, illegal access")
+var ErrNotExists = errors.New("key with labels does not exits")
+var ErrTooMany = errors.New("key with labels should be only one")
+var ErrKeyMustNotEmpty = errors.New("must supply key if you want to get exact one result")
+
+type Service interface {
+	CreateOrUpdate(kv *model.KV) (*model.KV, error)
+	//do not use primitive.ObjectID as return to decouple with mongodb, we can afford perf lost
+	Exist(key, domain string, labels model.Labels) (string, error)
+	DeleteByID(id string) error
+	Delete(key, domain string, labels model.Labels) error
+	Find(domain string, options ...CallOption) ([]*model.KV, error)
+	AddHistory(kv *model.KV) error
+	//RollBack(kv *KV, version string) error
+}
+
+type Options struct {
+	URI      string
+	PoolSize int
+	SSL      bool
+	TLS      *tls.Config
+	Timeout  time.Duration
+}
+
+func NewKVService() (Service, error) {
+	opts := Options{
+		URI:      config.GetDB().URI,
+		PoolSize: config.GetDB().PoolSize,
+		SSL:      config.GetDB().SSL,
+	}
+	if opts.SSL {
+
+	}
+	return NewMongoService(opts)
+}
diff --git a/server/kv/kv_test.go b/server/kv/kv_test.go
new file mode 100644
index 0000000..4bdd043
--- /dev/null
+++ b/server/kv/kv_test.go
@@ -0,0 +1,192 @@
+/*
+ * 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 kv_test
+
+import (
+	. "github.com/apache/servicecomb-kie/pkg/model"
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/gomega"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/apache/servicecomb-kie/server/kv"
+)
+
+var _ = Describe("Kv mongodb service", func() {
+	var s kv.Service
+	var err error
+	Describe("connecting db", func() {
+		s, err = kv.NewMongoService(kv.Options{
+			URI: "mongodb://kie:123@127.0.0.1:27017",
+		})
+		It("should not return err", func() {
+			Expect(err).Should(BeNil())
+		})
+	})
+
+	Describe("put kv timeout", func() {
+		Context("with labels app and service", func() {
+			kv, err := s.CreateOrUpdate(&model.KV{
+				Key:    "timeout",
+				Value:  "2s",
+				Domain: "default",
+				Labels: map[string]string{
+					"app":     "mall",
+					"service": "cart",
+				},
+			})
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has revision", func() {
+				Expect(kv.Revision).ShouldNot(BeZero())
+			})
+			It("should has ID", func() {
+				Expect(kv.ID.Hex()).ShouldNot(BeEmpty())
+			})
+
+		})
+		Context("with labels app, service and version", func() {
+			kv, err := s.CreateOrUpdate(&KV{
+				Key:    "timeout",
+				Value:  "2s",
+				Domain: "default",
+				Labels: map[string]string{
+					"app":     "mall",
+					"service": "cart",
+					"version": "1.0.0",
+				},
+			})
+			oid, err := s.Exist("timeout", "default", map[string]string{
+				"app":     "mall",
+				"service": "cart",
+				"version": "1.0.0",
+			})
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has revision", func() {
+				Expect(kv.Revision).ShouldNot(BeZero())
+			})
+			It("should has ID", func() {
+				Expect(kv.ID.Hex()).ShouldNot(BeEmpty())
+			})
+			It("should exist", func() {
+				Expect(oid).ShouldNot(BeEmpty())
+			})
+		})
+		Context("with labels app,and update value", func() {
+			beforeKV, err := s.CreateOrUpdate(&KV{
+				Key:    "timeout",
+				Value:  "1s",
+				Domain: "default",
+				Labels: map[string]string{
+					"app": "mall",
+				},
+			})
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			kvs1, err := s.Find("default", kv.WithKey("timeout"), kv.WithLabels(map[string]string{
+				"app": "mall",
+			}), kv.WithExactLabels())
+			It("should be 1s", func() {
+				Expect(kvs1[0].Value).Should(Equal(beforeKV.Value))
+			})
+			afterKV, err := s.CreateOrUpdate(&KV{
+				Key:    "timeout",
+				Value:  "3s",
+				Domain: "default",
+				Labels: map[string]string{
+					"app": "mall",
+				},
+			})
+			It("should has same id", func() {
+				Expect(afterKV.ID.Hex()).Should(Equal(beforeKV.ID.Hex()))
+			})
+			oid, err := s.Exist("timeout", "default", map[string]string{
+				"app": "mall",
+			})
+			It("should exists", func() {
+				Expect(oid).Should(Equal(beforeKV.ID.Hex()))
+			})
+			kvs, err := s.Find("default", kv.WithKey("timeout"), kv.WithLabels(map[string]string{
+				"app": "mall",
+			}), kv.WithExactLabels())
+			It("should be 3s", func() {
+				Expect(kvs[0].Value).Should(Equal(afterKV.Value))
+			})
+		})
+	})
+
+	Describe("greedy find by kv and labels", func() {
+		Context("with labels app ", func() {
+			kvs, err := s.Find("default", kv.WithKey("timeout"), kv.WithLabels(map[string]string{
+				"app": "mall",
+			}))
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has 3 records", func() {
+				Expect(len(kvs)).Should(Equal(3))
+			})
+
+		})
+	})
+	Describe("exact find by kv and labels", func() {
+		Context("with labels app ", func() {
+			kvs, err := s.Find("default", kv.WithKey("timeout"), kv.WithLabels(map[string]string{
+				"app": "mall",
+			}), kv.WithExactLabels())
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has 1 records", func() {
+				Expect(len(kvs)).Should(Equal(1))
+			})
+
+		})
+	})
+	Describe("exact find by labels", func() {
+		Context("with labels app ", func() {
+			kvs, err := s.Find("default", kv.WithLabels(map[string]string{
+				"app": "mall",
+			}), kv.WithExactLabels())
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has 1 records", func() {
+				Expect(len(kvs)).Should(Equal(1))
+			})
+
+		})
+	})
+	Describe("greedy find by labels", func() {
+		Context("with labels app ans service ", func() {
+			kvs, err := s.Find("default", kv.WithLabels(map[string]string{
+				"app":     "mall",
+				"service": "cart",
+			}))
+			It("should not return err", func() {
+				Expect(err).Should(BeNil())
+			})
+			It("should has 2 records", func() {
+				Expect(len(kvs)).Should(Equal(2))
+			})
+
+		})
+	})
+})
diff --git a/server/kv/model_suite_test.go b/server/kv/model_suite_test.go
new file mode 100644
index 0000000..965802e
--- /dev/null
+++ b/server/kv/model_suite_test.go
@@ -0,0 +1,44 @@
+/*
+ * 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 kv_test
+
+import (
+	"testing"
+
+	"github.com/go-chassis/paas-lager"
+	"github.com/go-mesh/openlogging"
+	. "github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/reporters"
+	. "github.com/onsi/gomega"
+)
+
+func TestModel(t *testing.T) {
+	RegisterFailHandler(Fail)
+	junitReporter := reporters.NewJUnitReporter("junit.xml")
+	RunSpecsWithDefaultAndCustomReporters(t, "Model Suite", []Reporter{junitReporter})
+}
+
+var _ = BeforeSuite(func() {
+	log.Init(log.Config{
+		Writers:     []string{"stdout"},
+		LoggerLevel: "DEBUG",
+	})
+
+	logger := log.NewLogger("ut")
+	openlogging.SetLogger(logger)
+})
diff --git a/server/kv/mongodb.go b/server/kv/mongodb.go
new file mode 100644
index 0000000..37664ae
--- /dev/null
+++ b/server/kv/mongodb.go
@@ -0,0 +1,304 @@
+/*
+ * 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 kv
+
+import (
+	"context"
+	"fmt"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/go-mesh/openlogging"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
+	"go.mongodb.org/mongo-driver/mongo/options"
+	"time"
+)
+
+var client *mongo.Client
+
+const (
+	DB                 = "kie"
+	CollectionKV       = "kv"
+	CollectionRevision = "revision"
+	DefaultTimeout     = 5 * time.Second
+	DefaultValueType   = "text"
+)
+
+type MongodbService struct {
+	c       *mongo.Client
+	timeout time.Duration
+}
+
+func (s *MongodbService) CreateOrUpdate(kv *model.KV) (*model.KV, error) {
+	if kv.Domain == "" {
+		return nil, ErrMissingDomain
+	}
+	ctx, _ := context.WithTimeout(context.Background(), DefaultTimeout)
+	collection := s.c.Database(DB).Collection(CollectionKV)
+	oid, err := s.Exist(kv.Key, kv.Domain, kv.Labels)
+	if err != nil {
+		if err != ErrNotExists {
+			return nil, err
+		}
+	}
+	if oid != "" {
+		hex, err := primitive.ObjectIDFromHex(oid)
+		if err != nil {
+			openlogging.Error(fmt.Sprintf("convert %s ,err:%s", oid, err))
+			return nil, err
+		}
+		kv.ID = hex
+		if err := s.update(ctx, collection, kv); err != nil {
+			return nil, err
+		}
+		return kv, nil
+	}
+	if kv.ValueType == "" {
+		kv.ValueType = DefaultValueType
+	}
+	//set 1 to revision for insertion
+	kv.Revision = 1
+	res, err := collection.InsertOne(ctx, kv)
+	if err != nil {
+		return nil, err
+	}
+	objectID, _ := res.InsertedID.(primitive.ObjectID)
+	kv.ID = objectID
+	if err := s.AddHistory(kv); err != nil {
+		openlogging.Warn(
+			fmt.Sprintf("can not update version for [%s] [%s] in [%s]",
+				kv.Key, kv.Labels, kv.Domain))
+	}
+	openlogging.Debug(fmt.Sprintf("create %s with labels %s value [%s]", kv.Key, kv.Labels, kv.Value))
+	return kv, nil
+}
+
+//update get latest revision from history
+//and increase revision
+//and update and them add new history
+func (s *MongodbService) update(ctx context.Context, collection *mongo.Collection, kv *model.KV) error {
+	h, err := s.getLatest(kv.ID)
+	if err != nil {
+		openlogging.Error(fmt.Sprintf("get latest [%s][%s] in [%s],err: %s",
+			kv.Key, kv.Labels, kv.Domain, err.Error()))
+		return err
+	}
+	if h != nil {
+		kv.Revision = h.Revision + 1
+	}
+	ur, err := collection.UpdateOne(ctx, bson.M{"_id": kv.ID}, bson.D{
+		{"$set", bson.D{
+			{"value", kv.Value},
+			{"revision", kv.Revision},
+			{"checker", kv.Checker},
+		}},
+	})
+	if err != nil {
+		return err
+	}
+	openlogging.Debug(
+		fmt.Sprintf("update %s with labels %s value [%s] %d ",
+			kv.Key, kv.Labels, kv.Value, ur.ModifiedCount))
+	if err := s.AddHistory(kv); err != nil {
+		openlogging.Warn(
+			fmt.Sprintf("can not update version for [%s] [%s] in [%s]",
+				kv.Key, kv.Labels, kv.Domain))
+	}
+	openlogging.Debug(
+		fmt.Sprintf("add history %s with labels %s value [%s] %d ",
+			kv.Key, kv.Labels, kv.Value, ur.ModifiedCount))
+	return nil
+
+}
+func (s *MongodbService) Exist(key, domain string, labels model.Labels) (string, error) {
+	kvs, err := s.Find(domain, WithExactLabels(), WithLabels(labels), WithKey(key))
+	if err != nil {
+		return "", err
+	}
+	if len(kvs) != 1 {
+		return "", ErrTooMany
+	}
+
+	return kvs[0].ID.Hex(), nil
+
+}
+
+//Find get kvs by key, labels
+//because labels has a a lot of combination,
+//you can use WithExactLabels to return only one kv which's labels exactly match the criteria
+func (s *MongodbService) Find(domain string, options ...CallOption) ([]*model.KV, error) {
+	opts := CallOptions{}
+	for _, o := range options {
+		o(&opts)
+	}
+	if domain == "" {
+		return nil, ErrMissingDomain
+	}
+	collection := s.c.Database(DB).Collection(CollectionKV)
+	ctx, _ := context.WithTimeout(context.Background(), DefaultTimeout)
+	filter := bson.M{"domain": domain}
+	if opts.Key != "" {
+		filter["key"] = opts.Key
+	}
+	for k, v := range opts.Labels {
+		filter["labels."+k] = v
+	}
+
+	cur, err := collection.Find(ctx, filter)
+	if err != nil {
+		if err.Error() == context.DeadlineExceeded.Error() {
+			return nil, ErrAction("find", opts.Key, opts.Labels, domain, fmt.Errorf("can not reach mongodb in %s", s.timeout))
+		}
+		return nil, err
+	}
+	defer cur.Close(ctx)
+	if cur.Err() != nil {
+		return nil, err
+	}
+	if opts.ExactLabels {
+		openlogging.Debug(fmt.Sprintf("find one [%s] with lables [%s] in [%s]", opts.Key, opts.Labels, domain))
+		curKV := &model.KV{} //reuse this pointer to reduce GC, only clear label
+		//check label length to get the exact match
+		for cur.Next(ctx) { //although complexity is O(n), but there won't be so much labels for one key
+			curKV.Labels = nil
+			err := cur.Decode(curKV)
+			if err != nil {
+				openlogging.Error("decode error: " + err.Error())
+				return nil, err
+			}
+			if len(curKV.Labels) == len(opts.Labels) {
+				openlogging.Debug("hit")
+				return []*model.KV{curKV}, nil
+			}
+
+		}
+		return nil, ErrNotExists
+	} else {
+		kvs := make([]*model.KV, 0)
+		for cur.Next(ctx) {
+			curKV := &model.KV{}
+			if err := cur.Decode(curKV); err != nil {
+				openlogging.Error("decode to KVs error: " + err.Error())
+				return nil, err
+			}
+			kvs = append(kvs, curKV)
+
+		}
+		if len(kvs) == 0 {
+			return nil, ErrNotExists
+		}
+		return kvs, nil
+	}
+
+}
+func (s *MongodbService) DeleteByID(id string) error {
+	collection := s.c.Database(DB).Collection(CollectionKV)
+	hex, err := primitive.ObjectIDFromHex(id)
+	if err != nil {
+		openlogging.Error(fmt.Sprintf("convert %s ,err:%s", id, err))
+		return err
+	}
+	ctx, _ := context.WithTimeout(context.Background(), DefaultTimeout)
+	dr, err := collection.DeleteOne(ctx, bson.M{"_id": hex})
+	if err != nil {
+		openlogging.Error(fmt.Sprintf("delete [%s] failed: %s", hex, err))
+	}
+	if dr.DeletedCount != 1 {
+		openlogging.Warn(fmt.Sprintf("delete [%s], but it is not exist", hex))
+	}
+	return nil
+}
+
+func (s *MongodbService) Delete(key, domain string, labels model.Labels) error {
+	return nil
+}
+func (s *MongodbService) AddHistory(kv *model.KV) error {
+	collection := s.c.Database(DB).Collection(CollectionRevision)
+	ctx, _ := context.WithTimeout(context.Background(), DefaultTimeout)
+	h := &model.KVHistory{
+		KID:      kv.ID.Hex(),
+		Value:    kv.Value,
+		Revision: kv.Revision,
+		Checker:  kv.Checker,
+	}
+	_, err := collection.InsertOne(ctx, h)
+	if err != nil {
+		openlogging.Error(err.Error())
+		return err
+	}
+	return nil
+}
+func (s *MongodbService) getLatest(id primitive.ObjectID) (*model.KVHistory, error) {
+	collection := s.c.Database(DB).Collection(CollectionRevision)
+	ctx, _ := context.WithTimeout(context.Background(), DefaultTimeout)
+
+	filter := bson.M{"kvID": id.Hex()}
+
+	cur, err := collection.Find(ctx, filter,
+		options.Find().SetSort(map[string]interface{}{
+			"revision": -1,
+		}), options.Find().SetLimit(1))
+	if err != nil {
+		return nil, err
+	}
+	h := &model.KVHistory{}
+	var exist bool
+	for cur.Next(ctx) {
+		if err := cur.Decode(h); err != nil {
+			openlogging.Error("decode to KVs error: " + err.Error())
+			return nil, err
+		}
+		exist = true
+		break
+	}
+	if !exist {
+		return nil, nil
+	}
+	return h, nil
+}
+func NewMongoService(opts Options) (Service, error) {
+	if opts.Timeout == 0 {
+		opts.Timeout = DefaultTimeout
+	}
+	c, err := getClient(opts)
+	if err != nil {
+		return nil, err
+	}
+	m := &MongodbService{
+		c:       c,
+		timeout: opts.Timeout,
+	}
+	return m, nil
+}
+func getClient(opts Options) (*mongo.Client, error) {
+	if client == nil {
+		var err error
+		client, err = mongo.NewClient(options.Client().ApplyURI(opts.URI))
+		if err != nil {
+			return nil, err
+		}
+		openlogging.Info("connecting to " + opts.URI)
+		ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
+		err = client.Connect(ctx)
+		if err != nil {
+			return nil, err
+		}
+		openlogging.Info("connected to " + opts.URI)
+	}
+	return client, nil
+}
diff --git a/server/kv/options.go b/server/kv/options.go
new file mode 100644
index 0000000..aabe1ec
--- /dev/null
+++ b/server/kv/options.go
@@ -0,0 +1,49 @@
+/*
+ * 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 kv
+
+import "github.com/apache/servicecomb-kie/pkg/model"
+
+type CallOptions struct {
+	ExactLabels bool
+	Key         string
+	Labels      model.Labels
+}
+
+type CallOption func(*CallOptions)
+
+//WithExactLabels tell model service to return only one kv matches the labels
+func WithExactLabels() CallOption {
+	return func(o *CallOptions) {
+		o.ExactLabels = true
+	}
+}
+
+//WithKey find by key
+func WithKey(key string) CallOption {
+	return func(o *CallOptions) {
+		o.Key = key
+	}
+}
+
+//WithLabels find kv by labels
+func WithLabels(labels model.Labels) CallOption {
+	return func(o *CallOptions) {
+		o.Labels = labels
+	}
+}


[servicecomb-kie] 02/06: add project introduction

Posted by li...@apache.org.
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

commit bfc05b37c9e710f2f3997b18b6203421899dcacd
Author: tian <xi...@gmail.com>
AuthorDate: Mon Apr 29 15:23:44 2019 +0800

    add project introduction
---
 README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 91353db..244cf63 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,66 @@
 # Apache-ServiceComb-Kie
 
-Introduction of the project
+A service for key value management in distributed system.
+
+## Conceptions
+
+### Key
+key could indicate a configuration like "timeout",
+then the value could be "3s"
+or indicates a file name "app.properties", 
+then the value could be content of app.properties
+
+### labels
+Each key could has labels. labels indicates a unique key.
+A key "log_level" with labels "env=production" 
+may saves the value "INFO" for all application log level in production environment.
+A key "log_level" with labels "env=production, component=payment" 
+may saves the value "DEBUG" for payment service in production environment.
+
+it means all payment service print debug log, but for other service print info log.
+
+so you can control your application runtime behaviors 
+by setting different labels to a key.
+
+
+
+## Components
+it includes 5 components
+
+- server: rest api service to manage kv
+- client: restful client for go
+- kie-template: agent can be deployed in your k8s pod 
+or VM, it connects to server and writes kv into config file 
+based on template language
+- kiectl: CLI tool for kie
+- frontend: web console for kie
 
 ## Features
 
+TODO
+- simple key name with rich labels: user can define labels for a key, 
+that distinguish from key to another key.  
+a key will not be stringed by fixed schema. 
+labels for a key is like "env=test, service=cart, version=1.0" or "cluster=xxx"  
+or "env=test, service=cart, version=1.0, ip=x.x.x.x"
+- validator: value can be checked by user defined python script, 
+so in runtime if someone want to change this value, 
+the script will check if this value is appropriate.
+- encryption web hook: value can by encrypt 
+by your custom encryption service like vault.
+- Long polling: client can get key value changes by long polling
+- config view: by setting labels criteria, servicecomb-kie 
+is able to aggregate a view to return all key values which match those labels, 
+so that operator can mange key in their own understanding 
+to a distributed system in separated views.
+- rich value type: not only plain text, but support to be aware of ini, json,yaml,xml and java properties
+- heterogeneous config server: able to fetch configuration in k8s and consul 
+ even more, you can update, delete, 
+ and use config view for those systems, 
+ and you can integrate with your own config system to MetaConfig by 
+ following standardized API and model
+- consul compatible: partially compatible with consul kv management API
+- kv change history: all kv changes is recorded and can be easily roll back by UI
 ## Quick Start
 
 ## Contact


[servicecomb-kie] 05/06: fix based on comments

Posted by li...@apache.org.
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

commit 65b7c24d6ae13148b2dc463460d2aaa8bdedff32
Author: tian <xi...@gmail.com>
AuthorDate: Tue May 7 20:16:45 2019 +0800

    fix based on comments
---
 deployments/docker/docker-compose.yaml | 16 ++++++++++++++++
 pkg/model/kv.go                        |  8 --------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml
index 2c87590..700fa28 100644
--- a/deployments/docker/docker-compose.yaml
+++ b/deployments/docker/docker-compose.yaml
@@ -1,3 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.1'
 services:
   mongo:
diff --git a/pkg/model/kv.go b/pkg/model/kv.go
index 1c31fc0..042cd20 100644
--- a/pkg/model/kv.go
+++ b/pkg/model/kv.go
@@ -23,14 +23,6 @@ import (
 
 type Labels map[string]string
 
-//func (m Labels) ToString() string {
-//	sb := strings.Builder{}
-//	for k, v := range m {
-//		sb.WriteString(k + "=" + v + ",")
-//	}
-//	return sb.String()
-//}
-
 type KV struct {
 	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
 	Key       string             `json:"key"`


[servicecomb-kie] 03/06: Add project introduction

Posted by li...@apache.org.
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

commit a1c07008c8f7cc2e2eb1918266980322b0b73101
Merge: e66eaec bfc05b3
Author: Willem Jiang <ji...@huawei.com>
AuthorDate: Mon Apr 29 15:54:27 2019 +0800

    Add project introduction
    
    add project introduction

 README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)