Documentation
¶
Overview ¶
Package cmd provides CLI command implementations for ZapFS services. This file contains reusable helpers for configuration loading with CLI flag precedence.
Index ¶
- Variables
- func Execute()
- func VersionInfo() map[string]string
- type AccessLogConfig
- type AccessLogManager
- type BackendOpts
- type EventPublisherConfig
- type FileServerOpts
- type FlagLoader
- func (f *FlagLoader) Bool(flagName string) bool
- func (f *FlagLoader) Duration(flagName string) time.Duration
- func (f *FlagLoader) Int(flagName string) int
- func (f *FlagLoader) Int64(flagName string) int64
- func (f *FlagLoader) String(flagName string) string
- func (f *FlagLoader) StringSlice(flagName string) []string
- func (f *FlagLoader) Uint32(flagName string) uint32
- type ManagerServerOpts
- type MetadataServerOpts
- type ReplicationCredentials
- type TaskWorkerConfig
- type TaskWorkerManager
Constants ¶
This section is empty.
Variables ¶
var ( // Version is the semantic version (e.g., "1.0.0") Version = "dev" // GitCommit is the git commit hash GitCommit = "unknown" // BuildDate is the build timestamp BuildDate = "unknown" )
Build-time variables (set via -ldflags)
Functions ¶
func VersionInfo ¶
VersionInfo returns structured version information.
Types ¶
type AccessLogConfig ¶
type AccessLogConfig struct {
Enabled bool
ClickHouseDSN string
BatchSize int
FlushInterval time.Duration
ExportInterval time.Duration
DB db.DB
}
AccessLogConfig configures the access log collector.
type AccessLogManager ¶
type AccessLogManager struct{}
AccessLogManager is a stub for community edition.
func InitializeAccessLog ¶
func InitializeAccessLog(ctx context.Context, cfg AccessLogConfig) (*AccessLogManager, error)
InitializeAccessLog returns nil in community edition.
func (*AccessLogManager) Collector ¶
func (m *AccessLogManager) Collector() api.AccessLogCollector
Collector returns nil in community edition.
func (*AccessLogManager) Stop ¶
func (m *AccessLogManager) Stop()
Stop is a no-op in community edition.
type BackendOpts ¶
type BackendOpts struct {
ID string
Type types.StorageType
Path string // For local disk backends
Endpoint string // For S3/remote backends
Bucket string
Region string
AccessKey string
SecretKey string
StorageClass string
Enabled bool
DirectIO bool // Use O_DIRECT for writes (Linux only, bypasses page cache)
MinFreeSpace string
}
BackendOpts holds configuration for a storage backend
type EventPublisherConfig ¶
type EventPublisherConfig struct {
RedisAddr string
RedisPassword string
RedisDB int
RedisChannel string
}
EventPublisherConfig configures event notification publishers.
type FileServerOpts ¶
type FileServerOpts struct {
// Network binding
BindAddr string // Address to bind to (e.g., "0.0.0.0:8001" or ":8001")
HTTPPort int // HTTP port (binds to same IP as gRPC)
DebugPort int // Debug HTTP port
// Service identity and discovery
NodeID string // Stable node identifier (e.g., "file-1" or pod name in K8s)
AdvertiseAddr string // Address to advertise to peers (e.g., "file-1:8001" or "pod.svc:8001")
// Storage
IndexPath string
ECScheme types.ECScheme
DirectIO bool // Use O_DIRECT for writes (Linux only)
Backends []BackendOpts
// Reconciliation configuration
ReconciliationInterval time.Duration // How often to run reconciliation (0 = disabled)
ReconciliationGracePeriod time.Duration // Grace period before deleting orphan chunks
// TLS
CertFile string
KeyFile string
// Manager registration
ManagerAddr string // Manager service address for registration
}
FileServerOpts holds all configuration for the file server
type FlagLoader ¶
type FlagLoader struct {
// contains filtered or unexported fields
}
FlagLoader provides methods for loading configuration values with CLI flag precedence. When a CLI flag is explicitly set, it takes precedence over config file and env vars. Otherwise, viper's standard priority applies: env > config file > default.
func NewFlagLoader ¶
func NewFlagLoader(cmd *cobra.Command) *FlagLoader
NewFlagLoader creates a FlagLoader for the given cobra command.
func (*FlagLoader) Bool ¶
func (f *FlagLoader) Bool(flagName string) bool
Bool returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) Duration ¶
func (f *FlagLoader) Duration(flagName string) time.Duration
Duration returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) Int ¶
func (f *FlagLoader) Int(flagName string) int
Int returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) Int64 ¶
func (f *FlagLoader) Int64(flagName string) int64
Int64 returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) String ¶
func (f *FlagLoader) String(flagName string) string
String returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) StringSlice ¶
func (f *FlagLoader) StringSlice(flagName string) []string
StringSlice returns CLI flag value if explicitly set, otherwise viper value.
func (*FlagLoader) Uint32 ¶
func (f *FlagLoader) Uint32(flagName string) uint32
Uint32 returns CLI flag value if explicitly set, otherwise viper value.
type ManagerServerOpts ¶
type ManagerServerOpts struct {
IP string
GRPCPort int
DebugPort int
AdminPort int // Admin HTTP port for IAM management (default: grpc_port+10)
CertFile string
KeyFile string
LogLevel string
// Raft configuration
NodeID string
RaftDir string
RaftBindAddr string // Address for Raft peer communication (default: IP:grpc_port+1)
Bootstrap bool // Bootstrap a new cluster (only one node should do this)
BootstrapExpect int // Expected cluster size
JoinAddr string // gRPC address of leader to join (e.g., manager-1:8050)
LeaderTimeout time.Duration // Time to wait for leader election
RegionID string
// Placement defaults
DefaultNumReplicas uint32 // Default replication factor when not specified per-request
// Admin gRPC auth
AdminToken string // Shared secret for admin gRPC RPCs
// Federation (S3 passthrough/migration)
FederationEnabled bool
FederationExternalTimeout time.Duration
FederationExternalMaxIdleConns int
}
ManagerServerOpts holds configuration for the manager server.
Port Configuration ¶
The manager uses two ports:
- grpc_port (default 8050): For gRPC API (cluster membership, placement queries)
- raft_addr (default grpc_port+1): For Raft peer-to-peer consensus
Raft Networking ¶
Raft nodes communicate via raft_addr for consensus. When joining a cluster:
- --join flag takes the LEADER'S gRPC address (e.g., manager-1:8050)
- --raft_addr is THIS node's Raft peer address (e.g., manager-2:8051)
The join RPC tells the leader to add this node's raft_addr to the cluster.
type MetadataServerOpts ¶
type MetadataServerOpts struct {
IP string
HTTPPort int
GRPCPort int
DebugPort int
CertFile string
KeyFile string
LogLevel string
// Service identity for manager registration
NodeID string
AdvertiseAddr string
ManagerAddr string
S3Domains []string
WebsiteDomains []string // Domains for static website hosting
RegionID string
PoolsConfig string
ProfilesConfig string
DataDir string
DBDriver string
DBDSN string
DBMaxOpenConns int
DBMaxIdleConns int
DBTLSMode string
DBTLSCAFile string
// Rate limiting
RateLimitEnabled bool
RateLimitBurstMultipler int64
RateLimitRedisEnabled bool
RateLimitRedisAddr string
RateLimitRedisPassword string
RateLimitRedisDB int
RateLimitRedisPoolSize int
RateLimitRedisFailOpen bool
// Access logging (enterprise: FeatureAccessLog)
AccessLogsEnabled bool
ClickHouseDSN string
AccessLogBatchSize int
AccessLogFlushInterval time.Duration
AccessLogExportInterval time.Duration
// Lifecycle scanner (community feature)
LifecycleScannerEnabled bool
LifecycleScanInterval time.Duration
LifecycleScanConcurrency int
LifecycleScanBatchSize int
LifecycleMaxTasksPerScan int
// Cross-region replication (enterprise: FeatureMultiRegion)
ReplicationAccessKeyID string
ReplicationSecretAccessKey string
// Event notifications (enterprise: FeatureEvents)
EventsRedisAddr string
EventsRedisPassword string
EventsRedisDB int
EventsRedisChannel string
// Federation (S3 passthrough/migration)
FederationEnabled bool
FederationMode string // "api", "worker", or "both"
FederationSyncBatchSize int
FederationSyncConcurrency int
FederationSyncRateLimit int
FederationExternalTimeout time.Duration
FederationExternalMaxIdleConns int
// Feature flags for federated buckets
FederationLifecycleEnabled bool
FederationNotificationsEnabled bool
FederationAccessLoggingEnabled bool
FederationMetricsEnabled bool
}
type ReplicationCredentials ¶
ReplicationCredentials provides credentials for cross-region replication.
type TaskWorkerConfig ¶
type TaskWorkerConfig struct {
DB *sql.DB
WorkerID string
PollInterval time.Duration
Concurrency int
LocalRegion string
// Dependencies for replication handler (enterprise only)
ObjectService object.Service
RegionConfig *manager.RegionConfig
Credentials ReplicationCredentials
// Dependencies for event notification handler (enterprise only)
NotificationStore any // events.NotificationStore in enterprise
EventPublishers EventPublisherConfig // Publisher configuration
}
TaskWorkerConfig configures the task worker.
type TaskWorkerManager ¶
type TaskWorkerManager struct{}
TaskWorkerManager is a stub for community edition.
func InitializeTaskWorker ¶
func InitializeTaskWorker(ctx context.Context, cfg TaskWorkerConfig) (*TaskWorkerManager, error)
InitializeTaskWorker returns nil in community edition.
func (*TaskWorkerManager) Queue ¶
func (m *TaskWorkerManager) Queue() any
Queue returns nil in community edition.
func (*TaskWorkerManager) Stop ¶
func (m *TaskWorkerManager) Stop()
Stop is a no-op in community edition.