-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this uses the X-Ray backend directly instead of using OTel, because AWS Lambda supports X-Ray by default, and including an OTel collector is extra work. It sounds like including the collector can be done by building it in as a Lambda Layer, but that's not something I've done before, and I think this will work for now.
- Loading branch information
Showing
16 changed files
with
601 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 19 additions & 12 deletions
31
core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
package com.dwolla.aws.autoscaling | ||
|
||
import cats.* | ||
import cats.effect.{Trace as _, *} | ||
import cats.mtl.Local | ||
import cats.syntax.all.* | ||
import com.amazonaws.sns.TopicARN | ||
import com.dwolla.aws.sns.* | ||
import feral.lambda.events.SnsEvent | ||
import feral.lambda.{INothing, LambdaEnv} | ||
import fs2.Stream | ||
import natchez.{EntryPoint, Span} | ||
import org.typelevel.log4cats.LoggerFactory | ||
import com.dwolla.tracing.syntax.* | ||
|
||
object LifecycleHookHandler { | ||
def apply[F[_] : MonadThrow : LoggerFactory](eventBridge: (TopicARN, LifecycleHookNotification) => F[Unit]) | ||
(using fs2.Compiler[F, F]): LambdaEnv[F, SnsEvent] => F[Option[INothing]] = env => | ||
Stream.eval(env.event) | ||
.map(_.records) | ||
.flatMap(Stream.emits(_)) | ||
.map(_.sns) | ||
.evalMap(ParseLifecycleHookNotification[F]) | ||
.unNone | ||
.evalMap(eventBridge.tupled) | ||
.compile | ||
.drain | ||
.as(None) | ||
def apply[F[_] : MonadCancelThrow : LoggerFactory](entryPoint: EntryPoint[F], hookName: String) | ||
(eventBridge: (TopicARN, LifecycleHookNotification) => F[Unit]) | ||
(using fs2.Compiler[F, F], Local[F, Span[F]]): LambdaEnv[F, SnsEvent] => F[Option[INothing]] = env => | ||
entryPoint.runInRoot(hookName) { | ||
Stream.eval(env.event) | ||
.map(_.records) | ||
.flatMap(Stream.emits(_)) | ||
.map(_.sns) | ||
.evalMap(ParseLifecycleHookNotification[F]) | ||
.unNone | ||
.evalMap(eventBridge.tupled) | ||
.compile | ||
.drain | ||
.as(None) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.