Skip to content

Conversation

hifi
Copy link
Collaborator

@hifi hifi commented Dec 28, 2023

Not sure if this makes sense as it would pollute the top level a lot. Maybe better to create a separate key to put the defaults under and deprecate the two S3 variables on top level?

Fixes #504

@corylanou
Copy link
Collaborator

Thank you for this PR! We're taking over this work as the branch has become significantly outdated (2 years old) and the codebase has evolved substantially.

The core idea of implementing global replica defaults is excellent and we're implementing a fresh version that builds on your approach but works with the current codebase structure.

New tracking issue: #745

We'll reference this original PR in our implementation. Thanks for the contribution!

@corylanou corylanou closed this Sep 11, 2025
corylanou added a commit that referenced this pull request Sep 11, 2025
This feature allows users to define global default settings for replica configurations,
eliminating the need to duplicate common settings across multiple database entries.

## What's Changed

- **New ReplicaSettings struct**: Contains all configurable replica fields (S3, ABS, SFTP, NATS, Age encryption, timing settings)
- **Embedded in Config**: Global defaults can be set at the top level of configuration files
- **Embedded in ReplicaConfig**: Individual replicas inherit from global settings but can override any field
- **Smart default propagation**: SetDefaults() method merges global settings with replica-specific settings
- **Full backward compatibility**: Existing configurations continue to work unchanged
- **Comprehensive test coverage**: Tests cover all replica types and override scenarios

## Supported Global Settings

- **S3**: access-key-id, secret-access-key, region, endpoint, force-path-style, skip-verify
- **ABS**: account-name, account-key
- **SFTP**: host, user, password, key-path, concurrent-writes
- **NATS**: jwt, seed, creds, nkey, username, token, tls, root-cas, client-cert, client-key, etc.
- **Timing**: sync-interval, validation-interval
- **Encryption**: age identities and recipients

## Example Configuration

Before (verbose with duplication):
```yaml
dbs:
  - path: /db1.sqlite
    replica:
      type: s3
      access-key-id: AKIA...
      secret-access-key: xxx...
      region: us-west-2
      endpoint: custom.endpoint.com
      bucket: bucket1

  - path: /db2.sqlite
    replica:
      type: s3
      access-key-id: AKIA...      # duplicated
      secret-access-key: xxx...   # duplicated
      region: us-west-2           # duplicated
      endpoint: custom.endpoint.com # duplicated
      bucket: bucket2
```

After (clean with global defaults):
```yaml
# Global defaults
access-key-id: AKIA...
secret-access-key: xxx...
region: us-west-2
endpoint: custom.endpoint.com

dbs:
  - path: /db1.sqlite
    replica:
      type: s3
      bucket: bucket1

  - path: /db2.sqlite
    replica:
      type: s3
      bucket: bucket2
```

Fixes #504
Closes #553

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Allow global variables to avoid duplication
2 participants