SetTimeout gRPC Method
Parámetros
timeout
entero
OBLIGATORIO
Cargando...
Devoluciones
error
cadena
Cargando...
Solicitud
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«tiempo»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 = "TU_TOKEN"21var punto final = "TU_PUNTO_DE_ACceso:50051"222324tipo autenticación estructura {25token cadena26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {29volver mapa[cadena]cadena{30«x-token»: un.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35volver false36}3738func main() {39conn := cliente.NewGrpcClient(punto de conexión)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),47grpc.Con credenciales RPCC(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51pánico(error)52}53aplazar conn.Conn.Cerrar()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«tiempo»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 = "TU_TOKEN"21var punto final = "TU_PUNTO_DE_ACceso:50051"222324tipo autenticación estructura {25token cadena26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {29volver mapa[cadena]cadena{30«x-token»: un.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35volver false36}3738func main() {39conn := cliente.NewGrpcClient(punto de conexión)4041conn.SetTimeout(10 * time.Second)4243fmt.Println("Timeout set to 10 seconds")4445opts := []grpc.DialOption{46grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),47grpc.Con credenciales RPCC(&auth{token}),48}4950if err := conn.Start(opts...); err != nil {51pánico(error)52}53aplazar conn.Conn.Cerrar()5455fmt.Println("Client successfully started with custom timeout configuration")5657}
¿Aún no tienes una cuenta?
Crea tu punto de conexión de Quicknode en cuestión de segundos y empieza a desarrollar
Empieza gratis