Skip to content

Commit cd7ffc1

Browse files
committed
PCSM-219: Consolidate configuration documentation
- Add configuration reference table to config/config.go (single source of truth) - Remove redundant config source comments from config/values.go - Remove references to external decision documents - Simplify function comments to describe behavior, not configuration
1 parent e358ba1 commit cd7ffc1

File tree

2 files changed

+27
-43
lines changed

2 files changed

+27
-43
lines changed

config/config.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,26 @@ func Init(cmd *cobra.Command) {
3434
}
3535

3636
// bindEnvVars binds environment variable names to Viper keys.
37-
// Only global/server options have env var support.
38-
// Clone tuning options are intentionally NOT bound (CLI/HTTP only).
37+
//
38+
// Configuration Reference:
39+
//
40+
// | Viper Key | CLI Flag | Env Var | Default |
41+
// |--------------------------------|-----------------------------------|--------------------------------------|---------|
42+
// | source | --source | PCSM_SOURCE_URI | - |
43+
// | target | --target | PCSM_TARGET_URI | - |
44+
// | port | --port | PCSM_PORT | 2242 |
45+
// | log-level | --log-level | PCSM_LOG_LEVEL | info |
46+
// | log-json | --log-json | PCSM_LOG_JSON | false |
47+
// | no-color | --no-color | PCSM_NO_COLOR | false |
48+
// | mongodb-cli-operation-timeout | --mongodb-cli-operation-timeout | PCSM_MONGODB_CLI_OPERATION_TIMEOUT | 5m |
49+
// | use-collection-bulk-write | --use-collection-bulk-write | PCSM_USE_COLLECTION_BULK_WRITE | false |
50+
// | clone-num-parallel-collections | --clone-num-parallel-collections | - | 0 |
51+
// | clone-num-read-workers | --clone-num-read-workers | - | 0 |
52+
// | clone-num-insert-workers | --clone-num-insert-workers | - | 0 |
53+
// | clone-segment-size | --clone-segment-size | - | 0 |
54+
// | clone-read-batch-size | --clone-read-batch-size | - | 0 |
55+
//
56+
// Note: Clone tuning options are CLI/HTTP only (no env var support).
3957
func bindEnvVars() {
4058
// Server connection URIs
4159
_ = viper.BindEnv("source", "PCSM_SOURCE_URI")
@@ -44,12 +62,8 @@ func bindEnvVars() {
4462
// MongoDB client timeout
4563
_ = viper.BindEnv("mongodb-cli-operation-timeout", "PCSM_MONGODB_CLI_OPERATION_TIMEOUT")
4664

47-
// Bulk write option (internal, has env var support)
65+
// Bulk write option (hidden, internal use)
4866
_ = viper.BindEnv("use-collection-bulk-write", "PCSM_USE_COLLECTION_BULK_WRITE")
49-
50-
// NOTE: Clone tuning options intentionally NOT bound to env vars.
51-
// They are CLI/HTTP-only per stakeholder decision (PCSM-219).
52-
// See: comment-decisions.md - Decision #2
5367
}
5468

5569
// GetString returns a string configuration value from Viper.

config/values.go

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,31 @@ import (
1212
)
1313

1414
// UseCollectionBulkWrite returns whether to use collection-level bulk write.
15-
// This is an internal option, not exposed via HTTP API.
16-
//
17-
// Configuration sources (in order of precedence):
18-
// - CLI flag: --use-collection-bulk-write (hidden)
19-
// - Env var: PCSM_USE_COLLECTION_BULK_WRITE
20-
// - Default: false
15+
// Internal option, not exposed via HTTP API.
2116
func UseCollectionBulkWrite() bool {
2217
return viper.GetBool("use-collection-bulk-write")
2318
}
2419

2520
// CloneNumParallelCollections returns the number of collections to clone in parallel.
26-
// Configurable via CLI flag only (no env var support per decision #2).
27-
//
28-
// Configuration sources (in order of precedence):
29-
// - CLI flag: --clone-num-parallel-collections
30-
// - Default: 0 (auto)
21+
// Returns 0 for auto-detection.
3122
func CloneNumParallelCollections() int {
3223
return viper.GetInt("clone-num-parallel-collections")
3324
}
3425

3526
// CloneNumReadWorkers returns the number of read workers.
36-
// Configurable via CLI flag only (no env var support per decision #2).
37-
//
38-
// Configuration sources (in order of precedence):
39-
// - CLI flag: --clone-num-read-workers
40-
// - Default: 0 (auto)
27+
// Returns 0 for auto-detection.
4128
func CloneNumReadWorkers() int {
4229
return viper.GetInt("clone-num-read-workers")
4330
}
4431

4532
// CloneNumInsertWorkers returns the number of insert workers.
46-
// Configurable via CLI flag only (no env var support per decision #2).
47-
//
48-
// Configuration sources (in order of precedence):
49-
// - CLI flag: --clone-num-insert-workers
50-
// - Default: 0 (auto)
33+
// Returns 0 for auto-detection.
5134
func CloneNumInsertWorkers() int {
5235
return viper.GetInt("clone-num-insert-workers")
5336
}
5437

5538
// CloneSegmentSizeBytes returns the segment size in bytes.
56-
// Configurable via CLI flag only (no env var support per decision #2).
57-
//
58-
// Configuration sources (in order of precedence):
59-
// - CLI flag: --clone-segment-size
60-
// - Default: AutoCloneSegmentSize (0 = auto)
39+
// Returns 0 (AutoCloneSegmentSize) for auto-detection.
6140
func CloneSegmentSizeBytes() int64 {
6241
sizeStr := viper.GetString("clone-segment-size")
6342
if sizeStr == "" {
@@ -73,11 +52,7 @@ func CloneSegmentSizeBytes() int64 {
7352
}
7453

7554
// CloneReadBatchSizeBytes returns the read batch size in bytes.
76-
// Configurable via CLI flag only (no env var support per decision #2).
77-
//
78-
// Configuration sources (in order of precedence):
79-
// - CLI flag: --clone-read-batch-size
80-
// - Default: 0 (uses MaxWriteBatchSizeBytes)
55+
// Returns 0 to use MaxWriteBatchSizeBytes default.
8156
func CloneReadBatchSizeBytes() int32 {
8257
sizeStr := viper.GetString("clone-read-batch-size")
8358
if sizeStr == "" {
@@ -112,11 +87,6 @@ func UseTargetClientCompressors() []string {
11287
}
11388

11489
// MongoDBOperationTimeout returns the timeout for MongoDB client operations.
115-
//
116-
// Configuration sources (in order of precedence):
117-
// - CLI flag: --mongodb-cli-operation-timeout
118-
// - Env var: PCSM_MONGODB_CLI_OPERATION_TIMEOUT
119-
// - Default: 5m
12090
func MongoDBOperationTimeout() time.Duration {
12191
timeoutStr := viper.GetString("mongodb-cli-operation-timeout")
12292
if timeoutStr != "" {

0 commit comments

Comments
 (0)