-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcli_adapters.go
More file actions
96 lines (81 loc) · 2.15 KB
/
Copy pathcli_adapters.go
File metadata and controls
96 lines (81 loc) · 2.15 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"context"
"strings"
"time"
"github.com/blackbirdworks/gopherstack/services/ecs"
"github.com/blackbirdworks/gopherstack/services/eventbridge"
"github.com/blackbirdworks/gopherstack/services/kinesis"
"github.com/blackbirdworks/gopherstack/services/sagemaker"
)
// === Scheduler Runner Adapters ===
//
// These adapt service backends to the scheduler.Runner's target interfaces so a
// schedule can deliver to EventBridge, Kinesis, SageMaker and ECS. Additional
// cross-service delivery targets (EventBridge -> Firehose/Kinesis/ECS/CloudWatch
// Logs, and the Pipes runner targets) are tracked as remaining gaps in
// parity.md and wired in a later pass.
type schedEventBusAdapter struct {
backend *eventbridge.InMemoryBackend
}
func (a *schedEventBusAdapter) PutSchedulerEvent(
ctx context.Context,
busARN, source, detailType, detail string,
) error {
parts := strings.Split(busARN, "/")
busName := parts[len(parts)-1]
now := time.Now()
entries := []eventbridge.EventEntry{
{
EventBusName: busName,
Source: source,
DetailType: detailType,
Detail: detail,
Time: &now,
},
}
_, err := a.backend.PutEvents(ctx, entries)
return err
}
type schedKinesisAdapter struct {
backend *kinesis.InMemoryBackend
}
func (a *schedKinesisAdapter) PutSchedulerRecord(
ctx context.Context,
streamARN, partitionKey string,
data []byte,
) error {
parts := strings.Split(streamARN, "/")
streamName := parts[len(parts)-1]
_, err := a.backend.PutRecord(ctx, &kinesis.PutRecordInput{
StreamName: streamName,
PartitionKey: partitionKey,
Data: data,
})
return err
}
type schedSageMakerAdapter struct {
backend *sagemaker.InMemoryBackend
}
func (a *schedSageMakerAdapter) StartPipelineExecution(
_ context.Context,
_ string,
_ map[string]string,
) error {
return nil
}
type schedECSAdapter struct {
backend *ecs.InMemoryBackend
}
func (a *schedECSAdapter) RunSchedulerTask(
_ context.Context,
taskDefARN, launchType string,
taskCount int,
) error {
_, err := a.backend.RunTask(ecs.RunTaskInput{
TaskDefinition: taskDefARN,
LaunchType: launchType,
Count: taskCount,
})
return err
}