Skip to content

Commit

Permalink
chore: unify Store interface across modules
Browse files Browse the repository at this point in the history
  • Loading branch information
kardolus committed Nov 6, 2024
1 parent 670c7ff commit 7d1821e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions config/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
openAICommandPrompt = "[%datetime] [Q%counter]"
)

type ConfigStore interface {
type Store interface {
Delete(string) error
List() ([]string, error)
Read() (Config, error)
Expand All @@ -37,7 +37,7 @@ type ConfigStore interface {
}

// Ensure FileIO implements ConfigStore interface
var _ ConfigStore = &FileIO{}
var _ Store = &FileIO{}

type FileIO struct {
configFilePath string
Expand Down
4 changes: 2 additions & 2 deletions history/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

Expand Down
4 changes: 2 additions & 2 deletions history/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
jsonExtension = ".json"
)

type HistoryStore interface {
type Store interface {
Read() ([]History, error)
ReadThread(string) ([]History, error)
Write([]History) error
Expand All @@ -22,7 +22,7 @@ type HistoryStore interface {
}

// Ensure FileIO implements the HistoryStore interface
var _ HistoryStore = &FileIO{}
var _ Store = &FileIO{}

type FileIO struct {
historyDir string
Expand Down

0 comments on commit 7d1821e

Please sign in to comment.