SetTimeout gRPC Method
Parâmetros
tempo limite
número inteiro
OBRIGATÓRIO
A carregar...
Devoluções
erro
cadeia de caracteres
A carregar...
Pedido
1pacote principal23importar (4"contexto"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 ponto final = "O_SEU_PONTO_DE_ACESSO:50051"222324tipo auth estrutura {25token string26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),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}
1pacote principal23importar (4"contexto"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 ponto final = "O_SEU_PONTO_DE_ACESSO:50051"222324tipo auth estrutura {25token string26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39conn := client.NewGrpcClient(endpoint)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),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}
Ainda não tem uma conta?
Crie o seu ponto de extremidade Quicknode em segundos e comece a desenvolver
Comece gratuitamente