SetTimeout gRPC Method
参数
timeout
整数
必填
正在加载...
退货
错误
字符串
正在加载...
请求
1包 main23导入 (4"上下文"5"crypto/tls"6"fmt"7"time"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var token = "YOUR_TOKEN"21var 端点 = "YOUR_ENDPOINT:50051"222324类型 auth 结构体 {25token 字符串26}2728func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {29返回 map[字符串]字符串{30“x-token”: a.令牌,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35返回 false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),47grpc.WithPerRPC凭据(&auth{令牌}),48}4950if err := conn.Start(opts...); err != nil {51恐慌(err)52}53推迟 conn.Conn.关闭()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
1包 main23导入 (4"上下文"5"crypto/tls"6"fmt"7"time"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var token = "YOUR_TOKEN"21var 端点 = "YOUR_ENDPOINT:50051"222324类型 auth 结构体 {25token 字符串26}2728func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {29返回 map[字符串]字符串{30“x-token”: a.令牌,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35返回 false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),47grpc.WithPerRPC凭据(&auth{令牌}),48}4950if err := conn.Start(opts...); err != nil {51恐慌(err)52}53推迟 conn.Conn.关闭()5455fmt.Println("Client successfully started with custom timeout configuration")5657}