From 7d1821eaec2bd6d0793ce01ae4cb48c5fb7cfb53 Mon Sep 17 00:00:00 2001 From: kardolus Date: Wed, 6 Nov 2024 13:41:00 +0100 Subject: [PATCH] chore: unify Store interface across modules --- api/client/client.go | 4 ++-- config/manager.go | 4 ++-- config/store.go | 4 ++-- history/manager.go | 4 ++-- history/store.go | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/client/client.go b/api/client/client.go index ee79a2a..7a0284c 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -40,11 +40,11 @@ type Client struct { Config config.Config History []history.History caller http.Caller - historyStore history.HistoryStore + historyStore history.Store timer Timer } -func New(callerFactory http.CallerFactory, hs history.HistoryStore, t Timer, cfg config.Config, interactiveMode bool) *Client { +func New(callerFactory http.CallerFactory, hs history.Store, t Timer, cfg config.Config, interactiveMode bool) *Client { caller := callerFactory(cfg) if interactiveMode && cfg.AutoCreateNewThread { diff --git a/config/manager.go b/config/manager.go index bbc83ee..cd3ee91 100644 --- a/config/manager.go +++ b/config/manager.go @@ -10,11 +10,11 @@ import ( ) type Manager struct { - configStore ConfigStore + configStore Store Config Config } -func NewManager(cs ConfigStore) *Manager { +func NewManager(cs Store) *Manager { configuration := cs.ReadDefaults() userConfig, err := cs.Read() diff --git a/config/store.go b/config/store.go index c4863cd..cb4dd48 100644 --- a/config/store.go +++ b/config/store.go @@ -28,7 +28,7 @@ const ( openAICommandPrompt = "[%datetime] [Q%counter]" ) -type ConfigStore interface { +type Store interface { Delete(string) error List() ([]string, error) Read() (Config, error) @@ -37,7 +37,7 @@ type ConfigStore interface { } // Ensure FileIO implements ConfigStore interface -var _ ConfigStore = &FileIO{} +var _ Store = &FileIO{} type FileIO struct { configFilePath string diff --git a/history/manager.go b/history/manager.go index f911d89..494c1d8 100644 --- a/history/manager.go +++ b/history/manager.go @@ -13,10 +13,10 @@ const ( ) type Manager struct { - store HistoryStore + store Store } -func NewHistory(store HistoryStore) *Manager { +func NewHistory(store Store) *Manager { return &Manager{store: store} } diff --git a/history/store.go b/history/store.go index 9e6675d..af2cf13 100644 --- a/history/store.go +++ b/history/store.go @@ -13,7 +13,7 @@ const ( jsonExtension = ".json" ) -type HistoryStore interface { +type Store interface { Read() ([]History, error) ReadThread(string) ([]History, error) Write([]History) error @@ -22,7 +22,7 @@ type HistoryStore interface { } // Ensure FileIO implements the HistoryStore interface -var _ HistoryStore = &FileIO{} +var _ Store = &FileIO{} type FileIO struct { historyDir string