Skip to content

Commit

Permalink
doc: sync gRPC Streaming Graceful Shutdown (#1190)
Browse files Browse the repository at this point in the history
Co-authored-by: yuxuan.wang1 <[email protected]>
  • Loading branch information
alice-yyds and DMwangnima authored Jan 13, 2025
1 parent 644fef0 commit 43c1941
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Streaming"
linkTitle: "Streaming"
weight: 2
date: 2024-01-13
description: >
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "gRPC"
linkTitle: "gRPC"
weight: 2
date: 2024-01-13
description: >
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "gRPC Streaming Graceful Shutdown"
date: 2025-01-13
weight: 4
keywords: ["gRPC Streaming Graceful Shutdown"]
description: "This article describes how to use Graceful Shutdown over gRPC"
---

## Background

To effectively solve the problem of upstream error reporting caused by service upgrade/migration, Kitex supports the graceful shutdown function of gRPC Streaming in the new version (v0.12.0).

By setting a reasonable window time, the streams with a lifetime shorter than this window can continue to work until the end, while the streams with a lifetime longer than this window will be forcibly closed.

## Usage

### Confirm the window time

Before starting the configuration, please obtain the duration distribution of the streams in the current service based on business statistics, and thereby establish a reasonable window time, denoted as **graceTime**, for example:

- All streams can be completed within 5 minutes, and 5 minutes is an acceptable service upgrade time, then **graceTime** is 5 minutes.
- Most streams can be completed within 5 minutes, and very few streams will last for 30 minutes, then **graceTime** can still be set to 5 minutes, and the flows exceeding graceTime will be forcibly closed.

### Configuration

When creating the Server, pass `server.WithExitWaitTime(graceTime)`.

If not configured, the default is **5 s**.

```go
import (
"github.com/cloudwego/kitex/server"
)

const (
graceTime = 600 * time.Second
)

svr := testservice.NewServer(hdl, server.WithExitWaitTime(graceTime))
```
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Thrift Streaming"
title: "Thrift Streaming over gRPC"
date: 2024-03-09
weight: 2
keywords: ["Kitex", "Streaming", "Thrift"]
description: This article describes how to define and use the Streaming API in Thrift IDL.
weight: 3
keywords: ["Kitex", "Streaming", "Thrift", "gRPC"]
description: This article describes how to define and use the Streaming API in Thrift IDL over gRPC.
---

## Introduction
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Streaming"
linkTitle: "Streaming"
weight: 2
date: 2024-03-06
description: >
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "gRPC"
linkTitle: "gRPC"
weight: 2
date: 2025-01-13
description: >
---
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "gRPC Streaming 优雅退出"
date: 2025-01-10
weight: 3
weight: 4
keywords: ["优雅退出"]
description: "本文介绍如何使用 gRPC Streaming 优雅突出"
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Thrift Streaming"
title: "Thrift Streaming over gRPC"
date: 2024-03-06
weight: 2
keywords: ["Kitex", "Streaming", "Thrift"]
weight: 3
keywords: ["Kitex", "Streaming", "Thrift", "gRPC"]
description: 本文介绍如何在 Thrift IDL 里定义并使用 Streaming API。
---

Expand Down

This file was deleted.

0 comments on commit 43c1941

Please sign in to comment.