From 3cbe068fc19e7ae72f7ae8c546f0a1b03710ecec Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 7 Aug 2021 12:11:35 -0400 Subject: [PATCH] Rename storage type inmemory to memory This is technically a breaking change, but given how long ago this field was implemented as well as the fact that this is the default value if the type is not specified, I doubt anybody's explicitly setting it as inmemory --- README.md | 6 +++--- config/config.go | 2 +- storage/storage.go | 2 +- storage/storage_test.go | 8 ++++---- storage/type.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d65901c9..11c06748 100644 --- a/README.md +++ b/README.md @@ -229,10 +229,10 @@ Here are some examples of conditions you can use: | Parameter | Description | Default | |:------------------ |:-------------------------------------------------------------------------------------- |:-------------- | | `storage` | Storage configuration | `{}` | -| `storage.file` | File to persist the data in. If the type is `inmemory`, data is persisted on interval. | `""` | -| `storage.type` | Type of storage. Valid types: `inmemory`, `sqlite`. | `"inmemory"` | +| `storage.file` | File to persist the data in. If the type is `memory`, data is persisted on interval. | `""` | +| `storage.type` | Type of storage. Valid types: `memory`, `sqlite`. | `"memory"` | -- If `storage.type` is `inmemory` (default) and `storage.file` is set to a non-blank value. +- If `storage.type` is `memory` (default) and `storage.file` is set to a non-blank value. Furthermore, the data is periodically persisted, but everything remains in memory. - If `storage.type` is `sqlite`, `storage.file` must not be blank. ```yaml diff --git a/config/config.go b/config/config.go index f8370675..13eb5162 100644 --- a/config/config.go +++ b/config/config.go @@ -177,7 +177,7 @@ func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) { func validateStorageConfig(config *Config) error { if config.Storage == nil { config.Storage = &storage.Config{ - Type: storage.TypeInMemory, + Type: storage.TypeMemory, } } err := storage.Initialize(config.Storage) diff --git a/storage/storage.go b/storage/storage.go index 72356126..549cdbb3 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -57,7 +57,7 @@ func Initialize(cfg *Config) error { if err != nil { return err } - case TypeInMemory: + case TypeMemory: fallthrough default: if len(cfg.File) > 0 { diff --git a/storage/storage_test.go b/storage/storage_test.go index b60d7cfe..e2cc7d94 100644 --- a/storage/storage_test.go +++ b/storage/storage_test.go @@ -32,13 +32,13 @@ func TestInitialize(t *testing.T) { ExpectedErr: nil, }, { - Name: "inmemory-no-file", - Cfg: &Config{Type: TypeInMemory}, + Name: "memory-no-file", + Cfg: &Config{Type: TypeMemory}, ExpectedErr: nil, }, { - Name: "inmemory-with-file", - Cfg: &Config{Type: TypeInMemory, File: t.TempDir() + "/TestInitialize_inmemory-with-file.db"}, + Name: "memory-with-file", + Cfg: &Config{Type: TypeMemory, File: t.TempDir() + "/TestInitialize_memory-with-file.db"}, ExpectedErr: nil, }, { diff --git a/storage/type.go b/storage/type.go index 342bad9f..87c6f5f1 100644 --- a/storage/type.go +++ b/storage/type.go @@ -4,6 +4,6 @@ package storage type Type string const ( - TypeInMemory Type = "inmemory" // In-memory store - TypeSQLite Type = "sqlite" // SQLite store + TypeMemory Type = "memory" // In-memory store + TypeSQLite Type = "sqlite" // SQLite store )