Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into 0.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gchudnov committed Nov 22, 2021
2 parents 86fb3e6 + f10ca5a commit 0e38ad2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ jobs:
- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- name: Login to Docker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Launch Nakadi
run: docker-compose up -d
Expand Down
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ pomIncludeRepository := (_ => false)
resolvers += Resolver.jcenterRepo

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Run(
List("echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin"),
name = Some("Login to Docker"),
env = Map(
"GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}"
WorkflowStep.Use(
UseRef.Public("docker", "login-action", "v1"),
name = Some("Login to GitHub Container Registry"),
params = Map(
"registry" -> "docker.pkg.github.com",
"username" -> "${{ github.actor }}",
"password" -> "${{ secrets.GITHUB_TOKEN }}"
)
),
WorkflowStep.Run(List("docker-compose up -d"), name = Some("Launch Nakadi")),
Expand Down
13 changes: 8 additions & 5 deletions src/main/scala/org/zalando/kanadi/api/Events.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ final case class Metadata(eid: EventId = EventId.random,
flowId: Option[FlowId] = None,
partition: Option[Partition] = None,
partitionCompactionKey: Option[PartitionCompactionKey] = None,
spanCtx: Option[SpanCtx] = None)
spanCtx: Option[SpanCtx] = None,
publishedBy: Option[PublishedBy] = None)

object Metadata {

implicit val metadataEncoder: Encoder[Metadata] = Encoder.forProduct9(
implicit val metadataEncoder: Encoder[Metadata] = Encoder.forProduct10(
"eid",
"occurred_at",
"event_type",
Expand All @@ -164,10 +165,11 @@ object Metadata {
"flow_id",
"partition",
"partition_compaction_key",
"span_ctx"
"span_ctx",
"published_by"
)(x => Metadata.unapply(x).get)

implicit val metadataDecoder: Decoder[Metadata] = Decoder.forProduct9(
implicit val metadataDecoder: Decoder[Metadata] = Decoder.forProduct10(
"eid",
"occurred_at",
"event_type",
Expand All @@ -176,7 +178,8 @@ object Metadata {
"flow_id",
"partition",
"partition_compaction_key",
"span_ctx"
"span_ctx",
"published_by"
)(Metadata.apply)
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/scala/org/zalando/kanadi/models/PublishedBy.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.zalando.kanadi.models

import io.circe.syntax._
import io.circe.{Decoder, Encoder}

final case class PublishedBy(name: String) extends AnyVal

object PublishedBy {
implicit val publishedByEncoder: Encoder[PublishedBy] =
Encoder.instance[PublishedBy](_.name.asJson)
implicit val publishedByDecoder: Decoder[PublishedBy] =
Decoder[String].map(PublishedBy.apply)
}
8 changes: 5 additions & 3 deletions src/test/scala/org/zalando/kanadi/api/JsonSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.specs2.specification.core.SpecStructure
import io.circe._
import io.circe.parser._
import io.circe.syntax._
import org.zalando.kanadi.models.{EventId, SpanCtx}
import org.zalando.kanadi.models.{EventId, SpanCtx, PublishedBy}
import java.time.OffsetDateTime

import io.circe.CursorOp.DownField
Expand All @@ -28,7 +28,9 @@ class JsonSpec extends Specification {
val uuid = UUID.randomUUID()
val testEvent = SomeEvent("Bart", "Simpson", uuid)
val now = OffsetDateTime.now()
val md = Metadata(eid = EventId(UUID.fromString("4ae5011e-eb01-11e5-8b4a-1c6f65464fc6")), occurredAt = now)
val md = Metadata(eid = EventId(UUID.fromString("4ae5011e-eb01-11e5-8b4a-1c6f65464fc6")),
occurredAt = now,
publishedBy = Some(PublishedBy("bart_simpson")))

val coreEventJson = s"""
"first_name": "Bart",
Expand All @@ -37,7 +39,7 @@ class JsonSpec extends Specification {
"""

val metadata =
s""""eid": "4ae5011e-eb01-11e5-8b4a-1c6f65464fc6", "occurred_at": ${now.asJson}"""
s""""eid": "4ae5011e-eb01-11e5-8b4a-1c6f65464fc6", "occurred_at": ${now.asJson}, "published_by": "bart_simpson""""

val businessEventJson = s"""{
"metadata": {$metadata},
Expand Down

0 comments on commit 0e38ad2

Please sign in to comment.