mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-11-24 08:22:42 +02:00
43 lines
1.6 KiB
Plaintext
43 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. Commands in NATS for reading, changing, etc.
|
|
2. DB CRUD operations - direct exchange with the database
|
|
(each table model has methods Read(), Update(), Create(), Save(), Delete(), Restore())
|
|
3. 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)
|
|
4. 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, you must specify the transport over which the exchange will take place (CRUD, GRPC, NRPC)
|
|
using one of the commands:
|
|
InitCrudTransport_DB()
|
|
InitCrudTransport_GRPC()
|
|
InitCrudTransport_NRPC()
|
|
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 (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. |