SetTimeout gRPC Method
Paramètres
timeout
entier
OBLIGATOIRE
Chargement en cours...
Retours
erreur
chaîne de caractères
Chargement en cours...
Demande
1paquet principal23import (4« contexte »5« crypto/tls »6« fmt »7« temps »89« github.sdk »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 jeton = "VOTRE_TOKEN"21var endpoint = "VOTRE_POINT_DE_FIN :50051"222324type auth struct {25jeton chaîne de caractères26}2728func (a *auth) GetRequestMetadata(ctx contexte.Context, uri ...chaîne) (carte[chaîne]chaîne, erreur) {29retour carte[chaîne]chaîne{30« x-token »: un.jeton,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retour false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(informations d'authentification.NewTLS(&tls.Config{})),47grpc.Avec les identifiants RPCC(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51panique(erreur)52}53reporter conn.Conn.Fermer()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
1paquet principal23import (4« contexte »5« crypto/tls »6« fmt »7« temps »89« github.sdk »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 jeton = "VOTRE_TOKEN"21var endpoint = "VOTRE_POINT_DE_FIN :50051"222324type auth struct {25jeton chaîne de caractères26}2728func (a *auth) GetRequestMetadata(ctx contexte.Context, uri ...chaîne) (carte[chaîne]chaîne, erreur) {29retour carte[chaîne]chaîne{30« x-token »: un.jeton,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retour false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(informations d'authentification.NewTLS(&tls.Config{})),47grpc.Avec les identifiants RPCC(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51panique(erreur)52}53reporter conn.Conn.Fermer()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
Vous n'avez pas encore de compte ?
Créez votreendpoint Quicknode endpoint quelques secondes et commencez à développer
Commencez gratuitement