mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-24 03:46:37 +02:00
replace pkg name to go-kratos
This commit is contained in:
parent
5a3f4b95d7
commit
9e060edc2d
10
README.md
10
README.md
@ -1,9 +1,9 @@
|
||||
![kratos](doc/img/kratos3.png)
|
||||
|
||||
[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)
|
||||
[![Build Status](https://travis-ci.org/bilibili/kratos.svg?branch=master)](https://travis-ci.org/bilibili/kratos)
|
||||
[![GoDoc](https://godoc.org/github.com/bilibili/kratos?status.svg)](https://godoc.org/github.com/bilibili/kratos)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/bilibili/kratos)](https://goreportcard.com/report/github.com/bilibili/kratos)
|
||||
[![Build Status](https://travis-ci.org/go-kratos/kratos.svg?branch=master)](https://travis-ci.org/go-kratos/kratos)
|
||||
[![GoDoc](https://godoc.org/github.com/go-kratos/kratos?status.svg)](https://godoc.org/github.com/go-kratos/kratos)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/go-kratos/kratos)](https://goreportcard.com/report/github.com/go-kratos/kratos)
|
||||
|
||||
# Kratos
|
||||
|
||||
@ -33,12 +33,12 @@ Go version>=1.13
|
||||
|
||||
### Installation
|
||||
```shell
|
||||
GO111MODULE=on && go get -u github.com/bilibili/kratos/tool/kratos
|
||||
GO111MODULE=on && go get -u github.com/go-kratos/kratos/tool/kratos
|
||||
cd $GOPATH/src
|
||||
kratos new kratos-demo
|
||||
```
|
||||
|
||||
通过 `kratos new` 会快速生成基于kratos库的脚手架代码,如生成 [kratos-demo](https://github.com/bilibili/kratos-demo)
|
||||
通过 `kratos new` 会快速生成基于kratos库的脚手架代码,如生成 [kratos-demo](https://github.com/go-kratos/kratos-demo)
|
||||
|
||||
### Build & Run
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
执行
|
||||
```shell
|
||||
go get -u github.com/bilibili/kratos/tool/kratos
|
||||
go get -u github.com/go-kratos/kratos/tool/kratos
|
||||
```
|
||||
出现以下错误时
|
||||
```shell
|
||||
|
@ -76,7 +76,7 @@ engine.Use(YourMiddleware())
|
||||
|
||||
# 局部中间件
|
||||
|
||||
先来看一段鉴权伪代码示例([auth示例代码位置](https://github.com/bilibili/kratos/tree/master/example/blademaster/middleware/auth)):
|
||||
先来看一段鉴权伪代码示例([auth示例代码位置](https://github.com/go-kratos/kratos/tree/master/example/blademaster/middleware/auth)):
|
||||
|
||||
```go
|
||||
func Example() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
基于proto文件可以快速生成`bm`框架对应的代码,提前需要准备以下工作:
|
||||
|
||||
* 安装`kratos tool protoc`工具,请看[kratos工具](kratos-tool.md)
|
||||
* 编写`proto`文件,示例可参考[kratos-demo内proto文件](https://github.com/bilibili/kratos-demo/blob/master/api/api.proto)
|
||||
* 编写`proto`文件,示例可参考[kratos-demo内proto文件](https://github.com/go-kratos/kratos-demo/blob/master/api/api.proto)
|
||||
|
||||
### kratos工具说明
|
||||
|
||||
@ -31,7 +31,7 @@ service Demo {
|
||||
|
||||
# 使用
|
||||
|
||||
建议在项目`api`目录下编写`proto`文件及生成对应的代码,可参考[kratos-demo内的api目录](https://github.com/bilibili/kratos-demo/tree/master/api)。
|
||||
建议在项目`api`目录下编写`proto`文件及生成对应的代码,可参考[kratos-demo内的api目录](https://github.com/go-kratos/kratos-demo/tree/master/api)。
|
||||
|
||||
执行命令后生成的`api.bm.go`代码,注意其中的`type DemoBMServer interface`和`RegisterDemoBMServer`,其中:
|
||||
|
||||
@ -39,7 +39,7 @@ service Demo {
|
||||
* `RegisterDemoBMServer`方法提供注册`DemoBMServer`接口的实现对象,和`bm`的`Engine`用于注册路由
|
||||
* `DemoBMServer`接口的实现,一般为`internal/service`内的业务逻辑代码,需要实现`DemoBMServer`接口
|
||||
|
||||
使用`RegisterDemoBMServer`示例代码请参考[kratos-demo内的http](https://github.com/bilibili/kratos-demo/blob/master/internal/server/http/server.go)内的如下代码:
|
||||
使用`RegisterDemoBMServer`示例代码请参考[kratos-demo内的http](https://github.com/go-kratos/kratos-demo/blob/master/internal/server/http/server.go)内的如下代码:
|
||||
|
||||
```go
|
||||
engine = bm.DefaultServer(hc.Server)
|
||||
@ -47,7 +47,7 @@ pb.RegisterDemoBMServer(engine, svc)
|
||||
initRouter(engine)
|
||||
```
|
||||
|
||||
`internal/service`内的`Service`结构实现了`DemoBMServer`接口可参考[kratos-demo内的service](https://github.com/bilibili/kratos-demo/blob/master/internal/service/service.go)内的如下代码:
|
||||
`internal/service`内的`Service`结构实现了`DemoBMServer`接口可参考[kratos-demo内的service](https://github.com/go-kratos/kratos-demo/blob/master/internal/service/service.go)内的如下代码:
|
||||
|
||||
```go
|
||||
// SayHelloURL bm demo func.
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/database/hbase"
|
||||
"github.com/go-kratos/kratos/pkg/database/hbase"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
## 错误码之Codes
|
||||
|
||||
在`kratos`里,错误码被设计成`Codes`接口,声明如下[代码位置](https://github.com/bilibili/kratos/blob/master/pkg/ecode/ecode.go):
|
||||
在`kratos`里,错误码被设计成`Codes`接口,声明如下[代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/ecode/ecode.go):
|
||||
|
||||
```go
|
||||
// Codes ecode error interface which has a code & message.
|
||||
@ -47,9 +47,9 @@ fmt.Println(ecode.OK.Message()) // 输出:很好很强大!
|
||||
### Details
|
||||
|
||||
`Details`接口为`gRPC`预留,`gRPC`传递异常会将服务端的错误码pb序列化之后赋值给`Details`,客户端拿到之后反序列化得到,具体可阅读`status`的实现:
|
||||
1. `ecode`包内的`Status`结构体实现了`Codes`接口[代码位置](https://github.com/bilibili/kratos/blob/master/pkg/ecode/status.go)
|
||||
2. `warden/internal/status`包内包装了`ecode.Status`和`grpc.Status`进行互相转换的方法[代码位置](https://github.com/bilibili/kratos/blob/master/pkg/net/rpc/warden/internal/status/status.go)
|
||||
3. `warden`的`client`和`server`则使用转换方法将`gRPC`底层返回的`error`最终转换为`ecode.Status` [代码位置](https://github.com/bilibili/kratos/blob/master/pkg/net/rpc/warden/client.go#L162)
|
||||
1. `ecode`包内的`Status`结构体实现了`Codes`接口[代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/ecode/status.go)
|
||||
2. `warden/internal/status`包内包装了`ecode.Status`和`grpc.Status`进行互相转换的方法[代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/net/rpc/warden/internal/status/status.go)
|
||||
3. `warden`的`client`和`server`则使用转换方法将`gRPC`底层返回的`error`最终转换为`ecode.Status` [代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/net/rpc/warden/client.go#L162)
|
||||
|
||||
## 转换为ecode
|
||||
|
||||
@ -90,7 +90,7 @@ enum UserErrCode {
|
||||
package ecode
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
)
|
||||
|
||||
var _ ecode.Codes
|
||||
|
@ -47,7 +47,7 @@ go get google.golang.org/genproto/...
|
||||
6.安装kratos tool
|
||||
|
||||
```
|
||||
go get -u github.com/bilibili/kratos/tool/kratos
|
||||
go get -u github.com/go-kratos/kratos/tool/kratos
|
||||
cd $GOPATH/src
|
||||
kratos new kratos-demo --proto
|
||||
```
|
||||
|
@ -13,17 +13,17 @@ kratos tool protoc --ecode api.proto
|
||||
kratos tool protoc --swagger api.proto
|
||||
```
|
||||
|
||||
执行生成如 `api.pb.go/api.bm.go/api.swagger.json/api.ecode.go` 的对应文件,需要注意的是:`ecode`生成有固定规则,需要首先是`enum`类型,且`enum`名字要以`ErrCode`结尾,如`enum UserErrCode`。详情可见:[example](https://github.com/bilibili/kratos/tree/master/example/protobuf)
|
||||
执行生成如 `api.pb.go/api.bm.go/api.swagger.json/api.ecode.go` 的对应文件,需要注意的是:`ecode`生成有固定规则,需要首先是`enum`类型,且`enum`名字要以`ErrCode`结尾,如`enum UserErrCode`。详情可见:[example](https://github.com/go-kratos/kratos/tree/master/example/protobuf)
|
||||
|
||||
> 该工具在Windows/Linux下运行,需提前安装好 [protobuf](https://github.com/google/protobuf) 工具
|
||||
|
||||
`kratos tool protoc`本质上是拼接好了`protoc`命令然后进行执行,在执行时会打印出对应执行的`protoc`命令,如下可见:
|
||||
|
||||
```shell
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/bilibili/kratos/third_party --proto_path=. --bm_out=:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/bilibili/kratos/third_party --proto_path=. --gofast_out=plugins=grpc:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/bilibili/kratos/third_party --proto_path=. --bswagger_out=:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/bilibili/kratos/third_party --proto_path=. --ecode_out=:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/go-kratos/kratos/third_party --proto_path=. --bm_out=:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/go-kratos/kratos/third_party --proto_path=. --gofast_out=plugins=grpc:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/go-kratos/kratos/third_party --proto_path=. --bswagger_out=:. api.proto
|
||||
protoc --proto_path=$GOPATH --proto_path=$GOPATH/github.com/go-kratos/kratos/third_party --proto_path=. --ecode_out=:. api.proto
|
||||
```
|
||||
|
||||
-------------
|
||||
|
@ -6,7 +6,7 @@ kratos包含了一批好用的工具集,比如项目一键生成、基于proto
|
||||
|
||||
执行以下命令,即可快速安装好`kratos`工具
|
||||
```shell
|
||||
go get -u github.com/bilibili/kratos/tool/kratos
|
||||
go get -u github.com/go-kratos/kratos/tool/kratos
|
||||
```
|
||||
|
||||
那么接下来让我们快速开始熟悉工具的用法~
|
||||
@ -93,7 +93,7 @@ swagger(已安装): swagger api文档 Author(goswagger.io) [2019/05/05]
|
||||
安装全部工具: kratos tool install all
|
||||
全部升级: kratos tool upgrade all
|
||||
|
||||
详细文档: https://github.com/bilibili/kratos/blob/master/doc/wiki-cn/kratos-tool.md
|
||||
详细文档: https://github.com/go-kratos/kratos/blob/master/doc/wiki-cn/kratos-tool.md
|
||||
```
|
||||
|
||||
> 小小说明:如未安装工具,第一次运行也可自动安装,不需要特别执行install
|
||||
|
@ -3,12 +3,12 @@
|
||||
快速使用kratos项目,可以使用`kratos`工具,如下:
|
||||
|
||||
```shell
|
||||
go get -u github.com/bilibili/kratos/tool/kratos
|
||||
go get -u github.com/go-kratos/kratos/tool/kratos
|
||||
cd $GOPATH/src
|
||||
kratos new kratos-demo
|
||||
```
|
||||
|
||||
根据提示可以快速创建项目,如[kratos-demo](https://github.com/bilibili/kratos-demo)就是通过工具创建生成。目录结构如下:
|
||||
根据提示可以快速创建项目,如[kratos-demo](https://github.com/go-kratos/kratos-demo)就是通过工具创建生成。目录结构如下:
|
||||
|
||||
```
|
||||
├── CHANGELOG.md
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
* [介绍](README.md)
|
||||
* [快速开始](quickstart.md)
|
||||
* [案例](https://github.com/bilibili/kratos-demo)
|
||||
* [案例](https://github.com/go-kratos/kratos-demo)
|
||||
* [http blademaster](blademaster.md)
|
||||
* [bm quickstart](blademaster-quickstart.md)
|
||||
* [bm module](blademaster-mod.md)
|
||||
|
@ -19,14 +19,14 @@ kratos本身不提供整套`trace`数据方案,但在`net/trace/report.go`内
|
||||
|
||||
### zipkin使用
|
||||
|
||||
可以看[zipkin](https://github.com/bilibili/kratos/tree/master/pkg/net/trace/zipkin)的协议上报实现,具体使用方式如下:
|
||||
可以看[zipkin](https://github.com/go-kratos/kratos/tree/master/pkg/net/trace/zipkin)的协议上报实现,具体使用方式如下:
|
||||
|
||||
1. 前提是需要有一套自己搭建的`zipkin`集群
|
||||
2. 在业务代码的`main`函数内进行初始化,代码如下:
|
||||
|
||||
```go
|
||||
// 忽略其他代码
|
||||
import "github.com/bilibili/kratos/pkg/net/trace/zipkin"
|
||||
import "github.com/go-kratos/kratos/pkg/net/trace/zipkin"
|
||||
// 忽略其他代码
|
||||
func main(){
|
||||
// 忽略其他代码
|
||||
|
@ -146,7 +146,7 @@ func TestUsers(t *testing.T) {
|
||||
```
|
||||
|
||||
#### 使用建议
|
||||
强烈建议使用 [testgen](https://github.com/bilibili/kratos/blob/master/doc/wiki-cn/ut-testgen.md) 进行测试用例的生成,生成后每个方法将包含一个符合以下规范的正向用例。
|
||||
强烈建议使用 [testgen](https://github.com/go-kratos/kratos/blob/master/doc/wiki-cn/ut-testgen.md) 进行测试用例的生成,生成后每个方法将包含一个符合以下规范的正向用例。
|
||||
|
||||
用例规范:
|
||||
1. 每个方法至少包含一个测试方法(命名为Test[PackageName][FunctionName])
|
||||
|
@ -1,7 +1,7 @@
|
||||
## testcli UT运行环境构建工具
|
||||
基于 docker-compose 实现跨平台跨语言环境的容器依赖管理方案,以解决运行ut场景下的 (mysql, redis, mc)容器依赖问题。
|
||||
|
||||
*这个是testing/lich的二进制工具版本(Go请直接使用库版本:github.com/bilibili/kratos/pkg/testing/lich)*
|
||||
*这个是testing/lich的二进制工具版本(Go请直接使用库版本:github.com/go-kratos/kratos/pkg/testing/lich)*
|
||||
|
||||
### 功能和特性
|
||||
- 自动读取 test 目录下的 yaml 并启动依赖
|
||||
@ -14,18 +14,18 @@
|
||||
|
||||
#### Method 1. With go get
|
||||
```shell
|
||||
go get -u github.com/bilibili/kratos/tool/testcli
|
||||
go get -u github.com/go-kratos/kratos/tool/testcli
|
||||
$GOPATH/bin/testcli -h
|
||||
```
|
||||
#### Method 2. Build with Go
|
||||
```shell
|
||||
cd github.com/bilibili/kratos/tool/testcli
|
||||
cd github.com/go-kratos/kratos/tool/testcli
|
||||
go build -o $GOPATH/bin/testcli
|
||||
$GOPATH/bin/testcli -h
|
||||
```
|
||||
#### Method 3. Import with Kratos pkg
|
||||
```Go
|
||||
import "github.com/bilibili/kratos/pkg/testing/lich"
|
||||
import "github.com/go-kratos/kratos/pkg/testing/lich"
|
||||
```
|
||||
|
||||
### 构建数据
|
||||
@ -105,7 +105,7 @@ example:
|
||||
testcli -f ../../test/docker-compose.yaml run go test -v ./
|
||||
```
|
||||
#### Method 2. Import with Kratos pkg
|
||||
- Step1. 在 Dao|Service 层中的 TestMain 单测主入口中,import "github.com/bilibili/kratos/pkg/testing/lich" 引入testcli工具的go库版本。
|
||||
- Step1. 在 Dao|Service 层中的 TestMain 单测主入口中,import "github.com/go-kratos/kratos/pkg/testing/lich" 引入testcli工具的go库版本。
|
||||
- Step2. 使用 flag.Set("f", "../../test/docker-compose.yaml") 指定 docker-compose.yaml 文件的路径。
|
||||
- Step3. 在 flag.Parse() 后即可使用 lich.Setup() 安装依赖&初始化数据(注意测试用例执行结束后 lich.Teardown() 回收下~)
|
||||
- Step4. 运行 `go test -v ./ `看看效果吧~
|
||||
@ -121,8 +121,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/bilibili/kratos/pkg/testing/lich"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/testing/lich"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -12,12 +12,12 @@
|
||||
### 编译安装
|
||||
#### Method 1. With go get
|
||||
```shell
|
||||
go get -u github.com/bilibili/kratos/tool/testgen
|
||||
go get -u github.com/go-kratos/kratos/tool/testgen
|
||||
$GOPATH/bin/testgen -h
|
||||
```
|
||||
#### Method 2. Build with Go
|
||||
```shell
|
||||
cd github.com/bilibili/kratos/tool/testgen
|
||||
cd github.com/go-kratos/kratos/tool/testgen
|
||||
go build -o $GOPATH/bin/testgen
|
||||
$GOPATH/bin/testgen -h
|
||||
```
|
||||
|
@ -42,7 +42,7 @@ type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *Una
|
||||
* 一个`UnaryHandler`方法用于传递`Handler`,就是基于`proto`文件`service`内声明而生成的方法
|
||||
* 一个`UnaryServerInterceptor`用于拦截`Handler`方法,可在`Handler`执行前后插入拦截代码
|
||||
|
||||
为了更形象的说明拦截器的执行过程,请看基于`proto`生成的以下代码[代码位置](https://github.com/bilibili/kratos-demo/blob/master/api/api.pb.go):
|
||||
为了更形象的说明拦截器的执行过程,请看基于`proto`生成的以下代码[代码位置](https://github.com/go-kratos/kratos-demo/blob/master/api/api.pb.go):
|
||||
|
||||
```go
|
||||
func _Demo_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
@ -89,7 +89,7 @@ func UnaryInterceptor(i UnaryServerInterceptor) ServerOption {
|
||||
|
||||
> Only one unary interceptor can be installed. The construction of multiple interceptors (e.g., chaining) can be implemented at the caller.
|
||||
|
||||
`gRPC`本身只支持一个`interceptor`,想要多`interceptors`需要自己实现~~所以`warden`基于`grpc.UnaryClientInterceptor`实现了`interceptor chain`,请看下面代码[代码位置](https://github.com/bilibili/kratos/blob/master/pkg/net/rpc/warden/server.go):
|
||||
`gRPC`本身只支持一个`interceptor`,想要多`interceptors`需要自己实现~~所以`warden`基于`grpc.UnaryClientInterceptor`实现了`interceptor chain`,请看下面代码[代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/net/rpc/warden/server.go):
|
||||
|
||||
```go
|
||||
// Use attachs a global inteceptor to the server.
|
||||
@ -167,7 +167,7 @@ type UnaryClientInterceptor func(ctx context.Context, method string, req, reply
|
||||
* 一个`UnaryInvoker`表示客户端具体要发出的执行方法
|
||||
* 一个`UnaryClientInterceptor`用于拦截`Invoker`方法,可在`Invoker`执行前后插入拦截代码
|
||||
|
||||
具体执行过程,请看基于`proto`生成的下面代码[代码位置](https://github.com/bilibili/kratos-demo/blob/master/api/api.pb.go):
|
||||
具体执行过程,请看基于`proto`生成的下面代码[代码位置](https://github.com/go-kratos/kratos-demo/blob/master/api/api.pb.go):
|
||||
|
||||
```go
|
||||
func (c *demoClient) SayHello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) {
|
||||
@ -211,7 +211,7 @@ func WithUnaryInterceptor(f UnaryClientInterceptor) DialOption {
|
||||
}
|
||||
```
|
||||
|
||||
需要注意的是客户端的拦截器在官方`gRPC`内也只能支持注册一个,与服务端拦截器`interceptor chain`逻辑类似`warden`在客户端拦截器也做了相同处理,并且在客户端连接时进行注册,请看下面代码[代码位置](https://github.com/bilibili/kratos/blob/master/pkg/net/rpc/warden/client.go):
|
||||
需要注意的是客户端的拦截器在官方`gRPC`内也只能支持注册一个,与服务端拦截器`interceptor chain`逻辑类似`warden`在客户端拦截器也做了相同处理,并且在客户端连接时进行注册,请看下面代码[代码位置](https://github.com/go-kratos/kratos/blob/master/pkg/net/rpc/warden/client.go):
|
||||
|
||||
```go
|
||||
// Use attachs a global inteceptor to the Client.
|
||||
@ -332,9 +332,9 @@ package grpc
|
||||
import (
|
||||
pb "kratos-demo/api"
|
||||
"kratos-demo/internal/service"
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden/ratelimiter"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden/ratelimiter"
|
||||
)
|
||||
|
||||
// New new a grpc server.
|
||||
|
@ -3,7 +3,7 @@
|
||||
基于proto文件可以快速生成`warden`框架对应的代码,提前需要准备以下工作:
|
||||
|
||||
* 安装`kratos tool protoc`工具,请看[kratos工具](kratos-tool.md)
|
||||
* 编写`proto`文件,示例可参考[kratos-demo内proto文件](https://github.com/bilibili/kratos-demo/blob/master/api/api.proto)
|
||||
* 编写`proto`文件,示例可参考[kratos-demo内proto文件](https://github.com/go-kratos/kratos-demo/blob/master/api/api.proto)
|
||||
|
||||
### kratos工具说明
|
||||
|
||||
@ -16,14 +16,14 @@ kratos tool protoc --grpc api.proto
|
||||
|
||||
# 使用
|
||||
|
||||
建议在项目`api`目录下编写`proto`文件及生成对应的代码,可参考[kratos-demo内的api目录](https://github.com/bilibili/kratos-demo/tree/master/api)。
|
||||
建议在项目`api`目录下编写`proto`文件及生成对应的代码,可参考[kratos-demo内的api目录](https://github.com/go-kratos/kratos-demo/tree/master/api)。
|
||||
|
||||
执行命令后生成的`api.pb.go`代码,注意其中的`DemoClient`和`DemoServer`,其中:
|
||||
|
||||
* `DemoClient`接口为客户端调用接口,相对应的有`demoClient`结构体为其实现
|
||||
* `DemoServer`接口为服务端接口声明,需要业务自己实现该接口的所有方法,`kratos`建议在`internal/service`目录下使用`Service`结构体实现
|
||||
|
||||
`internal/service`内的`Service`结构实现了`DemoServer`接口可参考[kratos-demo内的service](https://github.com/bilibili/kratos-demo/blob/master/internal/service/service.go)内的如下代码:
|
||||
`internal/service`内的`Service`结构实现了`DemoServer`接口可参考[kratos-demo内的service](https://github.com/go-kratos/kratos-demo/blob/master/internal/service/service.go)内的如下代码:
|
||||
|
||||
```go
|
||||
// SayHelloURL bm demo func.
|
||||
|
@ -35,8 +35,8 @@ package grpc
|
||||
import (
|
||||
pb "kratos-demo/api"
|
||||
"kratos-demo/internal/service"
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
)
|
||||
|
||||
// New new a grpc server.
|
||||
@ -99,7 +99,7 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@ -131,7 +131,7 @@ package dao
|
||||
import(
|
||||
demoapi "kratos-demo/api"
|
||||
grpcempty "github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -119,9 +119,9 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/naming/discovery"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden/resolver"
|
||||
"github.com/go-kratos/kratos/pkg/naming/discovery"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden/resolver"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@ -206,9 +206,9 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/naming/etcd"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||||
"github.com/bilibili/kratos/pkg/net/rpc/warden/resolver"
|
||||
"github.com/go-kratos/kratos/pkg/naming/etcd"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
|
||||
"github.com/go-kratos/kratos/pkg/net/rpc/warden/resolver"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
bm "github.com/bilibili/kratos/pkg/net/http/blademaster"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
)
|
||||
|
||||
// Config is the identify config model.
|
||||
|
@ -3,9 +3,9 @@ package auth_test
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/bilibili/kratos/example/blademaster/middleware/auth"
|
||||
bm "github.com/bilibili/kratos/pkg/net/http/blademaster"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/example/blademaster/middleware/auth"
|
||||
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
)
|
||||
|
||||
// This example create a identify middleware instance and attach to several path,
|
||||
|
@ -6,8 +6,8 @@ package api
|
||||
import (
|
||||
"context"
|
||||
|
||||
bm "github.com/bilibili/kratos/pkg/net/http/blademaster"
|
||||
"github.com/bilibili/kratos/pkg/net/http/blademaster/binding"
|
||||
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
|
||||
"github.com/go-kratos/kratos/pkg/net/http/blademaster/binding"
|
||||
)
|
||||
import google_protobuf1 "github.com/golang/protobuf/ptypes/empty"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
)
|
||||
|
||||
// to suppressed 'imported but not used warning'
|
||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module github.com/bilibili/kratos
|
||||
module github.com/go-kratos/kratos
|
||||
|
||||
go 1.13
|
||||
|
||||
|
2
pkg/cache/memcache/conn_test.go
vendored
2
pkg/cache/memcache/conn_test.go
vendored
@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
test "github.com/bilibili/kratos/pkg/cache/memcache/test"
|
||||
test "github.com/go-kratos/kratos/pkg/cache/memcache/test"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
|
2
pkg/cache/memcache/encoding_test.go
vendored
2
pkg/cache/memcache/encoding_test.go
vendored
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
mt "github.com/bilibili/kratos/pkg/cache/memcache/test"
|
||||
mt "github.com/go-kratos/kratos/pkg/cache/memcache/test"
|
||||
)
|
||||
|
||||
func TestEncode(t *testing.T) {
|
||||
|
4
pkg/cache/memcache/main_test.go
vendored
4
pkg/cache/memcache/main_test.go
vendored
@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
var testConnASCII Conn
|
||||
|
4
pkg/cache/memcache/memcache.go
vendored
4
pkg/cache/memcache/memcache.go
vendored
@ -3,8 +3,8 @@ package memcache
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
pkg/cache/memcache/metrics.go
vendored
2
pkg/cache/memcache/metrics.go
vendored
@ -1,6 +1,6 @@
|
||||
package memcache
|
||||
|
||||
import "github.com/bilibili/kratos/pkg/stat/metric"
|
||||
import "github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
|
||||
const namespace = "memcache_client"
|
||||
|
||||
|
2
pkg/cache/memcache/pool_conn.go
vendored
2
pkg/cache/memcache/pool_conn.go
vendored
@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
)
|
||||
|
||||
// Pool memcache connection pool struct.
|
||||
|
4
pkg/cache/memcache/pool_conn_test.go
vendored
4
pkg/cache/memcache/pool_conn_test.go
vendored
@ -7,8 +7,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
var itempool = &Item{
|
||||
|
4
pkg/cache/memcache/trace_conn.go
vendored
4
pkg/cache/memcache/trace_conn.go
vendored
@ -6,8 +6,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
pkg/cache/memcache/util_test.go
vendored
2
pkg/cache/memcache/util_test.go
vendored
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "github.com/bilibili/kratos/pkg/cache/memcache/test"
|
||||
pb "github.com/go-kratos/kratos/pkg/cache/memcache/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
2
pkg/cache/metrics.go
vendored
2
pkg/cache/metrics.go
vendored
@ -1,6 +1,6 @@
|
||||
package cache
|
||||
|
||||
import "github.com/bilibili/kratos/pkg/stat/metric"
|
||||
import "github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
|
||||
const _metricNamespace = "cache"
|
||||
|
||||
|
6
pkg/cache/redis/main_test.go
vendored
6
pkg/cache/redis/main_test.go
vendored
@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
"github.com/bilibili/kratos/pkg/testing/lich"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
"github.com/go-kratos/kratos/pkg/testing/lich"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
var (
|
||||
|
2
pkg/cache/redis/metrics.go
vendored
2
pkg/cache/redis/metrics.go
vendored
@ -1,7 +1,7 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/stat/metric"
|
||||
"github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
)
|
||||
|
||||
const namespace = "redis_client"
|
||||
|
4
pkg/cache/redis/pipeline_test.go
vendored
4
pkg/cache/redis/pipeline_test.go
vendored
@ -7,8 +7,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
func TestRedis_Pipeline(t *testing.T) {
|
||||
|
6
pkg/cache/redis/pool.go
vendored
6
pkg/cache/redis/pool.go
vendored
@ -25,9 +25,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
var beginTime, _ = time.Parse("2006-01-02 15:04:05", "2006-01-02 15:04:05")
|
||||
|
2
pkg/cache/redis/pool_test.go
vendored
2
pkg/cache/redis/pool_test.go
vendored
@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
)
|
||||
|
||||
type poolTestConn struct {
|
||||
|
4
pkg/cache/redis/redis.go
vendored
4
pkg/cache/redis/redis.go
vendored
@ -17,8 +17,8 @@ package redis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
// Error represents an error returned in a command reply.
|
||||
|
4
pkg/cache/redis/redis_test.go
vendored
4
pkg/cache/redis/redis_test.go
vendored
@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/container/pool"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/container/pool"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
func TestRedis(t *testing.T) {
|
||||
|
4
pkg/cache/redis/trace.go
vendored
4
pkg/cache/redis/trace.go
vendored
@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
pkg/cache/redis/trace_test.go
vendored
2
pkg/cache/redis/trace_test.go
vendored
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
@ -3,8 +3,8 @@ package dsn_test
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/dsn"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/conf/dsn"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
// Config struct
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
type cfg1 struct {
|
||||
@ -66,7 +66,7 @@ func TestDecodeQuery(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "test github.com/bilibili/kratos/pkg/time",
|
||||
name: "test github.com/go-kratos/kratos/pkg/time",
|
||||
args: args{
|
||||
query: url.Values{
|
||||
"timeout": {"1s"},
|
||||
@ -77,7 +77,7 @@ func TestDecodeQuery(t *testing.T) {
|
||||
cfg: &cfg2{xtime.Duration(time.Second)},
|
||||
},
|
||||
{
|
||||
name: "test empty github.com/bilibili/kratos/pkg/time",
|
||||
name: "test empty github.com/go-kratos/kratos/pkg/time",
|
||||
args: args{
|
||||
query: url.Values{},
|
||||
v: &cfg2{},
|
||||
@ -86,7 +86,7 @@ func TestDecodeQuery(t *testing.T) {
|
||||
cfg: &cfg2{},
|
||||
},
|
||||
{
|
||||
name: "test github.com/bilibili/kratos/pkg/time",
|
||||
name: "test github.com/go-kratos/kratos/pkg/time",
|
||||
args: args{
|
||||
query: url.Values{},
|
||||
v: &cfg4{},
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/philchia/agollo"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin/apollo/internal/mockserver"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin/apollo/internal/mockserver"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin/apollo"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin/apollo"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ package paladin_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -3,7 +3,7 @@ package paladin_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||||
"github.com/go-kratos/kratos/pkg/conf/paladin"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
)
|
||||
|
||||
// Config codel config.
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
)
|
||||
|
||||
var testConf = &Config{
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/database/hbase"
|
||||
"github.com/go-kratos/kratos/pkg/database/hbase"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package hbase
|
||||
|
||||
import (
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
// ZKConfig Server&Client settings.
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/tsuna/gohbase"
|
||||
"github.com/tsuna/gohbase/hrpc"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
)
|
||||
|
||||
// HookFunc hook function call before every method and hook return function will call after finish.
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/tsuna/gohbase"
|
||||
"github.com/tsuna/gohbase/hrpc"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/stat/metric"
|
||||
"github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
)
|
||||
|
||||
const namespace = "hbase_client"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/tsuna/gohbase/hrpc"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
)
|
||||
|
||||
// NewSlowLogHook log slow operation.
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/tsuna/gohbase/hrpc"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
)
|
||||
|
||||
// TraceHook create new hbase trace hook.
|
||||
|
@ -1,6 +1,6 @@
|
||||
package sql
|
||||
|
||||
import "github.com/bilibili/kratos/pkg/stat/metric"
|
||||
import "github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
|
||||
const namespace = "mysql_client"
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
// database driver
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -6,10 +6,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
"github.com/bilibili/kratos/pkg/naming/discovery"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
"github.com/go-kratos/kratos/pkg/naming/discovery"
|
||||
)
|
||||
|
||||
var _schema = "tidb://"
|
||||
|
@ -1,6 +1,6 @@
|
||||
package tidb
|
||||
|
||||
import "github.com/bilibili/kratos/pkg/stat/metric"
|
||||
import "github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
|
||||
const namespace = "tidb_client"
|
||||
|
||||
|
@ -3,7 +3,7 @@ package tidb
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
)
|
||||
|
||||
func (db *DB) nodeproc(e <-chan struct{}) {
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
"github.com/bilibili/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
"github.com/go-kratos/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -1,9 +1,9 @@
|
||||
package tidb
|
||||
|
||||
import (
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/netutil/breaker"
|
||||
"github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
// database driver
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode/types"
|
||||
"github.com/go-kratos/kratos/pkg/ecode/types"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode/types"
|
||||
"github.com/go-kratos/kratos/pkg/ecode/types"
|
||||
)
|
||||
|
||||
func TestEqual(t *testing.T) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: internal/types/status.proto
|
||||
|
||||
package types // import "github.com/bilibili/kratos/pkg/ecode/types"
|
||||
package types // import "github.com/go-kratos/kratos/pkg/ecode/types"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
|
@ -4,7 +4,7 @@ package bilibili.rpc;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/bilibili/Kratos/pkg/ecode/types;types";
|
||||
option go_package = "github.com/go-kratos/kratos/pkg/ecode/types;types";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "StatusProto";
|
||||
option java_package = "com.bilibili.rpc";
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log/internal/core"
|
||||
"github.com/go-kratos/kratos/pkg/log/internal/core"
|
||||
)
|
||||
|
||||
// D represents a map of entry level data used for structured logging.
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log/internal/filewriter"
|
||||
"github.com/go-kratos/kratos/pkg/log/internal/filewriter"
|
||||
)
|
||||
|
||||
// level idx
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
// FieldType represent D value type
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/stat/metric"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
)
|
||||
|
||||
// Config log config.
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/log/internal/core"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/log/internal/core"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
)
|
||||
|
||||
func addExtraField(ctx context.Context, fields map[string]interface{}) {
|
||||
|
@ -13,12 +13,12 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
http "github.com/bilibili/kratos/pkg/net/http/blademaster"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
http "github.com/go-kratos/kratos/pkg/net/http/blademaster"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
"go.etcd.io/etcd/mvcc/mvccpb"
|
||||
"google.golang.org/grpc"
|
||||
|
@ -3,7 +3,7 @@ package etcd
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
"google.golang.org/grpc"
|
||||
"testing"
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
|
||||
"github.com/dgryski/go-farm"
|
||||
)
|
||||
|
@ -12,9 +12,9 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
"github.com/go-zookeeper/zk"
|
||||
)
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/naming"
|
||||
"github.com/go-kratos/kratos/pkg/naming"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,10 +17,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/bilibili/kratos/pkg/net/netutil/breaker"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/net/netutil/breaker"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
pkgerr "github.com/pkg/errors"
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/bilibili/kratos/pkg/net/http/blademaster/binding"
|
||||
"github.com/bilibili/kratos/pkg/net/http/blademaster/render"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/net/http/blademaster/binding"
|
||||
"github.com/go-kratos/kratos/pkg/net/http/blademaster/render"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/gogo/protobuf/types"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package blademaster
|
||||
|
||||
import (
|
||||
criticalityPkg "github.com/bilibili/kratos/pkg/net/criticality"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
criticalityPkg "github.com/go-kratos/kratos/pkg/net/criticality"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
)
|
||||
|
||||
func matchHostSuffix(suffix string) func(*url.URL) bool {
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/ecode"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/ecode"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
)
|
||||
|
||||
// Logger is logger middleware
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/env"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/criticality"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/conf/env"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/criticality"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package blademaster
|
||||
|
||||
import "github.com/bilibili/kratos/pkg/stat/metric"
|
||||
import "github.com/go-kratos/kratos/pkg/stat/metric"
|
||||
|
||||
const (
|
||||
clientNamespace = "http_client"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/dsn"
|
||||
"github.com/go-kratos/kratos/pkg/conf/dsn"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
limit "github.com/bilibili/kratos/pkg/ratelimit"
|
||||
"github.com/bilibili/kratos/pkg/ratelimit/bbr"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
limit "github.com/go-kratos/kratos/pkg/ratelimit"
|
||||
"github.com/go-kratos/kratos/pkg/ratelimit/bbr"
|
||||
)
|
||||
|
||||
// RateLimiter bbr middleware.
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
)
|
||||
|
||||
// Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
|
||||
|
@ -13,12 +13,12 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/conf/dsn"
|
||||
"github.com/bilibili/kratos/pkg/log"
|
||||
"github.com/bilibili/kratos/pkg/net/criticality"
|
||||
"github.com/bilibili/kratos/pkg/net/ip"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
"github.com/go-kratos/kratos/pkg/conf/dsn"
|
||||
"github.com/go-kratos/kratos/pkg/log"
|
||||
"github.com/go-kratos/kratos/pkg/net/criticality"
|
||||
"github.com/go-kratos/kratos/pkg/net/ip"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
criticalityPkg "github.com/bilibili/kratos/pkg/net/criticality"
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
xtime "github.com/bilibili/kratos/pkg/time"
|
||||
criticalityPkg "github.com/go-kratos/kratos/pkg/net/criticality"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
xtime "github.com/go-kratos/kratos/pkg/time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"net/http/httptrace"
|
||||
"strconv"
|
||||
|
||||
"github.com/bilibili/kratos/pkg/net/metadata"
|
||||
"github.com/bilibili/kratos/pkg/net/trace"
|
||||
"github.com/go-kratos/kratos/pkg/net/metadata"
|
||||
"github.com/go-kratos/kratos/pkg/net/trace"
|
||||
)
|
||||
|
||||
const _defaultComponentName = "net/http"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user