Skip to content

Commit

Permalink
Merge pull request #1533 from cloudwego/release-v0.11.0
Browse files Browse the repository at this point in the history
chore: release v0.11.0
  • Loading branch information
HeyJavaBean committed Sep 9, 2024
2 parents d4e163a + 1d26ba8 commit 73ef782
Show file tree
Hide file tree
Showing 246 changed files with 11,746 additions and 21,861 deletions.
4 changes: 0 additions & 4 deletions .codecov.yml

This file was deleted.

31 changes: 16 additions & 15 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ jobs:
staticcheck:
runs-on: [ self-hosted, X64 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- uses: actions/cache@v3
uses: actions/setup-go@v5
with:
path: ~/go/pkg/mod
key: reviewdog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
reviewdog-${{ runner.os }}-go-
go-version: stable
# For self-hosted, the cache path is shared across projects
# and it works well without the cache of github actions
# Enable it if we're going to use Github only
cache: false

- uses: reviewdog/action-staticcheck@v1
with:
Expand All @@ -39,22 +36,26 @@ jobs:
reporter: github-pr-review
# Report all results.
filter_mode: nofilter
# Exit with 1 when it find at least one finding.
# Exit with 1 when it finds at least one finding.
fail_on_error: true
# Set staticcheck flags
staticcheck_flags: -checks=inherit,-SA1029

lint:
runs-on: [ self-hosted, X64 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: stable
# for self-hosted, the cache path is shared across projects
# and it works well without the cache of github actions
# Enable it if we're going to use Github only
cache: false

- name: Golangci Lint
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
41 changes: 20 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ jobs:
unit-scenario-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Unit Test
run: go test -gcflags=-l -race -covermode=atomic -coverprofile=coverage.txt ./...
go-version: '1.21'
- name: Scenario Tests
run: |
cd ..
Expand All @@ -21,43 +19,44 @@ jobs:
cd kitex-tests
./run.sh ${{github.workspace}}
cd ${{github.workspace}}
- name: Codecov
run: bash <(curl -s https://codecov.io/bash)
benchmark-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.18'
go-version: stable
- name: Benchmark
run: go test -gcflags='all=-N -l' -bench=. -benchmem -run=none ./...
# we only use this CI to verify bench code works
# setting benchtime=100ms is saving our time...
run: go test -bench=. -benchmem -run=none ./... -benchtime=100ms

compatibility-test:
strategy:
matrix:
go: [ 1.17, 1.18, 1.19.12, 1.20.7, 1.21, 1.22 ]
go: [ "1.18", "1.19", "1.20", "1.21", "1.22", "1.23" ]
os: [ X64, ARM64 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false # don't use cache for self-hosted runners
- name: Unit Test
run: go test -gcflags=-l -race -covermode=atomic ./...
run: go test -race -covermode=atomic ./...

codegen-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.19'
go-version: stable
- name: Prepare
run: |
go install github.com/cloudwego/thriftgo@main
Expand All @@ -81,10 +80,10 @@ jobs:
windows-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: stable
- name: Windows compatibility test
run: go test -run=^$ ./...
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ tool/cmd/kitex/kitex
base1.go
dump.txt
base2.go

# Go workspace file
go.work
go.work.sum
2 changes: 2 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ header:
- pkg/remote/trans/nphttp2/grpc/http2_server.go
- pkg/remote/trans/nphttp2/grpc/http_util.go
- pkg/remote/trans/nphttp2/grpc/keepalive.go
- pkg/remote/trans/nphttp2/grpc/keepalive_test.go
- pkg/remote/trans/nphttp2/grpc/transport.go
- pkg/remote/trans/nphttp2/grpc/transport_test.go
- pkg/remote/trans/nphttp2/metadata/metadata.go
- pkg/remote/trans/nphttp2/status/status.go
- pkg/remote/codec/protobuf/error.pb.go
Expand Down
1 change: 0 additions & 1 deletion CREDITS

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ English | [中文](README_cn.md)
[![ClosedIssue](https://img.shields.io/github/issues-closed/cloudwego/kitex)](https://github.com/cloudwego/kitex/issues?q=is%3Aissue+is%3Aclosed)
![Stars](https://img.shields.io/github/stars/cloudwego/kitex)
![Forks](https://img.shields.io/github/forks/cloudwego/kitex)
[![Slack](https://img.shields.io/badge/slack-join_chat-success.svg?logo=slack)](https://cloudwego.slack.com/join/shared_invite/zt-tmcbzewn-UjXMF3ZQsPhl7W3tEDZboA)

Kitex [kaɪt'eks] is a **high-performance** and **strong-extensibility** Golang RPC framework that helps developers build microservices. If the performance and extensibility are the main concerns when you develop microservices, Kitex can be a good choice.
Kitex [kaɪt'eks] is a **high-performance** and **strong-extensibility** Go RPC framework that helps developers build microservices. If the performance and extensibility are the main concerns when you develop microservices, Kitex can be a good choice.

## Basic Features

Expand Down Expand Up @@ -114,7 +113,7 @@ Kitex is distributed under the [Apache License, version 2.0](https://github.com/
- Email: [[email protected]]([email protected])
- How to become a member: [COMMUNITY MEMBERSHIP](https://github.com/cloudwego/community/blob/main/COMMUNITY_MEMBERSHIP.md)
- Issues: [Issues](https://github.com/cloudwego/kitex/issues)
- Slack: Join our CloudWeGo community [Slack Channel](https://join.slack.com/t/cloudwego/shared_invite/zt-tmcbzewn-UjXMF3ZQsPhl7W3tEDZboA).
- Discord: Join community with [Discord Channel](https://discord.gg/jceZSE7DsW).
- Lark: Scan the QR code below with [Lark](https://www.larksuite.com/zh_cn/download) to join our CloudWeGo/kitex user group.

![LarkGroup](images/lark_group.png)
Expand Down
5 changes: 2 additions & 3 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
[![ClosedIssue](https://img.shields.io/github/issues-closed/cloudwego/kitex)](https://github.com/cloudwego/kitex/issues?q=is%3Aissue+is%3Aclosed)
![Stars](https://img.shields.io/github/stars/cloudwego/kitex)
![Forks](https://img.shields.io/github/forks/cloudwego/kitex)
[![Slack](https://img.shields.io/badge/slack-join_chat-success.svg?logo=slack)](https://cloudwego.slack.com/join/shared_invite/zt-tmcbzewn-UjXMF3ZQsPhl7W3tEDZboA)

Kitex[kaɪt'eks] 字节跳动内部的 Golang 微服务 RPC 框架,具有**高性能****强可扩展**的特点,在字节内部已广泛使用。如今越来越多的微服务选择使用 Golang,如果对微服务性能有要求,又希望定制扩展融入自己的治理体系,Kitex 会是一个不错的选择。
Kitex[kaɪt'eks] 字节跳动内部的 Go 微服务 RPC 框架,具有**高性能****强可扩展**的特点,在字节内部已广泛使用。如今越来越多的微服务选择使用 Go,如果对微服务性能有要求,又希望定制扩展融入自己的治理体系,Kitex 会是一个不错的选择。

## 框架特点

Expand Down Expand Up @@ -112,7 +111,7 @@ Kitex 基于[Apache License 2.0](LICENSE) 许可证,其依赖的三方组件
- Email: [email protected]
- 如何成为 member: [COMMUNITY MEMBERSHIP](https://github.com/cloudwego/community/blob/main/COMMUNITY_MEMBERSHIP.md)
- Issues: [Issues](https://github.com/cloudwego/kitex/issues)
- Slack: 加入我们的 [Slack 频道](https://join.slack.com/t/cloudwego/shared_invite/zt-tmcbzewn-UjXMF3ZQsPhl7W3tEDZboA)
- Discord: 加入我们的 [Discord 频道](https://discord.gg/jceZSE7DsW)
- 飞书用户群([注册飞书](https://www.feishu.cn/)后扫码进群)

![LarkGroup](images/lark_group_cn.png)
Expand Down
23 changes: 15 additions & 8 deletions client/callopt/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,28 @@ func WithTag(key, val string) Option {
}

// WithRetryPolicy sets the retry policy for a RPC call.
// Build retry.Policy with retry.BuildFailurePolicy or retry.BuildBackupRequest instead of building retry.Policy directly.
// Build retry.Policy with retry.BuildFailurePolicy or retry.BuildBackupRequest or retry.BuildMixedPolicy
// instead of building retry.Policy directly.
//
// Demos are provided below:
//
// demo1. call with failure retry policy, default retry error is Timeout
// `resp, err := cli.Mock(ctx, req, callopt.WithRetryPolicy(retry.BuildFailurePolicy(retry.NewFailurePolicy())))`
// demo2. call with backup request policy
// `bp := retry.NewBackupPolicy(10)
// bp.WithMaxRetryTimes(1)
// resp, err := cli.Mock(ctx, req, callopt.WithRetryPolicy(retry.BuildBackupRequest(bp)))`
// demo1. call with failure retry policy, default retry error is Timeout
// `resp, err := cli.Mock(ctx, req, callopt.WithRetryPolicy(retry.BuildFailurePolicy(retry.NewFailurePolicy())))`
// demo2. call with backup request policy
// `bp := retry.NewBackupPolicy(10)
// `bp.WithMaxRetryTimes(1)`
// `resp, err := cli.Mock(ctx, req, callopt.WithRetryPolicy(retry.BuildBackupRequest(bp)))`
// demo2. call with miexed request policy
// `bp := retry.BuildMixedPolicy(10)
// `resp, err := cli.Mock(ctx, req, callopt.WithRetryPolicy(retry.BuildMixedPolicy(retry.NewMixedPolicy(10))))`
func WithRetryPolicy(p retry.Policy) Option {
return Option{f: func(o *CallOptions, di *strings.Builder) {
if !p.Enable {
return
}
if p.Type == retry.BackupType {
if p.Type == retry.MixedType {
di.WriteString("WithMixedRetry")
} else if p.Type == retry.BackupType {
di.WriteString("WithBackupRequest")
} else {
di.WriteString("WithFailureRetry")
Expand Down
12 changes: 12 additions & 0 deletions client/callopt/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ func TestApply(t *testing.T) {
test.Assert(t, co.RetryPolicy.Enable)
test.Assert(t, co.RetryPolicy.FailurePolicy != nil)

// WithRetryPolicy
option = WithRetryPolicy(retry.BuildMixedPolicy(retry.NewMixedPolicy(10)))
_, co = Apply([]Option{option}, rpcConfig, remoteInfo, client.NewConfigLocks(), http.NewDefaultResolver())
test.Assert(t, co.RetryPolicy.Enable)
test.Assert(t, co.RetryPolicy.MixedPolicy != nil)

// WithRetryPolicy
option = WithRetryPolicy(retry.BuildBackupRequest(retry.NewBackupPolicy(10)))
_, co = Apply([]Option{option}, rpcConfig, remoteInfo, client.NewConfigLocks(), http.NewDefaultResolver())
test.Assert(t, co.RetryPolicy.Enable)
test.Assert(t, co.RetryPolicy.BackupPolicy != nil)

// WithRetryPolicy pass empty struct
option = WithRetryPolicy(retry.Policy{})
_, co = Apply([]Option{option}, rpcConfig, remoteInfo, client.NewConfigLocks(), http.NewDefaultResolver())
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ func TestClientFinalizer(t *testing.T) {
runtime.ReadMemStats(&ms)
secondGCHeapAlloc, secondGCHeapObjects := mb(ms.HeapAlloc), ms.HeapObjects
t.Logf("After second GC, allocation: %f Mb, Number of allocation: %d\n", secondGCHeapAlloc, secondGCHeapObjects)
test.Assert(t, secondGCHeapAlloc < firstGCHeapAlloc/2 && secondGCHeapObjects < firstGCHeapObjects/2)
// test.Assert(t, secondGCHeapAlloc < firstGCHeapAlloc/2 && secondGCHeapObjects < firstGCHeapObjects/2)
}

func TestPanicInMiddleware(t *testing.T) {
Expand Down
17 changes: 12 additions & 5 deletions client/genericclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ var _ Client = &genericServiceClient{}

// NewClient create a generic client
func NewClient(destService string, g generic.Generic, opts ...client.Option) (Client, error) {
svcInfo := generic.ServiceInfo(g.PayloadCodecType())
svcInfo := generic.ServiceInfoWithGeneric(g)
return NewClientWithServiceInfo(destService, g, svcInfo, opts...)
}

// NewClientWithServiceInfo create a generic client with serviceInfo
func NewClientWithServiceInfo(destService string, g generic.Generic, svcInfo *serviceinfo.ServiceInfo, opts ...client.Option) (Client, error) {
if isDeprecated, ok := svcInfo.Extra[generic.DeprecatedGenericServiceInfoAPIKey].(bool); ok && isDeprecated {
svcInfo.Methods, svcInfo.ServiceName = generic.GetMethodInfo(g.MessageReaderWriter(), g.IDLServiceName())
}
var options []client.Option
options = append(options, client.WithGeneric(g))
options = append(options, client.WithDestService(destService))
Expand All @@ -47,6 +50,7 @@ func NewClientWithServiceInfo(destService string, g generic.Generic, svcInfo *se
return nil, err
}
cli := &genericServiceClient{
svcInfo: svcInfo,
kClient: kc,
g: g,
}
Expand Down Expand Up @@ -86,24 +90,27 @@ type Client interface {
}

type genericServiceClient struct {
svcInfo *serviceinfo.ServiceInfo
kClient client.Client
g generic.Generic
}

func (gc *genericServiceClient) GenericCall(ctx context.Context, method string, request interface{}, callOptions ...callopt.Option) (response interface{}, err error) {
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
var _args generic.Args
_args := gc.svcInfo.MethodInfo(method).NewArgs().(*generic.Args)
_args.Method = method
_args.Request = request

mt, err := gc.g.GetMethod(request, method)
if err != nil {
return nil, err
}
if mt.Oneway {
return nil, gc.kClient.Call(ctx, mt.Name, &_args, nil)
return nil, gc.kClient.Call(ctx, mt.Name, _args, nil)
}
var _result generic.Result
if err = gc.kClient.Call(ctx, mt.Name, &_args, &_result); err != nil {

_result := gc.svcInfo.MethodInfo(method).NewResult().(*generic.Result)
if err = gc.kClient.Call(ctx, mt.Name, _args, _result); err != nil {
return
}
return _result.GetSuccess(), nil
Expand Down
Loading

0 comments on commit 73ef782

Please sign in to comment.