From f5d91d6d8c2c860e928c7a496911994cc352435f Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 10 Jun 2019 10:44:46 +0800 Subject: [PATCH 1/2] add hbase doc --- doc/wiki-cn/database-hbase.md | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/doc/wiki-cn/database-hbase.md b/doc/wiki-cn/database-hbase.md index e69de29bb..56ff268e7 100644 --- a/doc/wiki-cn/database-hbase.md +++ b/doc/wiki-cn/database-hbase.md @@ -0,0 +1,50 @@ +# database/hbase + +## 说明 +Hbase Client,进行封装加入了链路追踪和统计。 + +## 配置 +需要指定hbase集群的zookeeper地址。 +``` +config := &hbase.Config{Zookeeper: &hbase.ZKConfig{Addrs: []string{"localhost"}}} +client := hbase.NewClient(config) +``` + +## 使用方式 +``` +package main + +import ( + "context" + "fmt" + + "github.com/bilibili/kratos/pkg/database/hbase" +) + +func main() { + config := &hbase.Config{Zookeeper: &hbase.ZKConfig{Addrs: []string{"localhost"}}} + client := hbase.NewClient(config) + + // + values := map[string]map[string][]byte{"name": {"firstname": []byte("hello"), "lastname": []byte("world")}} + ctx := context.Background() + + // 写入信息 + // table: user + // rowkey: user1 + // values["family"] = columns + _, err := client.PutStr(ctx, "user", "user1", values) + if err != nil { + panic(err) + } + + // 读取信息 + // table: user + // rowkey: user1 + result, err := client.GetStr(ctx, "user", "user1") + if err != nil { + panic(err) + } + fmt.Printf("%v", result) +} +``` From 39e7ce15e2027f04893bd4939137e5f6c22ae44f Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 10 Jun 2019 11:02:22 +0800 Subject: [PATCH 2/2] add database doc --- doc/wiki-cn/database.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/wiki-cn/database.md b/doc/wiki-cn/database.md index e69de29bb..8082dd117 100644 --- a/doc/wiki-cn/database.md +++ b/doc/wiki-cn/database.md @@ -0,0 +1,13 @@ +# database/sql + +## 说明 +数据库驱动,进行封装加入了链路追踪和统计,以及链路超时。 + +## MySQL +[mysql](database-mysql.md) + +## HBase +[hbase](database-hbase.md) + +## TiDB +[tidb](database-tidb.md)