-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
242 additions
and
359 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
512 changes: 169 additions & 343 deletions
512
core/src/main/scala/clue/websocket/ApolloClient.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package clue.websocket | ||
|
||
import clue.model.* | ||
import io.circe.* | ||
|
||
// Internal structure to emit data and errors to the client. | ||
protected[clue] trait Emitter[F[_]] { | ||
val request: GraphQLRequest[JsonObject] | ||
|
||
def emitData(response: GraphQLResponse[Json]): F[Unit] | ||
def emitErrors(errors: GraphQLErrors): F[Unit] | ||
val halt: F[Unit] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package clue.websocket | ||
|
||
import clue.* | ||
import io.circe.* | ||
|
||
// Client internal state for the FSM. | ||
// We keep a connectionId throughout all states to ensure that callback events (onClose, onMessage) | ||
// correpond to the current connection iteration. This is important in case of reconnections. | ||
protected sealed abstract class State[F[_]](val status: PersistentClientStatus) { | ||
val connectionId: ConnectionId | ||
} | ||
|
||
protected object State { | ||
final case class Disconnected[F[_]](connectionId: ConnectionId) | ||
extends State[F](PersistentClientStatus.Disconnected) | ||
|
||
final case class Connecting[F[_]]( | ||
connectionId: ConnectionId, | ||
connection: Option[WebSocketConnection[F]], | ||
initPayload: F[Map[String, Json]], | ||
subscriptions: Map[String, Emitter[F]], | ||
latch: Latch[F] | ||
) extends State[F](PersistentClientStatus.Connecting) | ||
|
||
final case class Connected[F[_]]( | ||
connectionId: ConnectionId, | ||
connection: WebSocketConnection[F], | ||
initPayload: F[Map[String, Json]], | ||
subscriptions: Map[String, Emitter[F]] | ||
) extends State[F](PersistentClientStatus.Connected) | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
org.slf4j.simpleLogger.defaultLogLevel=trace |
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