@ -1,8 +1,6 @@ |
||||
# Summary |
||||
|
||||
* [介绍](README.md) |
||||
* [快速开始](quickstart.md) |
||||
* [案例](https://github.com/go-kratos/kratos-demo) |
||||
* [快速开始 - 项目初始化](quickstart.md) |
||||
* [FAQ](FAQ.md) |
||||
* [http blademaster](blademaster.md) |
||||
* [bm quickstart](blademaster-quickstart.md) |
||||
* [bm module](blademaster-mod.md) |
@ -0,0 +1,42 @@ |
||||
# 开始使用 |
||||
|
||||
## 配置 |
||||
|
||||
进入项目中的configs目录,mysql.toml,我们可以看到: |
||||
|
||||
```toml |
||||
[demo] |
||||
addr = "127.0.0.1:3306" |
||||
dsn = "{user}:{password}@tcp(127.0.0.1:3306)/{database}?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8" |
||||
readDSN = ["{user}:{password}@tcp(127.0.0.2:3306)/{database}?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8","{user}:{password}@tcp(127.0.0.3:3306)/{database}?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8,utf8mb4"] |
||||
active = 20 |
||||
idle = 10 |
||||
idleTimeout ="4h" |
||||
queryTimeout = "200ms" |
||||
execTimeout = "300ms" |
||||
tranTimeout = "400ms" |
||||
``` |
||||
|
||||
在该配置文件中我们可以配置mysql的读和写的dsn、连接地址addr、连接池的闲置连接数idle、最大连接数active以及各类超时。 |
||||
|
||||
如果配置了readDSN,在进行读操作的时候会优先使用readDSN的连接。 |
||||
|
||||
## 初始化 |
||||
|
||||
进入项目的internal/dao目录,打开db.go,其中: |
||||
|
||||
```go |
||||
var cfg struct { |
||||
Client *sql.Config |
||||
} |
||||
checkErr(paladin.Get("db.toml").UnmarshalTOML(&dc)) |
||||
``` |
||||
使用paladin配置管理工具将上文中的db.toml中的配置解析为我们需要使用db的相关配置。 |
||||
|
||||
# TODO:补充常用方法 |
||||
|
||||
# 扩展阅读 |
||||
|
||||
[tidb模块说明](database-tidb.md) |
||||
[hbase模块说明](database-hbase.md) |
||||
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 661 KiB After Width: | Height: | Size: 661 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
@ -0,0 +1,30 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>Document</title> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> |
||||
<meta name="description" content="Description"> |
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> |
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css"> |
||||
</head> |
||||
<body> |
||||
<div id="app"></div> |
||||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script> |
||||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script> |
||||
<script src="//cdn.jsdelivr.net/npm/docsify-edit-on-github"></script> |
||||
<script> |
||||
window.$docsify = { |
||||
loadSidebar: true, |
||||
auto2top: true, |
||||
autoHeader: true, |
||||
name: 'go-kratos/kratos', |
||||
repo: 'https://github.com/go-kratos/kratos', |
||||
search: 'auto', |
||||
plugins: [ |
||||
EditOnGithubPlugin.create('https://github.com/go-kratos/kratos/blob/master/docs/') |
||||
] |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
@ -1,4 +1,4 @@ |
||||
## testing/lich 运行环境构建 |
||||
基于 docker-compose 实现跨平台跨语言环境的容器依赖管理方案,以解决运行ut场景下的 (mysql, redis, mc)容器依赖问题。 |
||||
|
||||
使用说明参见:https://github.com/go-kratos/kratos/tree/master/tool/testcli/README.md |
||||
使用说明参见:https://go-kratos.github.io/kratos/#/ut |