一键导入
create-dsync-connector
Create a new dsync connector with test suite. Use when adding support for a new data source/sink type (e.g., file, S3, database).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a new dsync connector with test suite. Use when adding support for a new data source/sink type (e.g., file, S3, database).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | create-dsync-connector |
| description | Create a new dsync connector with test suite. Use when adding support for a new data source/sink type (e.g., file, S3, database). |
file://, s3://, mongodb://)Read a similar connector as reference. Good examples:
connectors/s3/ - File-based sink with batchingconnectors/postgres/ - Full-featured with CDC using logical replicationconnectors/mongo/ - Full-featured with streamingconnectors/sqlbatch/ - Connector for SQL sources using a custom query and change-tracking with polling for CDCconnectors/null/ - Minimal sink-onlyconnectors/random/ - Source-onlyKey files to understand:
connector.go - Main implementationinternal/app/options/connectorflags.go - Registration and CLI flagspkg/test/connector.go - Test suite frameworkconnectors/<name>/
├── connector.go # Main implementation
└── connector_test.go # Tests
Required elements:
adiomv1connect.ConnectorServiceHandlerDbType identifierSource capabilities if readableSink capabilities if writableUnimplemented:
GeneratePlan - partition data for readingGetNamespaceMetadata - count recordsListData - read dataWriteData - write dataStreamUpdates - CDC (or Unimplemented)StreamLSN - LSN tracking (or Unimplemented)WriteUpdates - incremental updates (or Unimplemented)Notes:
Error message guidelines:
fmt.Errorf("failed to X for Y: %w", err) patternEdit internal/app/options/connectorflags.go:
myconnector "github.com/adiom-data/dsync/connectors/<name>"
GetRegisteredConnectors():{
Name: "<Name>",
IsConnector: func(s string) bool {
return strings.HasPrefix(strings.ToLower(s), "<scheme>://")
},
Create: func(args []string, as AdditionalSettings) (adiomv1connect.ConnectorServiceHandler, []string, error) {
settings := myconnector.ConnectorSettings{Uri: args[0]}
return CreateHelper("<name>", "<usage>", MyConnectorFlags(&settings),
func(_ *cli.Context, _ []string, _ AdditionalSettings) (adiomv1connect.ConnectorServiceHandler, error) {
return myconnector.NewConn(settings)
})(args, as)
},
},
func MyConnectorFlags(settings *myconnector.ConnectorSettings) []cli.Flag {
return []cli.Flag{
// Define CLI flags
}
}
Create connectors/<name>/test_data/ with:
Create connector_test.go:
func TestMyConnectorSuite(t *testing.T) {
tSuite := pkgtest.NewConnectorTestSuite(
"namespace",
func() adiomv1connect.ConnectorServiceClient {
conn, _ := NewConn(ConnectorSettings{Uri: "..."})
return pkgtest.ClientFromHandler(conn)
},
bootstrapFunc, // or nil
insertUpdatesFunc, // or nil
numPages,
numItems,
)
// Set flags for unsupported features:
tSuite.SkipDuplicateTest = true // If output order non-deterministic
tSuite.SkipWriteUpdatesTest = true // If WriteUpdates not supported
suite.Run(t, tSuite)
}
Run:
go build ./...
go test ./connectors/<name>/... -v
Check:
--help shows connector optionsRun dsync with the new connector as destination:
go run main.go /dev/fakesource <new-connector-uri> [options]
Evaluate output for: namespaces, data content, warnings, errors.
Run dsync with the new connector as source:
go run main.go <new-connector-uri> /dev/null --log-json
Evaluate output for: namespaces, data content, warnings, errors.
Try running both (one from /dev/fakesource to the new connector, and another one from the new connector to /dev/null) at the same time to ensure that the CDC is working correctly.