Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/brobridgeorg/gravity-adapter-mysql

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/brobridgeorg/gravity-adapter-mysql

  • v0.0.0-20240822080026-57fb56fca693
  • Source
  • Go
  • Socket score

Version published
Created
Source

gravity-adapter-mysql

Gravity adapter for MySQL


config.toml 說明

configs/config.toml example
[gravity]
domain = "default"
host = "192.168.8.227"
port = 32803
pingInterval = 10
maxPingsOutstanding = 3
maxReconnects = -1
accessToken = ""

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

[store]
enabled = true
path = "./statestore"
參數說明
gravity.domain設定gravity domain
gravity.host設定 gravity 的 nats ip
gravity.port設定 gravity 的 nats port
gravity.pingInterval設定 gravity 的 pingInterval
gravity.maxPingsOutstanding設定 gravity 的 maxPingOutstanding
gravity.maxReconnects設定 gravity 的 maxReconnects
gravity.accessToken設定 gravity 的 accessToken (for auth)
source.config設定 Adapter 的 來源設定檔位置
store.enabled是否掛載 presistent volume (記錄狀態)
store.path設定 presistent volume 掛載點 (記錄狀態)

INFO

config.toml 設定可由環境變數帶入,其環境變數命名如下: GRAVITY_ADAPTER_MYSQL + _ + [section] + _ + key 其中所有英文字母皆為大寫並使用_做連接。

YAML 由環境變數帶入 gravity.host 範例:

env:
- name: GRAVITY_ADAPTER_MYSQL_GRAVITY_HOST
  value: 192.168.8.227

settings.json 說明

settings/sources.json example
{
	"sources": {
		"mysql_example": {
			"disabled": false,
			"host": "192.168.8.227",
			"port": 3306,
			"username": "root",
			"password": "1qaz@WSXROOT",
			"dbname": "gravity",
			"initialLoad": false,
			"tables": {
				"accounts":{
					"event": {
						"snapshot": "accountInitialized",
						"create": "accountCreated",
						"update": "accountUpdated",
						"delete": "accountDeleted"
					}
				}
			}
		}
	}
}
參數說明
sources.SOURCE_NAME.disabled是否停用這個source
sources.SOURCE_NAME.host設定postgresql server ip
sources.SOURCE_NAME.port設定postgresql server port
sources.SOURCE_NAME.username設定 postgresql 登入帳號
sources.SOURCE_NAME.password設定 postgresql 登入密碼
sources.SOURCE_NAME.dbname設定 postgresql database name
sources.SOURCE_NAME.initialLoad是否同步既有 record (在初始化同步時禁止對該資料表進行操作)
sources.SOURCE_NAME.tables.TABLE_NAME設定要捕獲事件的 table 名稱
sources.SOURCE_NAME.tables.TABLE_NAME.event.snapshot設定 initialLoad event name
sources.SOURCE_NAME.tables.TABLE_NAME.event.create設定 create event name
sources.SOURCE_NAME.tables.TABLE_NAME.event.update設定 update event name
sources.SOURCE_NAME.tables.TABLE_NAME.event.delete設定 delete event name

INFO

資料庫的連線密碼可由環境變數帶入(需要使用工具做 AES 加密),其環境變數如下: [SOURCE_NAME] + _ + PASSWORD

settings.json 設定可由環境變數帶入,其環境變數如下: GRAVITY_ADAPTER_MYSQL_SOURCE_SETTINGS

YAML 由環境變數帶入範例:

env:
- name: GRAVITY_ADAPTER_MYSQL_SOURCE_SETTINGS
      value: |
        {
            "sources": {
                "mysql_example": {
                    "disabled": false,
                    "host": "192.168.8.227",
                    "port": 3306,
                    "username": "root",
                    "password": "1qaz@WSXROOT",
                    "dbname": "gravity",
                    "initialLoad": false,
                    "tables": {
                        "accounts":{
                            "event": {
                                "snapshot": "accountInitialized",
                                "create": "accountCreated",
                                "update": "accountUpdated",
                                "delete": "accountDeleted"
                            }
                        }
                    }
                }
            }
        }

補充

設定 Log 呈現的 Level 可由環境變數帶入: 其設定可使用 debug, info, error

env:
- name: GRAVITY_DEBUG
  value: debug

Build

podman buildx build --platform linux/amd64 --build-arg="AES_KEY=**********" -t docker.io/brobridgehub/gravity-adapter-mysql:v3.0.0 -f build/docker/Dockerfile .

Enable Database CDC

Enable binlog MySQL 8.0

vim /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
...
log-bin=/var/lib/mysql/binlog
binlog-format=row

Enable binlog MySQL 5.7

vim /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
...
server-id=1
log-bin=/var/lib/mysql/mysql-bin.log
binlog-format=row
max_allowed_packet=100M

Check binlog is enabled

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.00 sec)


License

Licensed under the MIT License

Authors

Copyright(c) 2020 Fred Chien <fred@brobridge.com>
Copyright(c) 2020 Jhe Sue <jhe@brobridge.com>

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc