1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2025-01-23 09:24:43 +02:00

39 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-03-22 16:26:01 +03:00
The service implements synchronous data exchange.
Service for exchanging data with Postgres SQL database
Data exchange is done using different methods:
2024-08-14 11:19:20 +03:00
1. DB CRUD operations - direct exchange with the database
2024-03-22 16:26:01 +03:00
(each table model has methods Read(), Update(), Create(), Save(), Delete(), Restore())
2024-08-14 11:19:20 +03:00
2. GRPC - exchange with the database using the GRPC protocol
2024-03-22 16:26:01 +03:00
(the client service that needs to exchange with the database connects to the sync_exchange server service, the latter exchanges with the database)
2024-08-14 11:19:20 +03:00
3. NRPC - exchange with the database using the NRPC protocol
2024-03-22 16:26:01 +03:00
(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)
2024-08-14 11:19:20 +03:00
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:
2024-03-22 16:26:01 +03:00
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:
2024-04-04 15:18:28 +03:00
(in ".env" file)
2024-03-22 16:26:01 +03:00
1) for DB CRUD:
2024-04-04 15:18:28 +03:00
DB_HOST=""
DB_NAME=""
DB_SCHEME=""
DB_PORT=""
2024-03-22 16:26:01 +03:00
DB_USER=""
DB_PASSWORD=""
2) for GRPC:
2024-04-04 15:18:28 +03:00
SYNC_SERVICE_HOST=
SYNC_SERVICE_PORT=
2024-03-22 16:26:01 +03:00
3) for NRPC:
2024-04-04 15:18:28 +03:00
BUS_LOCAL_HOST=
BUS_LOCAL_PORT=
2024-03-22 16:26:01 +03:00
2024-08-14 11:19:20 +03:00
For NRPC (and GRPC) it is advisable to connect there first and disconnect at the end
2024-03-22 16:26:01 +03:00
nrpc_client.Connect()
defer nrpc_client.CloseConnection()
otherwise, the code will still connect there and will not disconnect at the end of the microservice.