Files
EdgeNode/internal/utils/bfs/fs_options.go
2024-04-27 17:29:12 +08:00

35 lines
779 B
Go

// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package bfs
import "time"
type FSOptions struct {
MaxOpenFiles int
BytesPerSync int64
SyncTimeout time.Duration
MaxSyncFiles int
}
func (this *FSOptions) EnsureDefaults() {
if this.MaxOpenFiles <= 0 {
this.MaxOpenFiles = 4 << 10
}
if this.BytesPerSync <= 0 {
this.BytesPerSync = 1 << 20 // TODO 根据硬盘实际写入速度进行调整
}
if this.SyncTimeout <= 0 {
this.SyncTimeout = 1 * time.Second
}
if this.MaxSyncFiles <= 0 {
this.MaxSyncFiles = 32
}
}
var DefaultFSOptions = &FSOptions{
MaxOpenFiles: 4 << 10,
BytesPerSync: 1 << 20, // TODO 根据硬盘实际写入速度进行调整
SyncTimeout: 1 * time.Second,
MaxSyncFiles: 32,
}