Documentation
¶
Index ¶
- Constants
- type ACLMetadata
- type DirSharesState
- type FileScanner
- type FileServer
- func (fs *FileServer) AddBytesRead(bytes uint64)
- func (fs *FileServer) AddBytesWritten(bytes uint64)
- func (fs *FileServer) ChangeDir(CurrentFID *domain.FID, path string, RootFID *domain.FID) (*domain.FID, error)
- func (fs *FileServer) CollectMetrics() Metrics
- func (fs *FileServer) CreateFile(parentFID *domain.FID, name, root_user string, fileType domain.InodeType) (*domain.FID, error)
- func (fs *FileServer) DeleteFile(fid *domain.FID, root_user string, recursive bool) error
- func (fs *FileServer) GetChildInodeByName(parentInode *domain.Inode, name string) (*domain.Inode, error)
- func (fs *FileServer) GetFileHash(parentFID *domain.FID, name string) (string, error)
- func (fs *FileServer) GetInode(fid *domain.FID) (*domain.Inode, error)
- func (fs *FileServer) GetUserQuota(username string) uint64
- func (fs *FileServer) GetUserRoot(root_path, root_user string) (*domain.FID, error)
- func (fs *FileServer) HeartbeatWithMetaServer(selfAddr string) error
- func (fs *FileServer) ListDirectory(dirFID *domain.FID) ([]*domain.Inode, error)
- func (fs *FileServer) LoadACL(username, path string) (domain.ACL, error)
- func (fs *FileServer) LoadDirShares() error
- func (fs *FileServer) NotifyFileDeletedInDir(parentFID *domain.FID, name, originUsername string)
- func (fs *FileServer) NotifyFileUpdated(parentFID *domain.FID, name, originUsername string)
- func (fs *FileServer) NotifyNewFileInDir(parentFID *domain.FID, name, originUsername string)
- func (fs *FileServer) OpMetricsSnapshot() OpMetricsSnapshot
- func (fs *FileServer) Path(dirFID *domain.FID) (string, error)
- func (fs *FileServer) ReadFile(parentFID *domain.FID, name string, offset, length uint64) ([]byte, error)
- func (fs *FileServer) RecordRead(bytes uint64, durationMs float64, err error)
- func (fs *FileServer) RecordReadOp(durationMs float64, err error)
- func (fs *FileServer) RecordWrite(bytes uint64, durationMs float64, err error)
- func (fs *FileServer) RecordWriteOp(durationMs float64, err error)
- func (fs *FileServer) RegisterWithMetaServer(selfAddr string) error
- func (fs *FileServer) RemoveClientSession(username string)
- func (fs *FileServer) RestoreFile(fid *domain.FID, root_user, requester string) (string, error)
- func (fs *FileServer) RootShare(owner, name, path, share_with string) error
- func (fs *FileServer) RootUnshare(owner, name, path, unshare_with string) error
- func (fs *FileServer) SaveACL(path string, acl domain.ACL) error
- func (fs *FileServer) SaveDirShares() error
- func (fs *FileServer) SetUserQuota(username string, quotaBytes uint64) error
- func (fs *FileServer) Share(username string, share_with string, dirFID *domain.FID) error
- func (fs *FileServer) ShowTrash(root_user, requester string) ([]*domain.Inode, error)
- func (fs *FileServer) StartMetaServerSync(msAddr, selfAddr string, retryInterval, heartbeatInterval time.Duration) func()
- func (fs *FileServer) StartMetricsHTTP(port int)
- func (fs *FileServer) TouchClientActivity(username string)
- func (fs *FileServer) TouchClientActivityByRootFID(rootFID *domain.FID)
- func (fs *FileServer) TrashFile(fid *domain.FID, root_user string, recursive bool) (string, error)
- func (fs *FileServer) Unshare(username string, unshare_with string, dirFID *domain.FID) error
- func (fs *FileServer) UpdateClientCurrentDirByRootFID(rootFID, currentDirFID *domain.FID)
- func (fs *FileServer) UpsertClientSession(username, callbackAddress string, rootFID *domain.FID)
- func (fs *FileServer) WriteFile(parentFID *domain.FID, name string, offset uint64, data []byte) error
- type GRPCHandler
- func (h *GRPCHandler) ChangeDir(ctx context.Context, req *pb.ChangeDirRequest) (*pb.ChangeDirResponse, error)
- func (h *GRPCHandler) CreateFile(ctx context.Context, req *pb.CreateFileRequest) (*pb.CreateFileResponse, error)
- func (h *GRPCHandler) DeleteFile(ctx context.Context, req *pb.DeleteFileRequest) (*pb.DeleteFileResponse, error)
- func (h *GRPCHandler) DownloadFile(req *pb.DownloadFileRequest, stream pb.FileServer_DownloadFileServer) error
- func (h *GRPCHandler) GetAttr(ctx context.Context, req *pb.GetAttrRequest) (*pb.GetAttrResponse, error)
- func (h *GRPCHandler) ListDir(ctx context.Context, req *pb.ListDirRequest) (*pb.ListDirResponse, error)
- func (h *GRPCHandler) Path(ctx context.Context, req *pb.PathRequest) (*pb.PathResponse, error)
- func (h *GRPCHandler) ReadFile(ctx context.Context, req *pb.ReadFileRequest) (*pb.ReadFileResponse, error)
- func (h *GRPCHandler) RegisterClient(ctx context.Context, req *pb.RegisterClientRequest) (*pb.RegisterClientResponse, error)
- func (h *GRPCHandler) RestoreFile(ctx context.Context, req *pb.RestoreFileRequest) (*pb.RestoreFileResponse, error)
- func (h *GRPCHandler) SetQuota(ctx context.Context, req *pb.SetQuotaRequest) (*pb.SetQuotaResponse, error)
- func (h *GRPCHandler) Share(ctx context.Context, req *pb.ShareRequest) (*pb.ShareResponse, error)
- func (h *GRPCHandler) ShowTrash(ctx context.Context, req *pb.ShowTrashRequest) (*pb.ShowTrashResponse, error)
- func (h *GRPCHandler) TrashFile(ctx context.Context, req *pb.TrashFileRequest) (*pb.TrashFileResponse, error)
- func (h *GRPCHandler) UnregisterClient(ctx context.Context, req *pb.UnregisterClientRequest) (*pb.UnregisterClientResponse, error)
- func (h *GRPCHandler) Unshare(ctx context.Context, req *pb.UnshareRequest) (*pb.UnshareResponse, error)
- func (h *GRPCHandler) UploadFile(stream pb.FileServer_UploadFileServer) error
- func (h *GRPCHandler) WriteFile(ctx context.Context, req *pb.WriteFileRequest) (*pb.WriteFileResponse, error)
- type InodeIndexData
- type InodeStore
- type LatencyReservoir
- type Metrics
- type OpMetricsSnapshot
- type OperationMetrics
- func (om *OperationMetrics) AddBytesRead(bytes uint64)
- func (om *OperationMetrics) AddBytesWritten(bytes uint64)
- func (om *OperationMetrics) RecordRead(bytes uint64, durationMs float64, err error)
- func (om *OperationMetrics) RecordReadOp(durationMs float64, err error)
- func (om *OperationMetrics) RecordWrite(bytes uint64, durationMs float64, err error)
- func (om *OperationMetrics) RecordWriteOp(durationMs float64, err error)
- func (om *OperationMetrics) Snapshot() OpMetricsSnapshot
Constants ¶
const DiskSafetyBuffer uint64 = 20 * 1024 * 1024 * 1024 // 20 GiB safety buffer
DiskSafetyBuffer is the reserved disk space for host OS and system health (20 GiB). The fileserver max usable space is capped at (disk space - DiskSafetyBuffer).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACLMetadata ¶
type ACLMetadata struct {
Owner string `json:"owner"`
}
ACLMetadata represents the persisted ACL information
type DirSharesState ¶
type DirSharesState struct {
}
DirSharesState represents the persisted directory shares information
type FileScanner ¶
type FileScanner struct {
// contains filtered or unexported fields
}
type FileServer ¶
type FileServer struct {
// contains filtered or unexported fields
}
FileServer provides basic file operations
func NewFileServer ¶
func NewFileServer(serverID, rootDir string, msAddr string) (*FileServer, error)
NewFileServer creates a new file server object, either blank or loading from existing data
func (*FileServer) AddBytesRead ¶
func (fs *FileServer) AddBytesRead(bytes uint64)
AddBytesRead increments the running total of bytes read in real time.
func (*FileServer) AddBytesWritten ¶
func (fs *FileServer) AddBytesWritten(bytes uint64)
AddBytesWritten increments the running total of bytes written in real time.
func (*FileServer) CollectMetrics ¶
func (fs *FileServer) CollectMetrics() Metrics
CollectMetrics gathers a full metrics snapshot from the fileserver.
func (*FileServer) CreateFile ¶
func (fs *FileServer) CreateFile(parentFID *domain.FID, name, root_user string, fileType domain.InodeType) (*domain.FID, error)
CreateFile creates a new file or directory
func (*FileServer) DeleteFile ¶
DeleteFile deletes a file or directory with comprehensive error handling Parameters:
- fid: File identifier to delete
- root_user: User attempting the deletion (for permission checking)
- recursive: If true, allows deletion of non-empty directories
Implementation notes: - Uses two-phase approach: validate first, then delete - Deletes from OS filesystem first, then updates in-memory structures - For directories, uses post-order DFS traversal (children before parents) - Maintains atomicity: if OS deletion fails, memory state unchanged
func (*FileServer) GetChildInodeByName ¶
func (fs *FileServer) GetChildInodeByName(parentInode *domain.Inode, name string) (*domain.Inode, error)
find the inode in parent's children (should be existing)
func (*FileServer) GetFileHash ¶
GetFileHash computes and returns the hash of a file's contents.
func (*FileServer) GetInode ¶
GetInode retrieves an inode by FID from the file server (assumes lock is held)
func (*FileServer) GetUserQuota ¶
func (fs *FileServer) GetUserQuota(username string) uint64
GetUserQuota returns the configured quota for a user in bytes. If no custom quota is configured, it returns the default quota (1 GB).
func (*FileServer) GetUserRoot ¶
func (fs *FileServer) GetUserRoot(root_path, root_user string) (*domain.FID, error)
GetUserRoot returns the root FID for a user, creating it if necessary
func (*FileServer) HeartbeatWithMetaServer ¶
func (fs *FileServer) HeartbeatWithMetaServer(selfAddr string) error
HeartbeatWithMetaServer sends a lightweight liveness signal to metaserver.
func (*FileServer) ListDirectory ¶
ListDirectory lists contents of a directory
func (*FileServer) LoadACL ¶
func (fs *FileServer) LoadACL(username, path string) (domain.ACL, error)
LoadACL loads the ACL from disk for a user's root directory Returns default ACL (owner only, no shared users) if file doesn't exist
func (*FileServer) LoadDirShares ¶
func (fs *FileServer) LoadDirShares() error
LoadDirShares loads the explicit directory shares from disk Returns empty map if file doesn't exist (not an error)
func (*FileServer) NotifyFileDeletedInDir ¶
func (fs *FileServer) NotifyFileDeletedInDir(parentFID *domain.FID, name, originUsername string)
NotifyFileDeletedInDir notifies active users in the same directory that a file was deleted.
func (*FileServer) NotifyFileUpdated ¶
func (fs *FileServer) NotifyFileUpdated(parentFID *domain.FID, name, originUsername string)
NotifyFileUpdated notifies active users in the same current directory about file changes.
func (*FileServer) NotifyNewFileInDir ¶
func (fs *FileServer) NotifyNewFileInDir(parentFID *domain.FID, name, originUsername string)
NotifyNewFileInDir notifies active users in the same directory that a new file was uploaded.
func (*FileServer) OpMetricsSnapshot ¶
func (fs *FileServer) OpMetricsSnapshot() OpMetricsSnapshot
OpMetricsSnapshot returns a point-in-time snapshot of operation metrics.
func (*FileServer) Path ¶
func (fs *FileServer) Path(dirFID *domain.FID) (string, error)
Return path as pwd
func (*FileServer) ReadFile ¶
func (fs *FileServer) ReadFile(parentFID *domain.FID, name string, offset, length uint64) ([]byte, error)
ReadFile reads data from a file
func (*FileServer) RecordRead ¶
func (fs *FileServer) RecordRead(bytes uint64, durationMs float64, err error)
RecordRead records read bytes, duration in ms, and error status into operation metrics.
func (*FileServer) RecordReadOp ¶
func (fs *FileServer) RecordReadOp(durationMs float64, err error)
RecordReadOp records completion of a read operation into operation metrics.
func (*FileServer) RecordWrite ¶
func (fs *FileServer) RecordWrite(bytes uint64, durationMs float64, err error)
RecordWrite records write bytes, duration in ms, and error status into operation metrics.
func (*FileServer) RecordWriteOp ¶
func (fs *FileServer) RecordWriteOp(durationMs float64, err error)
RecordWriteOp records completion of a write operation into operation metrics.
func (*FileServer) RegisterWithMetaServer ¶
func (fs *FileServer) RegisterWithMetaServer(selfAddr string) error
RegisterWithMetaServer dials the meta server and registers this file server along with all users it currently knows about. selfAddr is the host:port that the meta server should store as this FS's address. If msAddr is empty this is a no-op.
func (*FileServer) RemoveClientSession ¶
func (fs *FileServer) RemoveClientSession(username string)
RemoveClientSession removes a client session when the client explicitly disconnects.
func (*FileServer) RestoreFile ¶
RestoreFile moves an inode out of trash back to its original parent (best-effort).
func (*FileServer) RootShare ¶
func (fs *FileServer) RootShare(owner, name, path, share_with string) error
func (*FileServer) RootUnshare ¶
func (fs *FileServer) RootUnshare(owner, name, path, unshare_with string) error
func (*FileServer) SaveACL ¶
func (fs *FileServer) SaveACL(path string, acl domain.ACL) error
SaveACL persists the ACL to disk in the user's root directory Uses atomic write (write to temp file, then rename) to prevent corruption
func (*FileServer) SaveDirShares ¶
func (fs *FileServer) SaveDirShares() error
SaveDirShares persists the explicit directory shares to disk Uses atomic write (write to temp file, then rename) to prevent corruption
func (*FileServer) SetUserQuota ¶
func (fs *FileServer) SetUserQuota(username string, quotaBytes uint64) error
SetUserQuota updates the quota for a user and persists it to quota_config.json.
func (*FileServer) Share ¶
Share another user the root dir only if current user is owner This method now recursively updates ACLs for all inodes in the subtree
func (*FileServer) ShowTrash ¶
func (fs *FileServer) ShowTrash(root_user, requester string) ([]*domain.Inode, error)
ShowTrash returns all entries from the caller's trash directory.
func (*FileServer) StartMetaServerSync ¶
func (fs *FileServer) StartMetaServerSync(msAddr, selfAddr string, retryInterval, heartbeatInterval time.Duration) func()
StartMetaServerSync keeps trying registration in the background so this file server can automatically re-attach when the metaserver restarts.
func (*FileServer) StartMetricsHTTP ¶
func (fs *FileServer) StartMetricsHTTP(port int)
StartMetricsHTTP starts a lightweight HTTP server on the given port that exposes /metrics (JSON) and /health endpoints.
func (*FileServer) TouchClientActivity ¶
func (fs *FileServer) TouchClientActivity(username string)
TouchClientActivity updates the last-seen timestamp for a user.
func (*FileServer) TouchClientActivityByRootFID ¶
func (fs *FileServer) TouchClientActivityByRootFID(rootFID *domain.FID)
TouchClientActivityByRootFID updates activity for sessions mapped to this root.
func (*FileServer) TrashFile ¶
TrashFile moves a file or directory into the user's trash directory (soft delete). NOTE: This stores restore metadata in-memory only.
func (*FileServer) Unshare ¶
Unshare removes a user from the shared list of the root dir This method now recursively updates ACLs for all inodes in the subtree
func (*FileServer) UpdateClientCurrentDirByRootFID ¶
func (fs *FileServer) UpdateClientCurrentDirByRootFID(rootFID, currentDirFID *domain.FID)
UpdateClientCurrentDirByRootFID updates current directory for sessions on this root.
func (*FileServer) UpsertClientSession ¶
func (fs *FileServer) UpsertClientSession(username, callbackAddress string, rootFID *domain.FID)
UpsertClientSession records callback address and activity metadata for a user.
type GRPCHandler ¶
type GRPCHandler struct {
pb.UnimplementedFileServerServer
// contains filtered or unexported fields
}
GRPCHandler implements the gRPC file server interface
func NewGRPCHandler ¶
func NewGRPCHandler(fileServer *FileServer) *GRPCHandler
NewGRPCHandler creates a new gRPC handler
func (*GRPCHandler) ChangeDir ¶
func (h *GRPCHandler) ChangeDir(ctx context.Context, req *pb.ChangeDirRequest) (*pb.ChangeDirResponse, error)
Changes the current directory
func (*GRPCHandler) CreateFile ¶
func (h *GRPCHandler) CreateFile(ctx context.Context, req *pb.CreateFileRequest) (*pb.CreateFileResponse, error)
CreateFile creates a new file or directory
func (*GRPCHandler) DeleteFile ¶
func (h *GRPCHandler) DeleteFile(ctx context.Context, req *pb.DeleteFileRequest) (*pb.DeleteFileResponse, error)
DeleteFile deletes a file or directory
func (*GRPCHandler) DownloadFile ¶
func (h *GRPCHandler) DownloadFile(req *pb.DownloadFileRequest, stream pb.FileServer_DownloadFileServer) error
DownloadFile downloads the file by it's name in cwd
func (*GRPCHandler) GetAttr ¶
func (h *GRPCHandler) GetAttr(ctx context.Context, req *pb.GetAttrRequest) (*pb.GetAttrResponse, error)
GetAttr gets file attributes
func (*GRPCHandler) ListDir ¶
func (h *GRPCHandler) ListDir(ctx context.Context, req *pb.ListDirRequest) (*pb.ListDirResponse, error)
ListDir lists directory contents
func (*GRPCHandler) Path ¶
func (h *GRPCHandler) Path(ctx context.Context, req *pb.PathRequest) (*pb.PathResponse, error)
Returns current path
func (*GRPCHandler) ReadFile ¶
func (h *GRPCHandler) ReadFile(ctx context.Context, req *pb.ReadFileRequest) (*pb.ReadFileResponse, error)
ReadFile reads data from a file
func (*GRPCHandler) RegisterClient ¶
func (h *GRPCHandler) RegisterClient(ctx context.Context, req *pb.RegisterClientRequest) (*pb.RegisterClientResponse, error)
RegisterClient handles client registration and returns user root FID
func (*GRPCHandler) RestoreFile ¶
func (h *GRPCHandler) RestoreFile(ctx context.Context, req *pb.RestoreFileRequest) (*pb.RestoreFileResponse, error)
RestoreFile restores a file or directory from trash back to its original location
func (*GRPCHandler) SetQuota ¶
func (h *GRPCHandler) SetQuota(ctx context.Context, req *pb.SetQuotaRequest) (*pb.SetQuotaResponse, error)
SetQuota updates the storage quota for a user in bytes.
func (*GRPCHandler) Share ¶
func (h *GRPCHandler) Share(ctx context.Context, req *pb.ShareRequest) (*pb.ShareResponse, error)
Share another user the root dir only if current user is owner
func (*GRPCHandler) ShowTrash ¶
func (h *GRPCHandler) ShowTrash(ctx context.Context, req *pb.ShowTrashRequest) (*pb.ShowTrashResponse, error)
ShowTrash lists the current user's trash directory contents.
func (*GRPCHandler) TrashFile ¶
func (h *GRPCHandler) TrashFile(ctx context.Context, req *pb.TrashFileRequest) (*pb.TrashFileResponse, error)
TrashFile moves a file or directory into the user's trash (soft delete)
func (*GRPCHandler) UnregisterClient ¶
func (h *GRPCHandler) UnregisterClient(ctx context.Context, req *pb.UnregisterClientRequest) (*pb.UnregisterClientResponse, error)
UnregisterClient handles client disconnect and removes their active session
func (*GRPCHandler) Unshare ¶
func (h *GRPCHandler) Unshare(ctx context.Context, req *pb.UnshareRequest) (*pb.UnshareResponse, error)
Unshare another user the root dir only if current user is owner
func (*GRPCHandler) UploadFile ¶
func (h *GRPCHandler) UploadFile(stream pb.FileServer_UploadFileServer) error
UploadFile uploads the file chunk by chunk
func (*GRPCHandler) WriteFile ¶
func (h *GRPCHandler) WriteFile(ctx context.Context, req *pb.WriteFileRequest) (*pb.WriteFileResponse, error)
WriteFile writes data to a file
type InodeIndexData ¶
type InodeIndexData struct {
NextInodeID uint64 `json:"next_inode_id"`
PathToID map[string]uint64 `json:"path_to_id"`
}
InodeIndexData represents the on-disk format of the persistent inode mapping.
type InodeStore ¶
type InodeStore struct {
// contains filtered or unexported fields
}
InodeStore provides thread-safe persistent mapping between filesystem relative paths and deterministic Inode IDs.
func NewInodeStore ¶
func NewInodeStore(rootDir string) (*InodeStore, error)
NewInodeStore creates or loads an InodeStore for rootDir.
func (*InodeStore) Get ¶
func (s *InodeStore) Get(relPath string) (uint64, bool)
Get retrieves an existing InodeID without allocating a new one.
func (*InodeStore) GetOrAssign ¶
func (s *InodeStore) GetOrAssign(relPath string) uint64
GetOrAssign retrieves an existing InodeID for the relative path, or allocates and returns a new InodeID.
func (*InodeStore) NextInodeID ¶
func (s *InodeStore) NextInodeID() uint64
NextInodeID returns the current nextInodeID value.
func (*InodeStore) Remove ¶
func (s *InodeStore) Remove(relPath string)
Remove removes the relative path from the inode store (used upon permanent deletion). It does not decrement NextInodeID, ensuring old IDs are never recycled.
func (*InodeStore) RenamePrefix ¶
func (s *InodeStore) RenamePrefix(oldPrefix, newPrefix string)
RenamePrefix renames all path keys matching oldPrefix to newPrefix. Used when moving or restoring subtrees (e.g. into or out of .trash).
func (*InodeStore) Save ¶
func (s *InodeStore) Save() error
Save writes the current inode index to disk atomically.
type LatencyReservoir ¶
type LatencyReservoir struct {
// contains filtered or unexported fields
}
LatencyReservoir maintains a circular sliding window of recent operation durations (in milliseconds).
func NewLatencyReservoir ¶
func NewLatencyReservoir(size int) *LatencyReservoir
NewLatencyReservoir creates a new sliding-window latency reservoir of the given sample size.
func (*LatencyReservoir) Add ¶
func (r *LatencyReservoir) Add(durationMs float64)
Add appends a new duration sample in milliseconds to the reservoir.
func (*LatencyReservoir) Percentiles ¶
func (r *LatencyReservoir) Percentiles() (p50, p95, p99 float64)
Percentiles calculates p50, p95, and p99 from the current reservoir samples.
type Metrics ¶
type Metrics struct {
DiskTotalBytes uint64 `json:"disk_total_bytes"`
DiskUsedBytes uint64 `json:"disk_used_bytes"`
DiskFreeBytes uint64 `json:"disk_free_bytes"`
DiskUsagePercent float64 `json:"disk_usage_percent"`
PerUserStorage map[string]uint64 `json:"per_user_storage"`
PerUserQuota map[string]uint64 `json:"per_user_quota"`
ChunkCount int `json:"chunk_count"`
CPUTempCelsius float64 `json:"cpu_temp_celsius"`
CPUUsagePercent float64 `json:"cpu_usage_percent"`
MemUsedBytes uint64 `json:"mem_used_bytes"`
MemTotalBytes uint64 `json:"mem_total_bytes"`
MemUsagePercent float64 `json:"mem_usage_percent"`
LoadAvg1m float64 `json:"load_avg_1m"`
LoadAvg5m float64 `json:"load_avg_5m"`
UptimeSeconds float64 `json:"uptime_seconds"`
LastRestartUnix int64 `json:"last_restart_unix"`
ActiveConnections int `json:"active_connections"`
ActiveUsers []string `json:"active_users"`
UsersAssigned int `json:"users_assigned_count"`
BytesWrittenTotal uint64 `json:"bytes_written_total"`
BytesReadTotal uint64 `json:"bytes_read_total"`
WriteOpsTotal uint64 `json:"write_ops_total"`
ReadOpsTotal uint64 `json:"read_ops_total"`
ErrorsTotal uint64 `json:"errors_total"`
FailedWritesTotal uint64 `json:"failed_writes_total"`
FailedReadsTotal uint64 `json:"failed_reads_total"`
OpLatencyWriteMsP50 float64 `json:"op_latency_write_ms_p50"`
OpLatencyWriteMsP95 float64 `json:"op_latency_write_ms_p95"`
OpLatencyWriteMsP99 float64 `json:"op_latency_write_ms_p99"`
OpLatencyReadMsP50 float64 `json:"op_latency_read_ms_p50"`
OpLatencyReadMsP95 float64 `json:"op_latency_read_ms_p95"`
OpLatencyReadMsP99 float64 `json:"op_latency_read_ms_p99"`
}
Metrics holds a point-in-time snapshot of fileserver health and resource usage.
type OpMetricsSnapshot ¶
type OpMetricsSnapshot struct {
BytesWrittenTotal uint64
BytesReadTotal uint64
WriteOpsTotal uint64
ReadOpsTotal uint64
ErrorsTotal uint64
FailedWritesTotal uint64
FailedReadsTotal uint64
OpLatencyWriteMsP50 float64
OpLatencyWriteMsP95 float64
OpLatencyWriteMsP99 float64
OpLatencyReadMsP50 float64
OpLatencyReadMsP95 float64
OpLatencyReadMsP99 float64
}
OpMetricsSnapshot represents a point-in-time snapshot of operation metrics and computed latency percentiles.
type OperationMetrics ¶
type OperationMetrics struct {
// contains filtered or unexported fields
}
OperationMetrics holds thread-safe telemetry for I/O operations, error counts, and latencies.
func NewOperationMetrics ¶
func NewOperationMetrics() *OperationMetrics
NewOperationMetrics constructs an initialized OperationMetrics tracker.
func (*OperationMetrics) AddBytesRead ¶
func (om *OperationMetrics) AddBytesRead(bytes uint64)
AddBytesRead increments the running total of bytes read in real time as chunks are streamed.
func (*OperationMetrics) AddBytesWritten ¶
func (om *OperationMetrics) AddBytesWritten(bytes uint64)
AddBytesWritten increments the running total of bytes written in real time as chunks arrive.
func (*OperationMetrics) RecordRead ¶
func (om *OperationMetrics) RecordRead(bytes uint64, durationMs float64, err error)
RecordRead records a read operation with its bytes transferred, duration, and error status.
func (*OperationMetrics) RecordReadOp ¶
func (om *OperationMetrics) RecordReadOp(durationMs float64, err error)
RecordReadOp records completion of a read operation, updating op count, error status, and latency.
func (*OperationMetrics) RecordWrite ¶
func (om *OperationMetrics) RecordWrite(bytes uint64, durationMs float64, err error)
RecordWrite records a write operation with its bytes transferred, duration, and error status.
func (*OperationMetrics) RecordWriteOp ¶
func (om *OperationMetrics) RecordWriteOp(durationMs float64, err error)
RecordWriteOp records completion of a write operation, updating op count, error status, and latency.
func (*OperationMetrics) Snapshot ¶
func (om *OperationMetrics) Snapshot() OpMetricsSnapshot
Snapshot captures atomic counters and computes latency percentiles.