跳至主要内容

Microsoft SQL Adapter

1. config.toml Explanation

1.1 Example of configs/config.toml

[gravity]
domain = "default"
host = "192.168.8.227"
port = 4222
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.domainSets the Gravity domain
gravity.hostSets the Gravity NATS IP address
gravity.portSets the Gravity NATS port
gravity.pingIntervalSets the Gravity ping interval
gravity.maxPingsOutstandingSets the maximum outstanding pings
gravity.maxReconnectsSets the maximum number of reconnections
gravity.accessTokenSets the Gravity access token (for authentication)
gravity.publishBatchSizeSets the batch size for events sent to NATS
gravity.rateLimitSets the maximum rate (per second) for events sent to NATS (0 = no limit)
source.configPath to the source configuration file
store.enabledEnables persistent volume mounting (for state storage)
store.pathPath for mounting the persistent volume

INFO

The config.toml settings can also be provided via environment variables. The naming convention is as follows:

GRAVITY_ADAPTER_MSSQL_[SECTION]_[KEY]

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

env:
- name: GRAVITY_ADAPTER_MSSQL_GRAVITY_HOST
value: 192.168.0.1

2. settings.json Explanation

2.1 Example of settings/sources.json

{
"sources": {
"my_mssql": {
"disabled": false,
"host": "192.168.8.227",
"port": 1433,
"username": "SA",
"password": "1qaz@WSX",
"dbname": "TestDB",
"param": "",
"initialLoad": true,
"initialLoadBatchSize": 100000,
"//_comment_interval": "query interval unit: seconds",
"interval": 5,
"tables": {
"dbo.Inventory": {
"events": {
"snapshot": "accountInitialized",
"create": "accountCreated",
"update": "accountUpdated",
"delete": "accountDeleted"
}
}
}
}
}
}

2.2 Parameters

ParameterDescription
sources.SOURCE_NAME.disabledWhether to disable this source
sources.SOURCE_NAME.hostSets the MSSQL server IP address
sources.SOURCE_NAME.portSets the MSSQL server port
sources.SOURCE_NAME.usernameSets the MSSQL login username
sources.SOURCE_NAME.passwordSets the MSSQL login password
sources.SOURCE_NAME.dbnameSets the MSSQL database name
sources.SOURCE_NAME.paramAdditional connection parameters. See go-mssqldb common parameters.
sources.SOURCE_NAME.initialLoadWhether to synchronize existing records during initialization
sources.SOURCE_NAME.initialLoadBatchSizeNumber of records per batch during initial load
sources.SOURCE_NAME.intervalSynchronization interval for CDC events (in seconds)
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

If both the environment variable and settings.json specify a password, the environment variable takes precedence.
Example:

env:
- name: MY_MSSQL_PASSWORD
value: f737540b75550a17af98cd3e640f61fd

A password encryption tool is included in the hb.k8sbridge.com/gravity/gravity-adapter-mssql:v3.0.6 image. Use the following commands:

$ /pwd-encrypt --plaintext 123456
f737540b75550a17af98cd3e640f61fd

$ /pwd-encrypt --ciphertext f737540b75550a17af98cd3e640f61fd
123456

Let me know if you'd like me to translate or adjust additional sections!