Skip to main content

Postgre SQL Adapter

1. config.toml Explanation

1.1 Example of configs/config.toml

[gravity]
domain = "default"
host = "192.168.8.227"
port = 32803
pingInterval = 10
maxPingsOutstanding = 3
maxReconnects = -1
accessToken = ""
publishBatchSize = 1000
rateLimit = 0

[source]
config = "./settings/sources.json"

[store]
enabled = true
path = "./statestore"

1.2 Parameters

ParameterDescription
gravity.domainSet the gravity domain
gravity.hostSet the Gravity NATS IP address
gravity.portSet the Gravity NATS port
gravity.pingIntervalSet the Gravity ping interval
gravity.maxPingsOutstandingSet the maximum outstanding pings
gravity.maxReconnectsSet the maximum number of reconnections
gravity.accessTokenSet the Gravity access token (for authentication)
gravity.publishBatchSizeSet the number of events to batch before publishing
gravity.rateLimitSet the maximum rate of event publishing per second (0 = no limit)
source.configPath to the source configuration file
store.enabledWhether to mount a persistent volume (for state storage)
store.pathPath for mounting the persistent volume

💡 INFO

The config.toml settings can be provided via environment variables. The naming convention is as follows: GRAVITY_ADAPTER_POSTGRES_[SECTION]_[KEY]

All letters are uppercase, and underscores (_) are used to separate sections and keys.
Example for gravity.host:

env:
- name: GRAVITY_ADAPTER_POSTGRES_GRAVITY_HOST
value: 192.168.0.1

2. settings.json Explanation

2.1 Example of settings/sources.json

{
"sources": {
"my_postgres": {
"disabled": false,
"host": "192.168.8.227",
"port": 5432,
"username": "postgres",
"password": "1qaz@WSX",
"dbname": "gravity",
"param": "sslmode=disable",
"initialLoad": true,
"initialLoadBatchSize": 10000,
"//_comment_interval": "query interval unit: seconds",
"interval": 1,
"slotName": "regression_slot",
"//_comment_public.account": "schema.tableName",
"tables": {
"public.account": {
"events": {
"snapshot": "accountInitialized",
"create": "accountCreated",
"update": "accountUpdated",
"delete": "accountDeleted"
}
}
}
}
}
}

2.2 Parameters

ParameterDescription
sources.SOURCE_NAME.disabledWhether to disable this source
sources.SOURCE_NAME.hostPostgreSQL server IP
sources.SOURCE_NAME.portPostgreSQL server port
sources.SOURCE_NAME.usernamePostgreSQL username
sources.SOURCE_NAME.passwordPostgreSQL password
sources.SOURCE_NAME.dbnamePostgreSQL database name
sources.SOURCE_NAME.paramAdditional connection parameters (e.g., "sslmode=disable")
sources.SOURCE_NAME.initialLoadWhether to synchronize existing records initially
sources.SOURCE_NAME.initialLoadBatchSizeNumber of records per batch during initial sync
sources.SOURCE_NAME.intervalSync interval for initial load events (in seconds)
sources.SOURCE_NAME.slotNameName of the replication slot
sources.SOURCE_NAME.tables.TABLE_NAMEName of the table to capture events (e.g., "public.account")
sources.SOURCE_NAME.tables.TABLE_NAME.event.snapshotEvent name for initial load
sources.SOURCE_NAME.tables.TABLE_NAME.event.createEvent name for record creation
sources.SOURCE_NAME.tables.TABLE_NAME.event.updateEvent name for record updates
sources.SOURCE_NAME.tables.TABLE_NAME.event.deleteEvent name for record deletion

INFO

The database password can be provided via environment variables using AES encryption.
Environment variable format: [SOURCE_NAME]_PASSWORD