Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Update Akka gRPC to 0.8.0 (#211)
Browse files Browse the repository at this point in the history
* Update Akka gRPC to 0.8.0

Unfortunately running into akka/akka-grpc#628 now

* Update to 0.8.1

* Update akka-grpc

To a version that has akka/akka-grpc#943 to fix
compilation errors. Compile/test now works, but assembly still has problems,
and the PR needs a rebase.

* Remove reflection proto

Reflection is provided by akka-grpc. Perhaps we'd like to make the .proto
available here for some reason, but we shouldn't generate code for it.

* reuse writer, shorter codec negotiation

* Update to published akka-grpc snapshot

* Expect server reflection in the reflection in the TCK

Co-authored-by: Arnout Engelen <[email protected]>
  • Loading branch information
viktorklang and raboof authored Apr 30, 2020
1 parent 091142f commit baa43a8
Show file tree
Hide file tree
Showing 43 changed files with 141 additions and 399 deletions.
23 changes: 7 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ inThisBuild(
version := dynverGitDescribeOutput.value.mkVersion(versionFmt, "latest"),
dynver := sbtdynver.DynVer.getGitDescribeOutput(new Date).mkVersion(versionFmt, "latest"),
scalaVersion := "2.12.11",
// Needed for the fixed HTTP/2 connection cleanup version of akka-http
resolvers += Resolver.bintrayRepo("akka", "snapshots"), // TODO: Remove once we're switching to akka-http 10.1.11
// Needed for the akka-grpc 0.8.4 snapshot
resolvers += Resolver.bintrayRepo("akka", "maven"), // TODO: Remove once we're switching to akka-grpc 0.8.5/1.0.0
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("https://lightbend.com")),
startYear := Some(2019),
Expand Down Expand Up @@ -71,11 +71,6 @@ def common: Seq[Setting[_]] = Seq(
de.heikoseeberger.sbtheader.FileType("proto") -> HeaderCommentStyle.cppStyleLineComment,
de.heikoseeberger.sbtheader.FileType("js") -> HeaderCommentStyle.cStyleBlockComment
),
// Akka gRPC adds all protobuf files from the classpath to this, which we don't want because it includes
// all the Google protobuf files which are already compiled and on the classpath by ScalaPB. So we set it
// back to just our source directory.
PB.protoSources in Compile := Seq(),
PB.protoSources in Test := Seq(),
// Akka gRPC overrides the default ScalaPB setting including the file base name, let's override it right back.
akkaGrpcCodeGeneratorSettings := Seq(),
excludeFilter in headerResources := HiddenFileFilter || GlobFilter("reflection.proto"),
Expand Down Expand Up @@ -422,18 +417,14 @@ lazy val `proxy-core` = (project in file("proxy/core"))
},
PB.protoSources in Compile ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Seq(baseDir / "proxy", baseDir / "frontend", baseDir / "protocol", (sourceDirectory in Compile).value / "protos")
Seq(baseDir / "proxy", baseDir / "frontend", baseDir / "protocol")
},
PB.protoSources in Test ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Seq(baseDir / "frontend")
},
// For Google Cloud Pubsub API
PB.protoSources in Compile += target.value / "protobuf_external" / "google" / "pubsub" / "v1",
// This adds the test/protos dir and enables the ProtocPlugin to generate protos in the Test scope
inConfig(Test)(
sbtprotoc.ProtocPlugin.protobufConfigSettings ++ Seq(
PB.protoSources ++= Seq(sourceDirectory.value / "protos"),
akkaGrpcCodeGeneratorSettings := Seq(),
akkaGrpcGeneratedSources := Seq(AkkaGrpc.Server, AkkaGrpc.Client)
)
),
javaAgents += "org.mortbay.jetty.alpn" % "jetty-alpn-agent" % "2.0.9" % "runtime;test",
dockerSettings,
fork in run := true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CrdtImpl(system: ActorSystem, services: Map[String, CrdtStatefulService],
def handle(in: Source[CrdtStreamIn, NotUsed]): Source[CrdtStreamOut, NotUsed] =
in.prefixAndTail(1)
.flatMapConcat {
case (Seq(CrdtStreamIn(In.Init(init))), source) =>
case (Seq(CrdtStreamIn(In.Init(init), _)), source) =>
source.via(runEntity(init))
case _ =>
// todo better error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ private[crdt] final class FlagImpl extends InternalCrdt with Flag {
override def state: CrdtState.State = CrdtState.State.Flag(FlagState(value))

override val applyDelta = {
case CrdtDelta.Delta.Flag(FlagDelta(value)) =>
case CrdtDelta.Delta.Flag(FlagDelta(value, _)) =>
this.value |= value
}

override val applyState = {
case CrdtState.State.Flag(FlagState(value)) =>
case CrdtState.State.Flag(FlagState(value, _)) =>
this.value = value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ private[crdt] final class GCounterImpl extends InternalCrdt with GCounter {
override def state: CrdtState.State = CrdtState.State.Gcounter(GCounterState(value))

override val applyDelta = {
case CrdtDelta.Delta.Gcounter(GCounterDelta(increment)) =>
case CrdtDelta.Delta.Gcounter(GCounterDelta(increment, _)) =>
value += increment
}

override val applyState = {
case CrdtState.State.Gcounter(GCounterState(value)) =>
case CrdtState.State.Gcounter(GCounterState(value, _)) =>
this.value = value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ private[crdt] final class GSetImpl[T](anySupport: AnySupport)
override def state: CrdtState.State = CrdtState.State.Gset(GSetState(value.asScala.toSeq.map(anySupport.encodeScala)))

override val applyDelta = {
case CrdtDelta.Delta.Gset(GSetDelta(added)) =>
case CrdtDelta.Delta.Gset(GSetDelta(added, _)) =>
value.addAll(added.map(e => anySupport.decode(e).asInstanceOf[T]).asJava)
}

override val applyState = {
case CrdtState.State.Gset(GSetState(value)) =>
case CrdtState.State.Gset(GSetState(value, _)) =>
this.value.clear()
this.value.addAll(value.map(e => anySupport.decode(e).asInstanceOf[T]).asJava)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ private[crdt] final class LWWRegisterImpl[T](anySupport: AnySupport) extends Int
)

override val applyDelta = {
case CrdtDelta.Delta.Lwwregister(LWWRegisterDelta(Some(any), _, _)) =>
case CrdtDelta.Delta.Lwwregister(LWWRegisterDelta(Some(any), _, _, _)) =>
this.value = anySupport.decode(any).asInstanceOf[T]
}

override val applyState = {
case CrdtState.State.Lwwregister(LWWRegisterState(Some(any), _, _)) =>
case CrdtState.State.Lwwregister(LWWRegisterState(Some(any), _, _, _)) =>
this.value = anySupport.decode(any).asInstanceOf[T]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ private[crdt] final class ORMapImpl[K, V <: InternalCrdt](anySupport: AnySupport
)

override val applyDelta = {
case CrdtDelta.Delta.Ormap(ORMapDelta(cleared, removed, updated, added)) =>
case CrdtDelta.Delta.Ormap(ORMapDelta(cleared, removed, updated, added, _)) =>
if (cleared) {
value.clear()
}
removed.foreach(key => value.remove(anySupport.decode(key)))
updated.foreach {
case ORMapEntryDelta(Some(key), Some(delta)) =>
case ORMapEntryDelta(Some(key), Some(delta), _) =>
val crdt = value.get(anySupport.decode(key))
if (crdt == null) {
ORMapImpl.log.warn(s"ORMap entry to update with key $key not found in map")
Expand All @@ -188,17 +188,17 @@ private[crdt] final class ORMapImpl[K, V <: InternalCrdt](anySupport: AnySupport
}
}
added.foreach {
case ORMapEntry(Some(key), Some(state)) =>
case ORMapEntry(Some(key), Some(state), _) =>
value.put(anySupport.decode(key).asInstanceOf[K],
CrdtStateTransformer.create(state, anySupport).asInstanceOf[V])
}
}

override val applyState = {
case CrdtState.State.Ormap(ORMapState(values)) =>
case CrdtState.State.Ormap(ORMapState(values, _)) =>
value.clear()
values.foreach {
case ORMapEntry(Some(key), Some(state)) =>
case ORMapEntry(Some(key), Some(state), _) =>
value.put(anySupport.decode(key).asInstanceOf[K],
CrdtStateTransformer.create(state, anySupport).asInstanceOf[V])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private[crdt] class ORSetImpl[T](anySupport: AnySupport) extends util.AbstractSe
CrdtState.State.Orset(ORSetState(value.asScala.toSeq.map(anySupport.encodeScala)))

override val applyDelta = {
case CrdtDelta.Delta.Orset(ORSetDelta(cleared, removed, added)) =>
case CrdtDelta.Delta.Orset(ORSetDelta(cleared, removed, added, _)) =>
if (cleared) {
value.clear()
}
Expand All @@ -110,7 +110,7 @@ private[crdt] class ORSetImpl[T](anySupport: AnySupport) extends util.AbstractSe
}

override val applyState = {
case CrdtState.State.Orset(ORSetState(value)) =>
case CrdtState.State.Orset(ORSetState(value, _)) =>
this.value.clear()
this.value.addAll(value.map(e => anySupport.decode(e).asInstanceOf[T]).asJava)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ private[crdt] final class PNCounterImpl extends InternalCrdt with PNCounter {
override def state: CrdtState.State = CrdtState.State.Pncounter(PNCounterState(value))

override val applyDelta = {
case CrdtDelta.Delta.Pncounter(PNCounterDelta(increment)) =>
case CrdtDelta.Delta.Pncounter(PNCounterDelta(increment, _)) =>
value += increment
}

override val applyState = {
case CrdtState.State.Pncounter(PNCounterState(value)) =>
case CrdtState.State.Pncounter(PNCounterState(value, _)) =>
this.value = value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ private[crdt] final class VoteImpl extends InternalCrdt with Vote {
override def state: CrdtState.State = CrdtState.State.Vote(VoteState(votesFor, voters, selfVote))

override val applyDelta = {
case CrdtDelta.Delta.Vote(VoteDelta(_, votesFor, totalVoters)) =>
case CrdtDelta.Delta.Vote(VoteDelta(_, votesFor, totalVoters, _)) =>
this.voters = totalVoters
this.votesFor = votesFor
}

override val applyState = {
case CrdtState.State.Vote(VoteState(votesFor, voters, selfVote)) =>
case CrdtState.State.Vote(VoteState(votesFor, voters, selfVote, _)) =>
this.voters = voters
this.votesFor = votesFor
this.selfVote = selfVote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final class EventSourcedImpl(_system: ActorSystem,
): akka.stream.scaladsl.Source[EventSourcedStreamOut, akka.NotUsed] =
in.prefixAndTail(1)
.flatMapConcat {
case (Seq(EventSourcedStreamIn(InInit(init))), source) =>
case (Seq(EventSourcedStreamIn(InInit(init), _)), source) =>
source.via(runEntity(init))
case _ =>
// todo better error
Expand Down
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.17")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.3.0")

addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "0.7.1")
resolvers += Resolver.bintrayRepo("akka", "maven")
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "0.8.4+25-52f006d6")
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.4")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
Expand Down
136 changes: 0 additions & 136 deletions protocols/proxy/grpc/reflection/v1alpha/reflection.proto

This file was deleted.

Loading

0 comments on commit baa43a8

Please sign in to comment.