1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-12-22 00:36:41 +02:00

сделал timeout_seconds

This commit is contained in:
Nikitin Aleksandr 2024-01-25 13:02:46 +03:00
parent 52d54a1ddb
commit aa46709a6b
3 changed files with 31 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/ManyakRus/starter/stopapp" "github.com/ManyakRus/starter/stopapp"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
grpc_constants "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/grpc/constants"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"os" "os"
@ -71,6 +72,9 @@ func Connect_err() error {
addr := Settings.SYNC_SERVICE_HOST + ":" + Settings.SYNC_SERVICE_PORT addr := Settings.SYNC_SERVICE_HOST + ":" + Settings.SYNC_SERVICE_PORT
Conn, err = grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) Conn, err = grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Client = grpc_proto.NewSyncServiceClient(Conn) Client = grpc_proto.NewSyncServiceClient(Conn)
return err return err
@ -219,3 +223,15 @@ loop:
stopapp.GetWaitGroup_Main().Done() stopapp.GetWaitGroup_Main().Done()
} }
// GetTimeoutSeconds - возвращает время ожидания ответа
func GetTimeoutSeconds() int {
Otvet := grpc_constants.GetTimeoutSeconds()
return Otvet
}
// SetTimeoutSeconds - устанавливает время ожидания ответа
func SetTimeoutSeconds(seconds int) {
grpc_constants.SetTimeoutSeconds(seconds)
}

View File

@ -16,6 +16,7 @@ import (
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/api/grpc_proto"
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/constants"
nrpc_constants "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/network/nrpc/constants"
"sync" "sync"
"os" "os"
@ -72,12 +73,12 @@ func Connect_err() error {
} }
NatsURL := "nats://" + Settings.NATS_HOST + ":" + Settings.NATS_PORT NatsURL := "nats://" + Settings.NATS_HOST + ":" + Settings.NATS_PORT
// Connect to the NATS server. // Connect to the NATS server.
Conn, err = nats.Connect(NatsURL, nats.Timeout(5*time.Second)) Conn, err = nats.Connect(NatsURL, nats.Timeout(5*time.Second))
if err != nil { if err != nil {
log.Panic(err) return err
} }
// defer Conn.Close()
// This is our generated client. // This is our generated client.
Client = grpc_proto.NewSync_serviceClient(Conn) Client = grpc_proto.NewSync_serviceClient(Conn)
@ -230,3 +231,15 @@ loop:
stopapp.GetWaitGroup_Main().Done() stopapp.GetWaitGroup_Main().Done()
} }
// GetTimeoutSeconds - возвращает время ожидания ответа
func GetTimeoutSeconds() int {
Otvet := nrpc_constants.GetTimeoutSeconds()
return Otvet
}
// SetTimeoutSeconds - устанавливает время ожидания ответа
func SetTimeoutSeconds(seconds int) {
nrpc_constants.SetTimeoutSeconds(seconds)
}