SetTimeout gRPC Method
パラメータ
timeout
整数
必須
読み込み中...
返します
error
文字列
読み込み中...
リクエスト
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"fmt"7「時間」89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.grpc"11"google.golang.grpc"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 トークン = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324タイプ auth 構造体 {25トークン 文字列26}2728func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {29戻る map[文字列]文字列{30「x-token」: a.トークン,31}, nil32}3334func (a *auth) RequireTransportSecurity(auth) 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.WithTransportCredentialsWithTransportCredentials(credentials.NewTLS(&tls.設定{})),47grpc.WithPerRPCCredentials(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51panic(err)52}53defer conn.Conn.Close()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"fmt"7「時間」89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.grpc"11"google.golang.grpc"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 トークン = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324タイプ auth 構造体 {25トークン 文字列26}2728func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {29戻る map[文字列]文字列{30「x-token」: a.トークン,31}, nil32}3334func (a *auth) RequireTransportSecurity(auth) 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.WithTransportCredentialsWithTransportCredentials(credentials.NewTLS(&tls.設定{})),47grpc.WithPerRPCCredentials(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51panic(err)52}53defer conn.Conn.Close()5455fmt.Println("Client successfully started with custom timeout configuration")5657}