Skip to content

Commit

Permalink
Make path configurable via ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
dewey committed Aug 29, 2018
1 parent f2fd828 commit 210cdf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var config struct {
CacheExpiration int `env:"CACHE_EXPIRATION" envDefault:"30"`
CacheExpiredPurge int `env:"CACHE_EXPIRED_PURGE" envDefault:"60"`
StorageBackend string `env:"STORAGE_BACKEND" envDefault:"memory"`
StoragePath string `env:"STORAGE_PATH" envDefault:"feedbridge-data"`
Environment string `env:"ENVIRONMENT" envDefault:"develop"`
Port int `env:"PORT" envDefault:"8080"`
}
Expand Down Expand Up @@ -57,8 +58,8 @@ func main() {
return
}
storageRepo = memory
case "persistant":
disk, err := store.NewDiskRepository("feedbridge-cache")
case "persistent":
disk, err := store.NewDiskRepository(config.StoragePath)
if err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions store/disk_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/peterbourgon/diskv"
)

// DiskRepo holds a representation of a persistant store backend
// DiskRepo holds a representation of a persistent store backend
type DiskRepo struct {
d *diskv.Diskv
}

// NewDiskRepository returns a newly persistant store repository
// NewDiskRepository returns a newly persistent store repository
func NewDiskRepository(path string) (*DiskRepo, error) {
d := diskv.New(diskv.Options{
BasePath: path,
Expand Down

0 comments on commit 210cdf7

Please sign in to comment.