mirror of
https://github.com/hanzoai/replicate.git
synced 2026-10-30 18:23:20 +00:00
- All source files, configs, docs, CI renamed - Binary: replicate (not litestream) - Config: replicate.yml (litestream.yml as fallback) - Env: REPLICATE_* (LITESTREAM_* as fallback) - Socket: /var/run/replicate.sock - Image: ghcr.io/hanzoai/replicate - Module: github.com/hanzoai/replicate - Package name: replicate (Go), replicate-vfs (npm/pip/gem) - VFS: registered as "replicate", pragmas replicate_* - C exports: ReplicateVFSRegister, GoReplicate* - Windows service: Replicate - Systemd unit: replicate.service - Upstream attribution preserved (README, upgrade test scripts)
2.5 KiB
2.5 KiB
description
| description |
|---|
| Create a new storage backend implementation |
Add Storage Backend Command
Create a new storage backend implementation for Replicate with all required components.
Steps
-
Create Package Directory
mkdir -p {{backend_name}} -
Implement ReplicaClient Interface Create
{{backend_name}}/replica_client.go:package {{backend_name}} type ReplicaClient struct { // Configuration fields } func (c *ReplicaClient) Type() string { return "{{backend_name}}" } func (c *ReplicaClient) LTXFiles(ctx context.Context, level int, seek ltx.TXID, useMetadata bool) (ltx.FileIterator, error) { // List files at level // When useMetadata=true, fetch accurate timestamps from backend metadata } func (c *ReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) { // Open file for reading } func (c *ReplicaClient) WriteLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error) { // Write file atomically } func (c *ReplicaClient) DeleteLTXFiles(ctx context.Context, files []*ltx.FileInfo) error { // Delete files } func (c *ReplicaClient) DeleteAll(ctx context.Context) error { // Remove all files for replica } -
Add Configuration Parsing Update
cmd/replicate/config.go:case "{{backend_name}}": client = &{{backend_name}}.ReplicaClient{ // Parse config } -
Create Integration Tests Create
{{backend_name}}/replica_client_test.go:func TestReplicaClient_{{backend_name}}(t *testing.T) { if !*integration || *backend != "{{backend_name}}" { t.Skip("{{backend_name}} integration test skipped") } // Test implementation } -
Add Documentation Update README.md with configuration example:
replica: type: {{backend_name}} option1: value1 option2: value2
Key Requirements
- Handle eventual consistency
- Implement atomic writes (temp file + rename)
- Support partial reads (offset/size)
- Preserve CreatedAt timestamps in returned FileInfo
- Return proper error types (os.ErrNotExist)
Testing
# Run integration tests
go test -v ./replica_client_test.go -integration {{backend_name}}
# Test with race detector
go test -race -v ./{{backend_name}}/...