-
Notifications
You must be signed in to change notification settings - Fork 1
/
serv.go
39 lines (32 loc) · 824 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
package policyservice
import (
"context"
"fmt"
"github.com/ScoreTrak/ScoreTrak/pkg/policy"
repo2 "github.com/ScoreTrak/ScoreTrak/pkg/policy/policyrepo"
)
type Serv interface {
Get(ctx context.Context) (*policy.Policy, error)
Update(ctx context.Context, u *policy.Policy) error
}
type policyServ struct {
repo repo2.Repo
}
func NewPolicyServ(repo repo2.Repo) Serv {
return &policyServ{
repo: repo,
}
}
func (svc *policyServ) Get(ctx context.Context) (*policy.Policy, error) {
p, err := svc.repo.Get(ctx)
if err != nil {
return nil, fmt.Errorf("failed to make a get call: %w", err)
}
return p, nil
}
func (svc *policyServ) Update(ctx context.Context, u *policy.Policy) error {
if err := svc.repo.Update(ctx, u); err != nil {
return fmt.Errorf("failed to make update call: %w", err)
}
return nil
}