当前位置:网站首页>Grp: implement GRP timeout interceptor
Grp: implement GRP timeout interceptor
2022-06-24 01:47:00 【Trespass 】
Introduce
How does this article describe rk-boot Quickly build gRPC Timeout interceptor .
What is? gRPC Timeout interceptor ?
Interceptors will intercept gRPC request , And return the timeout error according to the policy .
Please visit the following address for a complete tutorial :
install
go get github.com/rookie-ninja/rk-boot go get github.com/rookie-ninja/rk-grpc
Quick start
Use rk-boot start-up gRPC service .
Support global timeout and API Timeout settings .
1. establish boot.yaml
boot.yaml File tell rk-boot How to start gRPC service .
In order to verify , We started commonService,commonService Contains a series of commonly used API, for example /rk/v1/gc.
Set the global timeout to 5 second , Give Way GC Timeout positioning for 1 millisecond ,GC Usually more than 1 millisecond .
---
grpc:
- name: greeter # Required
port: 8080 # Required
enabled: true # Required
commonService:
enabled: true # Optional, Enable common service for testing
interceptors:
timeout:
enabled: true # Optional, default: false
timeoutMs: 5000 # Optional, default: 5000
paths:
- path: "/rk.api.v1.RkCommonService/Gc" # Optional, default: ""
timeoutMs: 1 # Optional, default: 50002. establish main.go
// Copyright (c) 2021 rookie-ninja
//
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.
package main
import (
"context"
"github.com/rookie-ninja/rk-boot"
_ "github.com/rookie-ninja/rk-grpc/boot"
)
// Application entrance.
func main() {
// Create a new boot instance.
boot := rkboot.NewBoot()
// Bootstrap
boot.Bootstrap(context.Background())
// Wait for shutdown sig
boot.WaitForShutdownSig(context.Background())
}3. start-up main.go
$ go run main.go
4. verification
send out GC request .
$ grpcurl -plaintext localhost:8080 rk.api.v1.RkCommonService.Gc
ERROR:
Code: Canceled
Message: Request timed out!
Details:
1) {"@type":"type.googleapis.com/rk.api.v1.ErrorDetail","code":1,"message":"[from-grpc] Request timed out!","status":"Canceled"}$ curl -X GET localhost:8080/rk/v1/gc
{
"error":{
"code":408,
"status":"Request Timeout",
"message":"Request timed out!",
"details":[
{
"code":1,
"status":"Canceled",
"message":"[from-grpc] Request timed out!"
}
]
}
}边栏推荐
- Cloud computing "keeping the promise"
- Application analysis of video edge computing gateway easynvr in video overall monitoring solution
- Ppt layout design how to make pages not messy
- 4-data persistence and shared interconnection
- Introduction to easycvr interfacing with Huawei IVS subscription camera and user change request interface
- Analysis of the whole process of webapck5 core packaging principle
- What is "data" in data analysis- Cassie Kozyrkov
- Spatial4j introduction practice
- DCOM horizontal movement of Intranet penetration
- How does smart digital operation get through offline collection and online marketing?
猜你喜欢

I, a 27 year old female programmer, feel that life is meaningless, not counting the accumulation fund deposit of 430000
![[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)](/img/b5/a8c4bbaf868dd20b7dc9449d2a4378.jpg)
[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)
![[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)](/img/c8/f6c2a62b8ab8fa88bd2b3d8f35f592.jpg)
[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)

It's too difficult for me. Ali has had 7 rounds of interviews (5 years of experience and won the offer of P7 post)
随机推荐
[tcapulusdb knowledge base] how to delete a table in tcapulusdb table management?
Tencent cloud database tdsql elite challenge --q & A
Activity Registration - Tencent cloud digital intelligence driven SME transformation and upgrading series salon · Zhuhai station
November 15, 2021: add four numbers II. Here are four integer arrays nums1, num
Detailed explanation of SSH tunnel and stable intranet penetration using autossh
LeetCode 931. Descent path min sum
5、 Array base
Tcapulusdb Jun · industry news collection
Many ministries and commissions strengthened regulation, and Tencent security helped enterprises resist the "mining" Trojan horse
Implementation of asynchronous notification and event callback based on guava API
[technical grass planting] cdn+ lightweight server +hugo= let the blog "cloud native"
Easynvr background channel list timing request touchstreamclient interface optimization
Blog platform was falsely blackmailed and the new hacker organization claimed responsibility for the Israeli attack | November 16 global network security hotspot
SAP mm Migo 411k error - correct the customizing settings for the unique
Collation of commonly used glusterfs commands
Moment. JS to UTC format
DCOM horizontal movement of Intranet penetration
How to use the speech synthesis assistant? Does speech synthesis cost money?
How to use voice synthesis? Can voice synthesis modify the voice?
Cost composition and calculation method of system software