-
Notifications
You must be signed in to change notification settings - Fork 1
/
serv.go
48 lines (37 loc) · 991 Bytes
/
serv.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package configservice
import (
"context"
"github.com/ScoreTrak/ScoreTrak/pkg/config"
repo2 "github.com/ScoreTrak/ScoreTrak/pkg/config/configrepo"
)
type Serv interface {
Get(ctx context.Context) (*config.DynamicConfig, error)
Update(context.Context, *config.DynamicConfig) error
}
type configServ struct {
repo repo2.Repo
}
func NewConfigServ(repo repo2.Repo) Serv {
return &configServ{
repo: repo,
}
}
func (svc *configServ) Get(ctx context.Context) (*config.DynamicConfig, error) {
return svc.repo.Get(ctx)
}
func (svc *configServ) Update(ctx context.Context, cfg *config.DynamicConfig) error {
return svc.repo.Update(ctx, cfg)
}
type StaticServ interface {
Get() (*config.StaticConfig, error)
}
type configStaticServ struct {
Config config.StaticConfig
}
func NewStaticConfigServ(cfg config.StaticConfig) StaticServ {
return &configStaticServ{Config: cfg}
}
func (svc *configStaticServ) Get() (*config.StaticConfig, error) {
sc := svc.Config
return &sc, nil
}