Skip to content

Commit 82c2f94

Browse files
authored
Create separate Akka-less gateway-data project (#43)
* Extract certain gateway types into an Akka-less gateway-data project * Scalafmt everything * Undelete copyright comments * Add gateway-data to aggregates * Undo IntelliJ comment spacings
1 parent f489677 commit 82c2f94

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

build.sbt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ lazy val data = crossProject(JSPlatform, JVMPlatform)
7171
lazy val dataJVM = data.jvm
7272
lazy val dataJS = data.js
7373

74+
lazy val gatewayData = crossProject(JSPlatform, JVMPlatform)
75+
.crossType(CrossType.Pure)
76+
.settings(
77+
commonSettings,
78+
publishSettings,
79+
name := "gateway-data",
80+
version := ackCordVersion
81+
)
82+
.dependsOn(data)
83+
84+
lazy val gatewayDataJVM = gatewayData.jvm
85+
lazy val gatewayDataJS = gatewayData.js
86+
7487
lazy val requests = project
7588
.settings(
7689
commonSettings,
@@ -101,7 +114,7 @@ lazy val gateway = project
101114
),
102115
Compile / doc / scalacOptions ++= Seq("-skip-packages", "akka.pattern")
103116
)
104-
.dependsOn(dataJVM)
117+
.dependsOn(gatewayDataJVM)
105118

106119
lazy val voice = project
107120
.settings(
@@ -224,6 +237,7 @@ lazy val docs = project
224237
autoAPIMappings := true,
225238
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(
226239
dataJVM,
240+
gatewayDataJVM,
227241
requests,
228242
gateway,
229243
voice,
@@ -254,6 +268,8 @@ lazy val ackCordRoot = project
254268
.aggregate(
255269
dataJVM,
256270
dataJS,
271+
gatewayDataJVM,
272+
gatewayDataJS,
257273
requests,
258274
gateway,
259275
voice,
File renamed without changes.
File renamed without changes.

gateway/src/main/scala/ackcord/gateway/gatewayData.scala renamed to gatewayData/src/main/scala/ackcord/gateway/gatewayData.scala

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package ackcord.gateway
2626
import ackcord.data._
2727
import ackcord.data.raw._
2828
import ackcord.util.{IntCirceEnumWithUnknown, JsonOption, JsonSome, JsonUndefined}
29-
import akka.NotUsed
3029
import cats.{Eval, Later, Now}
3130
import enumeratum.values.{IntEnum, IntEnumEntry}
3231
import io.circe.Decoder.Result
@@ -225,9 +224,9 @@ case class Resume(nowD: ResumeData, gatewayInfo: GatewayInfo)
225224
/**
226225
* Sent by the gateway to indicate that the shard should reconnect.
227226
*/
228-
case class Reconnect(gatewayInfo: GatewayInfo) extends EagerGatewayMessage[NotUsed] with ServerGatewayMessage[NotUsed] {
227+
case class Reconnect(gatewayInfo: GatewayInfo) extends EagerGatewayMessage[Unit] with ServerGatewayMessage[Unit] {
229228
override def op: GatewayOpCode = GatewayOpCode.Reconnect
230-
override def nowD: NotUsed = NotUsed
229+
override def nowD: Unit = ()
231230
}
232231

233232
/**
@@ -286,20 +285,18 @@ case class Hello(nowD: HelloData, gatewayInfo: GatewayInfo)
286285
/**
287286
* Sent by the gateway as a response to [[Heartbeat]].
288287
*/
289-
case class HeartbeatACK(gatewayInfo: GatewayInfo)
290-
extends EagerGatewayMessage[NotUsed]
291-
with ServerGatewayMessage[NotUsed] {
288+
case class HeartbeatACK(gatewayInfo: GatewayInfo) extends EagerGatewayMessage[Unit] with ServerGatewayMessage[Unit] {
292289
override def op: GatewayOpCode = GatewayOpCode.HeartbeatACK
293-
override def nowD: NotUsed = NotUsed
290+
override def nowD: Unit = ()
294291
}
295292

296293
/**
297294
* All unknown gateway messages.
298295
*/
299296
case class UnknownGatewayMessage(op: GatewayOpCode, gatewayInfo: GatewayInfo)
300-
extends EagerGatewayMessage[NotUsed]
301-
with ServerGatewayMessage[NotUsed] {
302-
override def nowD: NotUsed = NotUsed
297+
extends EagerGatewayMessage[Unit]
298+
with ServerGatewayMessage[Unit] {
299+
override def nowD: Unit = ()
303300
}
304301

305302
/**
@@ -387,10 +384,10 @@ object GatewayEvent {
387384
/**
388385
* Sent to the shard when a previously interrupted connection is resumed.
389386
*/
390-
case class Resumed(rawData: Json) extends GatewayEvent[NotUsed] {
387+
case class Resumed(rawData: Json) extends GatewayEvent[Unit] {
391388
override def name: String = "RESUMED"
392389

393-
override def data: Later[Result[NotUsed]] = Later(Right(NotUsed))
390+
override def data: Later[Result[Unit]] = Later(Right(()))
394391
}
395392

396393
/**
@@ -1035,8 +1032,8 @@ object GatewayEvent {
10351032
) {
10361033

10371034
def reparse[A: Decoder]: Result[A] = {
1038-
import GatewayProtocol._
10391035
import io.circe.syntax._
1036+
import GatewayProtocol._
10401037
val self: SimpleRawInteraction = this
10411038
self.asJson.as[A]
10421039
}
@@ -1059,8 +1056,8 @@ object GatewayEvent {
10591056
) {
10601057

10611058
def reparse[A: Decoder]: Decoder.Result[A] = {
1062-
import GatewayProtocol._
10631059
import io.circe.syntax._
1060+
import GatewayProtocol._
10641061
val self: SimpleApplicationCommandWithGuildId = this
10651062
self.asJson.as[A]
10661063
}

0 commit comments

Comments
 (0)