-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcage.go
51 lines (44 loc) · 945 Bytes
/
cage.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
49
50
51
package cage
import (
"context"
"time"
"github.com/loilo-inc/canarycage/awsiface"
)
type Cage interface {
Up(ctx context.Context) (*UpResult, error)
Run(ctx context.Context, input *RunInput) (*RunResult, error)
RollOut(ctx context.Context, input *RollOutInput) (*RollOutResult, error)
}
type Time interface {
Now() time.Time
NewTimer(time.Duration) *time.Timer
}
type cage struct {
Env *Envars
Ecs awsiface.EcsClient
Alb awsiface.AlbClient
Ec2 awsiface.Ec2Client
Time Time
MaxWait time.Duration
}
type Input struct {
Env *Envars
ECS awsiface.EcsClient
ALB awsiface.AlbClient
EC2 awsiface.Ec2Client
Time Time
MaxWait time.Duration
}
func NewCage(input *Input) Cage {
if input.Time == nil {
input.Time = &timeImpl{}
}
return &cage{
Env: input.Env,
Ecs: input.ECS,
Alb: input.ALB,
Ec2: input.EC2,
Time: input.Time,
MaxWait: 15 * time.Minute,
}
}