-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.go
32 lines (29 loc) · 807 Bytes
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package store
import (
"context"
"stoo-kv/config"
"stoo-kv/internal/provider"
)
type Store interface {
Set(key string, value any) error
Get(key string) (string, error)
Delete(key string) error
//GetAll() (map[string]string, error)
GetByNameSpaceAndProfile(namespace, profile string) (map[string]string, error)
}
func NewStorage(config *config.Config) (Store, error) {
switch config.Application.StorageType {
case "redis":
return provider.NewRedisClient(context.Background(), config), nil
case "mysql":
return provider.NewMySql(config)
case "postgres":
return provider.NewPostgres(config)
case "mongo":
return provider.NewMongoClient(context.TODO(), config)
case "etcd":
return provider.NewEtcdClient(context.Background(), config)
default:
return provider.NewMemory(), nil
}
}