Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add notes on service idle timeout #166

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/user_guide/server/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ tRPC-Go provides three timeout mechanisms for RPC calls: link timeout, message t

This feature requires protocol support (the protocol needs to carry timeout metadata downstream). The tRPC protocol, generic HTTP RPC protocol all support timeout control.

## Idle Timeout

The server has a default idle timeout of 60 seconds to prevent excessive idle connections from consuming server-side resources. This value can be modified through the `idletimeout` setting in the framework configuration:

```yaml
server:
service:
- name: trpc.server.service.Method
network: tcp
protocol: trpc
idletime: 60000 # The unit is milliseconds. Setting it to -1 means there is no idle timeout (setting it to 0 will still default to the 60s by the framework)
```

## Link transmission

The tRPC-Go framework provides a mechanism for passing fields between the client and server and passing them down the entire call chain. For the mechanism and usage of link transmission, please refer to [tRPC-Go Link Transmission](/docs/user_guide/metadata_transmission.md).
Expand Down
15 changes: 14 additions & 1 deletion docs/user_guide/server/overview.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,20 @@ tRPC-Go 从设计之初就考虑了框架的易测性,在通过 pb 生成桩

tRPC-Go 为 RPC 调用提供了 3 种超时机制控制:链路超时,消息超时和调用超时。关于这 3 种超时机制的原理介绍和相关配置,请参考 [tRPC-Go 超时控制](/docs/user_guide/timeout_control.zh_CN.md)。

此功能需要协议的支持(协议需要携带 timeout 元数据到下游),tRPC 协议,泛 HTTP RPC 协议均支持超时控制功能。其
此功能需要协议的支持(协议需要携带 timeout 元数据到下游),tRPC 协议,泛 HTTP RPC 协议均支持超时控制功能。

## 空闲超时

服务默认存在一个 60s 的空闲超时时间,以防止过多空闲连接消耗服务侧的资源,这个值可以通过框架配置中的 `idletimeout` 来进行修改:

```yaml
server:
service:
- name: trpc.server.service.Method
network: tcp
protocol: trpc
idletime: 60000 # 单位是毫秒, 设置为 -1 的时候表示没有空闲超时(这里设置为 0 时框架仍会自动转为默认的 60s)
```

## 链路透传

Expand Down
3 changes: 3 additions & 0 deletions http/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ func TestCheckRedirect(t *testing.T) {
return nil
}
thttp.DefaultClientTransport.(*thttp.ClientTransport).CheckRedirect = checkRedirect
defer func() {
thttp.DefaultClientTransport.(*thttp.ClientTransport).CheckRedirect = nil
}()
proxy := thttp.NewClientProxy("trpc.test.helloworld.Greeter",
client.WithTarget("ip://"+ln.Addr().String()),
client.WithSerializationType(codec.SerializationTypeNoop),
Expand Down
2 changes: 1 addition & 1 deletion pool/connpool/checker_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestRemoteEOF(t *testing.T) {
require.Nil(t, pc.Close())
}

func TestUnexceptedRead(t *testing.T) {
func TestUnexpectedRead(t *testing.T) {
var s server
require.Nil(t, s.init())

Expand Down
Loading