当前位置:网站首页>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!"
}
]
}
}边栏推荐
- Activity Registration - Tencent cloud digital intelligence driven SME transformation and upgrading series salon · Zhuhai station
- How do users of Fortress computers add servers? How much does it cost to add servers for fortress users?
- AES encryption analysis of CNKI academic translation
- [dry goods] configure failover active/acitve in transparent mode on Cisco ASA firewall
- Salesforce uses hyperlink formula field to implement custom jump
- Build fiora chat room with Tencent lightweight cloud
- Build and enable all plug-ins of kubesphere high availability cluster
- Can the fortress machine connect to the ECS? What are the reasons why the fortress cannot connect to the ECS?
- Note sharing (5) -precautions for Oracle to MySQL
- [SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)
猜你喜欢

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)

It's too difficult for me. Ali has had 7 rounds of interviews (5 years of experience and won the offer of P7 post)
![[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)
随机推荐
Echo framework: implementing service end flow limiting Middleware
Network security meets new regulations again, UK and US warn apt hacker attacks November 18 global network security hotspots
How about speech synthesis? Is speech synthesis effective?
Tcapulusdb Jun · industry news collection
LeetCode 931. Descent path min sum
From idea to finished product, the necessary process of APP product development
Tencent cloud database tdsql elite challenge --q & A
[tcapulusdb knowledge base] how to clean up tables in tcapulusdb table management?
Moment. JS to UTC format
Go language core 36 lectures (go language practice and application VII) -- learning notes
Tcapulusdb Jun · industry news collection
Baysor: cell segmentation in imaging based spatial transcriptomics
How to create a group on a barcode label
Build a smart drug supervision platform based on easycvr video technology and build a drug safety firewall
Line/kotlin jdsl: kotlin DSL for JPA criteria API
If the program exits abnormally, how to catch the fatal error through the go language?
Why promote steam education?
Easynvr background channel list timing request touchstreamclient interface optimization
[technical grass planting] how can this double eleven be cost-effective!
Analysis of the whole process of webapck5 core packaging principle