jvmMain.com.steamstreet.aws.test.DynamoEventBridgePipe.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of awskt-test-jvm Show documentation
Show all versions of awskt-test-jvm Show documentation
Some useful tools for writing local unit tests.
package com.steamstreet.aws.test
import aws.sdk.kotlin.services.eventbridge.EventBridgeClient
import aws.sdk.kotlin.services.eventbridge.model.PutEventsRequestEntry
import aws.sdk.kotlin.services.eventbridge.putEvents
import com.steamstreet.dynamokt.DynamoStreamEvent
import kotlinx.serialization.json.Json
/**
* Returns a StreamProcessorFunction that can be used to pipe stream events
* to an EventBridge bus.
*
* Pass this to the DynamoStreamRunner constructor to pipe data to
* the provided EventBridge client (which will typically be EventBridgeMock).
*/
public fun dynamoPipe(
eventBridge: EventBridgeClient,
eventBusArn: String,
detailType: String,
source: String
): StreamProcessorFunction {
suspend fun streamProcessor(event: DynamoStreamEvent) {
eventBridge.putEvents {
entries = listOf(
PutEventsRequestEntry {
eventBusName = (eventBusArn.substringAfterLast(":event-bus/"))
detail = (Json.encodeToString(DynamoStreamEvent.serializer(), event))
this.detailType = detailType
this.source = source
}
)
}
}
return ::streamProcessor
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy