1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2025-01-23 09:24:43 +02:00
2024-08-14 11:19:20 +03:00

39 lines
1.6 KiB
Plaintext

The service implements synchronous data exchange.
Service for exchanging data with Postgres SQL database
Data exchange is done using different methods:
1. DB CRUD operations - direct exchange with the database
(each table model has methods Read(), Update(), Create(), Save(), Delete(), Restore())
2. GRPC - exchange with the database using the GRPC protocol
(the client service that needs to exchange with the database connects to the sync_exchange server service, the latter exchanges with the database)
3. NRPC - exchange with the database using the NRPC protocol
(the client service that needs to exchange with the database connects to the NATS service, which sends commands to the sync_exchange server, the latter exchanges with the database)
Before starting CRUD operations, with a direct connection to the DB, you must specify the transport through which the exchange will take place (not necessary for GRPC, NRPC) using the command:
InitCrudTransport_DB()
from module
"gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/crud_starter"
Also, to get started, the environment variables must be filled in:
(in ".env" file)
1) for DB CRUD:
DB_HOST=""
DB_NAME=""
DB_SCHEME=""
DB_PORT=""
DB_USER=""
DB_PASSWORD=""
2) for GRPC:
SYNC_SERVICE_HOST=
SYNC_SERVICE_PORT=
3) for NRPC:
BUS_LOCAL_HOST=
BUS_LOCAL_PORT=
For NRPC (and GRPC) it is advisable to connect there first and disconnect at the end
nrpc_client.Connect()
defer nrpc_client.CloseConnection()
otherwise, the code will still connect there and will not disconnect at the end of the microservice.