Refactor VFS implementation to use Create and Open methods
Some checks failed
PR Check / check-and-test (pull_request) Failing after 11m4s

- Updated disk_test.go to replace Set and Get with Create and Open methods for better clarity and functionality.
- Modified fileinfo.go to include package comment.
- Refactored gc.go to streamline garbage collection handling and removed unused statistics.
- Updated gc_test.go to comment out large random tests for future implementation.
- Enhanced memory.go to implement LRU caching and metrics for memory usage.
- Updated memory_test.go to replace Set and Get with Create and Open methods.
- Removed sync.go as it was redundant and not utilized.
- Updated vfs.go to reflect changes in the VFS interface, replacing Set and Get with Create and Open.
- Added package comments to vfserror.go for consistency.
This commit is contained in:
2025-07-13 03:17:22 -05:00
parent b83836f914
commit 1673e9554a
24 changed files with 945 additions and 631 deletions

View File

@@ -1,7 +1,9 @@
// cmd/root.go
package cmd
import (
"os"
"runtime"
"s1d3sw1ped/SteamCache2/steamcache"
"s1d3sw1ped/SteamCache2/steamcache/logger"
"s1d3sw1ped/SteamCache2/version"
@@ -11,6 +13,8 @@ import (
)
var (
threads int
memory string
memorymultiplier int
disk string
@@ -18,7 +22,6 @@ var (
diskpath string
upstream string
pprof bool
logLevel string
logFormat string
)
@@ -52,21 +55,29 @@ var rootCmd = &cobra.Command{
logger.Logger = zerolog.New(writer).With().Timestamp().Logger()
logger.Logger.Info().
Msg("starting SteamCache2 " + version.Version)
Msg("SteamCache2 " + version.Version + " starting...")
address := ":80"
if runtime.GOMAXPROCS(-1) != threads {
runtime.GOMAXPROCS(threads)
logger.Logger.Info().
Int("threads", threads).
Msg("Maximum number of threads set")
}
sc := steamcache.New(
":80",
address,
memory,
memorymultiplier,
disk,
diskmultiplier,
diskpath,
upstream,
pprof,
)
logger.Logger.Info().
Msg("SteamCache2 listening on port 80")
Msg("SteamCache2 " + version.Version + " started on " + address)
sc.Run()
@@ -85,6 +96,8 @@ func Execute() {
}
func init() {
rootCmd.Flags().IntVarP(&threads, "threads", "t", runtime.GOMAXPROCS(-1), "Number of worker threads to use for processing requests")
rootCmd.Flags().StringVarP(&memory, "memory", "m", "0", "The size of the memory cache")
rootCmd.Flags().IntVarP(&memorymultiplier, "memory-gc", "M", 10, "The gc value for the memory cache")
rootCmd.Flags().StringVarP(&disk, "disk", "d", "0", "The size of the disk cache")
@@ -93,9 +106,6 @@ func init() {
rootCmd.Flags().StringVarP(&upstream, "upstream", "u", "", "The upstream server to proxy requests overrides the host header from the client but forwards the original host header to the upstream server")
rootCmd.Flags().BoolVarP(&pprof, "pprof", "P", false, "Enable pprof")
rootCmd.Flags().MarkHidden("pprof")
rootCmd.Flags().StringVarP(&logLevel, "log-level", "l", "info", "Logging level: debug, info, error")
rootCmd.Flags().StringVarP(&logFormat, "log-format", "f", "console", "Logging format: json, console")
}

View File

@@ -1,3 +1,4 @@
// cmd/version.go
package cmd
import (