-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmock.go
45 lines (35 loc) · 933 Bytes
/
mock.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
package mock
import (
"sync"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
"github.com/nyaruka/gocommon/aws/cwatch"
)
type MockCWService struct {
namespace string
deployment types.Dimension
Batcher []types.MetricDatum
Stopped bool
}
func NewMockCWService(accessKey, secretKey, region, namespace, deployment string) (*MockCWService, error) {
mockCW := MockCWService{
namespace: namespace,
deployment: types.Dimension{Name: aws.String("Deployment"), Value: aws.String(deployment)},
Batcher: nil,
}
return &mockCW, nil
}
func (s *MockCWService) Queue(d types.MetricDatum) {
if s.Stopped {
return
}
s.Batcher = append(s.Batcher, d)
}
func (s *MockCWService) StartQueue(wg *sync.WaitGroup) {
s.Batcher = []types.MetricDatum{}
s.Stopped = false
}
func (s *MockCWService) StopQueue() {
s.Stopped = true
}
var _ cwatch.CWService = (*MockCWService)(nil)