Skip to content

YAML Configuration System - Sync Service (Rust) #23

Description

@deserat

YAML Configuration System - Sync Service

Epic: EPIC-4 - Configuration Management
Service: sync-service (Rust)
Priority: P1
Story Points: 2

User Story

As a developer,
I need a YAML-based configuration system for sync-service,
So that I can manage vault watching, API client, and sync behavior without modifying code.

Acceptance Criteria

Configuration File Structure

  • sync-service/config.yaml created with complete configuration structure:
    vault:
      path: ~/noosphere-vault
      watch_recursive: true
      debounce_ms: 500  # Wait 500ms after last change before syncing
    
    api:
      base_url: http://127.0.0.1:8000
      timeout_ms: 5000
      retry_attempts: 3
      retry_delay_ms: 1000
    
    sync:
      batch_size: 10
      sync_interval_ms: 60000  # Sync every 60 seconds
      ignore_patterns:
        - "*.lock"
        - "*.tmp"
        - ".DS_Store"
        - ".noosphere-metadata"
    
    logging:
      level: info
      format: text  # or "json"
      file: logs/sync-service.log
      max_size_mb: 10
      max_backups: 5

Configuration Template

  • sync-service/config.example.yaml created as template
  • All configuration options have inline comments
  • Template includes placeholder values
  • .gitignore updated to exclude config.yaml

Documentation

  • Configuration options documented in sync-service/README.md
  • Development defaults vs production recommendations
  • Validation rules documented (required fields, value ranges)

Dependencies

  • Add to Cargo.toml:
    [dependencies]
    serde_yaml = "0.9"
    serde = { version = "1.0", features = ["derive"] }

Technical Notes

Configuration Sections:

  • vault: File system path, watch settings, debouncing
  • api: HTTP client settings for connecting to api-service
  • sync: Batch sizes, intervals, ignore patterns
  • logging: Log levels, formats, rotation (tracing crate)

Security:

  • config.yaml excluded from git
  • config.example.yaml has placeholder values
  • API authentication tokens use environment variables

Rust Configuration Loading:

use serde::{Deserialize, Serialize};
use std::fs;

#[derive(Debug, Deserialize, Serialize)]
pub struct Config {
    pub vault: VaultConfig,
    pub api: ApiConfig,
    pub sync: SyncConfig,
    pub logging: LoggingConfig,
}

impl Config {
    pub fn load(path: &str) -> anyhow::Result<Self> {
        let content = fs::read_to_string(path)?;
        let config: Config = serde_yaml::from_str(&content)?;
        Ok(config)
    }
}

Dependencies

Verification

cd sync-service
cargo test --test config_test

# Manual validation
cargo run --example validate_config
# Should load config.example.yaml and print parsed values

Metadata

Metadata

Assignees

Labels

phase/1-foundationRepository, database, vault, scaffoldingpriority/P1Core foundation - must complete in phaseservice/sync-serviceFile watching Rust servicesize/S3 story pointstype/storyUser story from roadmap

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions