How vishalk91-4/syncinator works
Purpose and entry points
Syncinator is a Go, gRPC-based distributed file synchronization system. Clients mirror a local base directory with remote metadata and content services. Executables are:
• Client sync process: cmd/SyncinatorClientExec/main.go
• Block data server: cmd/SyncinatorServerExec/main.go
• RAFT-backed metadata server: cmd/SyncinatorRaftServerExec/main.go
• Block-placement inspection utility: cmd/SyncinatorPrintBlockMapping/main.go
RPC contract and process boundary
The shared service contract is defined in pkg/syncinator/Syncinator.proto, with generated Go/gRPC bindings in pkg/syncinator/Syncinator_grpc.pb.go. Client and server processes communicate exclusively through gRPC; local filesystem state and remote service state are separate ownership domains.
Client synchronization engine
pkg/syncinator/Syncinator.go implements synchronization around local directory scanning, block hashing, index.db-backed state, remote metadata retrieval, and upload/download decisions. pkg/syncinator/SyncinatorRPCClient.go is the client-side RPC adapter, while pkg/syncinator/SyncinatorInterfaces.go defines the key abstractions. The core merge boundary is the three-view comparison of local disk/index state, previously synced state, and current remote metadata.
Content plane: BlockStore
pkg/syncinator/BlockStore.go owns content-addressed file blocks. Files are divided into fixed-size blocks and addressed by SHA-256 hashes; metadata refers to block hashes rather than embedding file data. This allows deduplication and separates large payload transfer from metadata consensus.
Metadata plane and block placement
pkg/syncinator/MetaStore.go maintains filename versions, file hash lists, and BlockStore membership/mappings. pkg/syncinator/ConsistentHashRing.go maps each block hash to a BlockStore endpoint using a SHA-256 consistent-hash ring. Metadata operations determine where clients upload or retrieve each block; BlockStores do not independently coordinate file versions.
Replicated metadata consensus
pkg/syncinator/RaftSyncinatorServer.go wraps metadata mutation in RAFT replication so MetaStore replicas converge and tolerate node failures. Consensus interfaces and protocol constants are concentrated in pkg/syncinator/RaftInterfaces.go and pkg/syncinator/RaftConstants.go. This is the authoritative write-control boundary: conflicting or stale metadata updates are resolved by the replicated service rather than clients.
Primary flow and infrastructure
A client scans its base directory, computes block hash lists, compares local/index state against remote metadata, then:
1. obtains current metadata and block placement from MetaStore;
2. uploads missing blocks to mapped BlockStores;
3. submits versioned metadata updates through the RAFT-backed MetaStore; or
4. downloads remotely newer blocks and reconstructs files locally.
Runtime topology is supplied by JSON endpoint configuration, principally config.json; shell launchers (run_syncinator.sh, run_block_server.sh, run_meta_server.sh) start the three process roles. Material dependencies are Go, gRPC/protobuf, SHA-256 hashing, local filesystem/index persistence, and a multi-node RAFT network.
Main entry points: Syncinator.go Synchronization engine · BlockStore.go BlockStore · config.json Endpoint configuration · Syncinator.proto Syncinator gRPC contract
Components 15
Client sync runtime
- Client executable
cmd/SyncinatorClientExec/main.go - Synchronization engine · Performs scan, comparison, and transfer decisions.
pkg/syncinator/Syncinator.go - Local base directory
- index.db state · Tracks prior synchronized state.
- Three-view merge · Compares disk/index state, prior sync state, and remote metadata.
pkg/syncinator/Syncinator.go - RPC client adapter
pkg/syncinator/SyncinatorRPCClient.go
Metadata consensus plane
- RAFT metadata executable
cmd/SyncinatorRaftServerExec/main.go - RAFT metadata server · Replicates metadata mutations across a RAFT network.
pkg/syncinator/RaftSyncinatorServer.go - MetaStore · Stores file versions, block hashes, and block mappings.
pkg/syncinator/MetaStore.go - Consistent hash ring · Maps block hashes to BlockStore endpoints.
pkg/syncinator/ConsistentHashRing.go
Content plane
- Block server executable
cmd/SyncinatorServerExec/main.go - BlockStore · Stores fixed-size SHA-256-addressed file blocks.
pkg/syncinator/BlockStore.go
Other components
- Syncinator gRPC contract
pkg/syncinator/Syncinator.proto - Block mapping inspector
cmd/SyncinatorPrintBlockMapping/main.go - Endpoint configuration · Supplies runtime service topology.
config.json
Connections 18
- Client executable → Synchronization engine: runs
- Synchronization engine → Local base directory: scans and reconstructs
- Synchronization engine → index.db state: reads/writes sync state
- Synchronization engine → Three-view merge: evaluates changes
- Three-view merge → RPC client adapter: requests metadata or transfer
- RPC client adapter → Syncinator gRPC contract: uses
- Syncinator gRPC contract → RAFT metadata server: metadata RPCs
- Syncinator gRPC contract → BlockStore: block RPCs
- RAFT metadata executable → RAFT metadata server: runs
- RAFT metadata server → MetaStore: replicates mutations to
- MetaStore → Consistent hash ring: uses placement mapping
- Consistent hash ring → BlockStore: selects endpoint
- Block server executable → BlockStore: runs
- Synchronization engine → BlockStore: uploads/downloads hashed blocks
- Block mapping inspector → MetaStore: inspects mappings
- Endpoint configuration → Client executable: configures endpoints
- Endpoint configuration → RAFT metadata executable: configures topology
- Endpoint configuration → Block server executable: configures endpoint