weedforge
A lightweight Rust SDK with Python bindings for SeaweedFS.
Features
- Clean Architecture: Domain, Application, Infrastructure, Python layers
- HA-aware: Multiple master support with automatic failover
- Async + Sync: Both async and blocking Rust APIs
- Type-safe:
FileIdas a first-class entity, not an opaque string - Python bindings: Native Python SDK via PyO3
- Production-ready: Retry logic, error handling, tracing
Installation
Rust
[]
= "0.1"
Python
Quick Start
Rust (Async)
use WeedClient;
async
Rust (Blocking)
use BlockingWeedClient;
Python
# Create client
=
# Upload bytes
=
# Download
=
# Get public URL
=
# With image resize
=
# Delete
# Parse file ID from string
=
Architecture
weedforge follows Clean Architecture principles:
┌─────────────────────────────────────────┐
│ Python Bindings │ ← Thin wrappers (PyO3)
├─────────────────────────────────────────┤
│ Application Layer │ ← Use cases (WriteFile, ReadFile)
├─────────────────────────────────────────┤
│ Domain Layer │ ← Entities (FileId), Ports (traits)
├─────────────────────────────────────────┤
│ Infrastructure Layer │ ← HTTP clients, HA logic
└─────────────────────────────────────────┘
Dependencies flow downward only:
- Python → Application → Domain → Infrastructure
- Domain layer has no external dependencies
- Application layer is fully testable with mocks
Configuration
Master Selection Strategies
| Strategy | Description |
|---|---|
round_robin |
Cycle through masters (default) |
failover |
Try masters in order, failover on error |
random |
Random selection |
Rust Builder Options
let client = builder
.master_urls
.strategy
.max_retries
.http_config
.build?;
SeaweedFS Protocol
weedforge implements the official SeaweedFS protocol:
Write Flow
GET /dir/assign→ Get file ID and volume URLPOST {volume_url}/{fid}→ Upload file (multipart)- Return
fidfor storage
Read Flow
GET /dir/lookup?volumeId=X→ Get volume locations- Select replica (random or deterministic)
GET {volume_url}/{fid}→ Download file
Development
Prerequisites
- Rust 1.75+
- Python 3.9+ (for Python bindings)
- maturin (for building Python wheels)
Build
# Rust
# Python (development)
# Python (release wheel)
Test
# Rust tests
# Clippy
# Format check
# Security audit