Skip to content

Commit b91b67b

Browse files
authored
PCSM-230: Fix filtered sync (#162)
1 parent 218e9df commit b91b67b

18 files changed

+423
-172
lines changed

AGENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AGENTS.md - Percona ClusterSync for MongoDB
2+
3+
## Build/Lint/Test Commands
4+
- **Build**: `make build` (production) or `make test-build` (with race detection)
5+
- **Lint**: `make lint` (uses golangci-lint with gofmt, gofumpt, goimports)
6+
- **Test Go**: `go test -race ./...` or `make test`
7+
- **Test Python**: `poetry run pytest` or `make pytest`
8+
- **Single Go Test**: `go test -race -run TestName ./package`
9+
- **Single Python Test**: `poetry run pytest tests/test_file.py::test_name`
10+
- **Clean**: `make clean`
11+
12+
## Code Style Guidelines
13+
- **Imports**: Group stdlib, third-party, local (separated by blank lines). Use `goimports` for formatting.
14+
- **Error Handling**: Use custom `errors` package (`errors.Wrap`, `errors.New`, `errors.Join`). Always wrap errors with context. Return `nil` for nil errors in Wrap.
15+
- **Types**: Prefer explicit types. Use generics where appropriate. Document exported types with comments.
16+
- **Naming**: Use camelCase for unexported, PascalCase for exported. Acronyms stay uppercase (e.g., `URI`, `HTTP`).
17+
- **Comments**: Document all exported functions/types with godoc format. Start with the function/type name.
18+
- **Linting**: Follow golangci-lint v2 with most linters enabled (see `.golangci.yml`). Use `//nolint:lintername` sparingly with justification.
19+
- **Context**: Pass `context.Context` as first parameter. Use `util.CtxWithTimeout` for timeout operations.
20+
- **Formatting**: Use `gofmt` and `gofumpt`. Max line length flexible but keep readable. Use tabs for indentation.
21+
- **Testing**: Use `testify` for assertions. Add `-race` flag. Python tests use `pytest` with `pymongo`.

hack/change_stream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env python3
2-
# poetry run python3 .dev/change_stream.py mongodb://adm:pass@rs00:30000
2+
# poetry run python3 .dev/change_stream.py mongodb://rs00:30000
33

44
import sys
55
from signal import SIG_DFL, SIGINT, signal
66

77
import bson.json_util as json
88
import pymongo
99

10-
MONGODB_URI = "mongodb://adm:pass@rs00:30000"
10+
MONGODB_URI = "mongodb://rs00:30000"
1111

1212
ignoreCheckpoints = True # set to False to see all changes, including checkpoints
1313

@@ -26,7 +26,7 @@
2626
del change["wallTime"]
2727

2828
ns = change["ns"]["db"]
29-
29+
3030
if ignoreCheckpoints and ns == "percona_link_mongodb":
3131
continue
3232

hack/compare-all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from pymongo import ASCENDING, MongoClient
88
from pymongo.collection import Collection
99

10-
SRC_URI = "mongodb://adm:pass@rs00:30000"
11-
TGT_URI = "mongodb://adm:pass@rs10:30100"
10+
SRC_URI = "mongodb://rs00:30000"
11+
TGT_URI = "mongodb://rs10:30100"
1212

13-
SRC_SH_URI = "mongodb://adm:pass@src-mongos:27017"
14-
TGT_SH_URI = "mongodb://adm:pass@tgt-mongos:29017"
13+
SRC_SH_URI = "mongodb://src-mongos:27017"
14+
TGT_SH_URI = "mongodb://tgt-mongos:29017"
1515

1616
src = pymongo.MongoClient(SRC_SH_URI)
1717
tgt = pymongo.MongoClient(TGT_SH_URI)

hack/drop-all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import pymongo
44

5-
SRC_URI = "mongodb://adm:pass@rs00:30000"
6-
TGT_URI = "mongodb://adm:pass@rs10:30100"
5+
SRC_URI = "mongodb://rs00:30000"
6+
TGT_URI = "mongodb://rs10:30100"
77

8-
SRC_SH_URI = "mongodb://adm:pass@src-mongos:27017"
9-
TGT_SH_URI = "mongodb://adm:pass@tgt-mongos:29017"
8+
SRC_SH_URI = "mongodb://src-mongos:27017"
9+
TGT_SH_URI = "mongodb://tgt-mongos:29017"
1010

1111
src = pymongo.MongoClient(SRC_SH_URI)
1212
tgt = pymongo.MongoClient(TGT_SH_URI)

hack/oplog_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pymongo
55

66
if __name__ == "__main__":
7-
MONGODB_URI = "mongodb://adm:pass@rs10:30100,rs11:30101,rs12:30102"
7+
MONGODB_URI = "mongodb://rs10:30100,rs11:30101,rs12:30102"
88
m = pymongo.MongoClient(MONGODB_URI, readPreference="primary")
99
for change in m.local["oplog.rs"].find():
1010
del change["_id"]

hack/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ host.docker.internal:2242/metrics
1010
## MongoLink CLI
1111

1212
```shell
13-
go install . && pml --source="mongodb://adm:pass@rs00:30000" --target="mongodb://adm:pass@rs10:30100" --reset-state --log-level="debug"
13+
go install . && pcsm --source="mongodb://rs00:30000" --target="mongodb://rs10:30100" --reset-state --log-level="debug"
1414
```
1515

1616

hack/rs/generate-data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pymongo
55
from pymongo import MongoClient
66

7-
MONGODB_URI = "mongodb://adm:pass@rs00:30000"
7+
MONGODB_URI = "mongodb://rs00:30000"
88
client = MongoClient(MONGODB_URI)
99
db = client["stress_test_db"]
1010

hack/rs/generate-replication-data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bson import ObjectId, BSON
88
from datetime import datetime
99

10-
uri = "mongodb://adm:pass@rs00:30000"
10+
uri = "mongodb://rs00:30000"
1111
# uri="mongodb://inel:[email protected]/"
1212

1313

hack/rs/generate-replication-txn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import threading
77

88
# MongoDB connection
9-
uri = "mongodb://adm:pass@rs00:30000"
9+
uri = "mongodb://rs00:30000"
1010
client = MongoClient(uri) # Ensure you have a replica set
1111

1212
# Databases and collections

hack/rs/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bson import ObjectId, BSON
88
from datetime import datetime
99

10-
uri="mongodb://adm:pass@rs00:30000"
10+
uri="mongodb://rs00:30000"
1111
# uri="mongodb://inel:[email protected]/"
1212

1313
def log(msg):

0 commit comments

Comments
 (0)