package steamcache import "github.com/docker/go-units" type StorageType string type Config struct { Address string `yaml:"address"` // Address to listen on Storage []StorageConfig `yaml:"storage"` // Storage configuration // Ordered by speed so memory is first, then ssd, then hdd, etc } func NewConfig() *Config { return &Config{ Address: ":8080", Storage: []StorageConfig{ { Name: "memory", MaxSizeStr: "1GB", }, { Name: "filesystem", Path: "/example/path", MaxSizeStr: "1TB", }, }, } } type StorageConfig struct { Name string `yaml:"name"` // Name of the storage Path string `yaml:"path,omitempty"` // Path to the storage (if applicable) - empty for memory MaxSizeStr string `yaml:"max_size"` // Maximum size of the storage in human readable format (e.g. 1GB) } func (sc *StorageConfig) IsMemory() bool { return sc.Path == "" } func (sc *StorageConfig) IsFilesystem() bool { return sc.Path != "" } func (sc *StorageConfig) MaxSize() int64 { x, err := units.FromHumanSize(sc.MaxSizeStr) if err != nil { return -1 // Unlimited } return x // Bytes }