Repository navigation
Expand file tree
/
Copy pathpintpoint_service.js
More file actions
50 lines (39 loc) · 1.5 KB
/
Copy pathpintpoint_service.js
File metadata and controls
50 lines (39 loc) · 1.5 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
import { Input, Pipeline, Transformation, Output, AdapterRegistry, EventRegistry } from "alchemist-etl";
import PinpointEventTransformation from "../adapters/pinpoint_event_transformation";
import AWS from 'aws-sdk'
export default class PinpointService {
constructor(opts) {
// Register the adapters used in the ETL Job
this.adapterRegistry = new AdapterRegistry();
this.adapterRegistry.register(PinpointEventTransformation);
this.eventRegistry = new EventRegistry();
this.event = this.eventRegistry.eventFor('KinesisEvent', opts.event);
this.context = opts.context
}
async call() {
let input = this.buildInput()
let output = this.buildOutput()
let transformations = this.buildTranformations()
// Use console for invalid output ( notice ConsoleOutput is a preregistered Adapter )
let invalidOutput = Output.instanceFor(this.adapterRegistry, 'ConsoleOutput', { })
let pipeline = new Pipeline({
input: input,
transformations: transformations,
output: output,
invalidOutput: invalidOutput
})
await pipeline.call()
}
buildInput() {
return Input.instanceFor(this.adapterRegistry, 'KinesisInput', { events: this.event.events() })
}
buildOutput() {
let stream_name = "my-kinesis-stream"
return Output.instanceFor(this.adapterRegistry, 'KinesisOutput', {stream_name: stream_name})
}
buildTranformations() {
return [
Transformation.instanceFor(this.adapterRegistry, 'PinpointEventTransformation')
]
}
}