当前位置:网站首页>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!"
}
]
}
}边栏推荐
- Tcapulusdb Jun · industry news collection
- Software cost evaluation: a method for estimating software scale by fast function point method
- Logistics industry supplier collaborative management platform supplier life cycle management to optimize logistics costs
- How to restart the server through the fortress machine how to log in to the fortress machine
- SAP mm maintains inter company sto error -no delivery type defined for supplying
- What is pension finance? What are the pension financial products?
- MySQL architecture
- Software cost evaluation: basic knowledge interpretation of cosmoc method
- How to do AI speech synthesis? How to download the voice of AI speech synthesis?
- Disruptor note 2: disruptor class analysis
猜你喜欢
![[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)

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)
随机推荐
6、 Symbols and commands for numerical calculation of variables
How to implement NSQ delay streaming technology in easycvr?
LeetCode 120. Triangle minimum path sum
[actual combat] how to realize people nearby through PostGIS
SMS marketing is the key to retain customers
How to use the speech synthesis tool? Does the speech synthesis tool cost money?
Tcapulusdb pays high tribute to Chinese journalists!
[tcapulusdb knowledge base] how to rebuild tables in tcapulusdb table management?
什麼是養老理財?養老理財產品有哪些?
Clubhouse online supports replay function; Webobs live streaming tools are going to be popular |w
Note sharing (5) -precautions for Oracle to MySQL
What is pension finance? What are the pension financial products?
How to access the server through the fortress machine? What if the fortress cannot access the server?
Why promote steam education?
8、 Pipeline pipeline construction project
Implementation of asynchronous notification and event callback based on guava API
[guide to cloud first] point north before tdsql elite challenge
A multifunctional SSH Remote Server Management Tool
[technical grass planting] the cloud driver takes you straight to the clouds
Typescript is a weak type