Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rough draft wip for ws on AkkaHttp #196

Closed
wants to merge 13 commits into from

Conversation

phderome
Copy link
Contributor

@phderome phderome commented Feb 3, 2020

Minor progress on ws solution for AkkaHttpAdapter, stuck when using Altair

some potential proposal of refactoring of Http4sAdapter though there is no apparent/intentional functional change. I personally like it better, but it's not needed for sure for this PR.

…is no apparent/intentional functional change

Minor progress on ws solution for AkkaHttpAdapter
@phderome phderome requested a review from ghostdogpr February 3, 2020 03:55
val apiRoute: Route = AkkaHttpAdapter.makeHttpServiceM(interpreter)
val wsApiRoute = {
// when do we create subscriptions? When do we make it effectful/unsafe?
// val subscriptions: UIO[Ref[Map[String, Fiber[Throwable, Unit]]]] = Ref.make(Map.empty[String, Fiber[Throwable, Unit]])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscriptions should be created inside the adapter, the end-user don't need to see it. A new Ref should be created for each WS connection.

} ~ path("graphiql") {
getFromResource("graphiql.html")
}

// convention is normally 8080. Keep at 8088?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because so many services use 8080, I always end up with conflicts. I'd prefer to keep 8088 for this reason.

…is no apparent/intentional functional change

Minor progress on ws solution for AkkaHttpAdapter
# Conflicts:
#	examples/src/main/scala/caliban/akkahttp/ExampleApp.scala
# Conflicts:
#	examples/src/main/scala/caliban/akkahttp/ExampleApp.scala
…eateFlow, createSource, route for ws/graphql, use handleMessagesWithSinkSource with subprotocol
…ketRoute respectively

Added wrappers to Akka example interpreter
removed silencer in sbt for AkkaHttp project

onGraphQLResponse is now almost identical to http4s version
processMessage is now almost identical to http4s version except shortcoming of stop handling, which needs more work
removed prints

pending issues:
mutations: return only partial data unlike http4s
lifecycle of subscriptions is unclear and could be quite wrong. For instance when routes are created multiple times from Caliban we see loads of duplicate answers, though that's not necessarily a susbscription issue. It's not perfectly clear when it should be recreated (done in createSink)
definition and usage trait Protocol with Complete, Fail is suspect (see createSource usage of Source.actorRef comment below)
processMessage, connection terminate case should close cleanly and it's not immediately obvious how to do it (possibly some via hook in createSink/Flow)
usage of Actor to send messages back is weak in terms of back-pressure. Akka Http and Streams users recommend instead using some kind of queue. This needs investigation.
createSource usage of Source.actorRef requires a CompletionMatcher and FailureMatcher and it's not clear how we should handle those.
@phderome
Copy link
Contributor Author

phderome commented Feb 16, 2020

Comments on where we stand here.

  • onGraphQLResponse is now almost identical to http4s version
  • processMessage is now almost identical to http4s version except shortcoming of stop handling, which needs more work

Pending issues:

  • lifecycle of subscriptions is unclear and could be quite wrong. For instance when routes are created multiple times from Caliban we see loads of duplicate answers, though that's not necessarily a subscription issue. It's not perfectly clear when it should be recreated (done in createSink). I often see webSocketRoute being created multiple times. It seems like many clients exist in same browser window exist concurrently and the negative symptom is that we process the same message/ws 4-5 times instead of once, leading to excessive responses in a single Altair Client window.
  • definition and usage trait Protocol with Complete, Fail is suspect (see createSource usage of Source.actorRef comment below)
  • processMessage, connection terminate case should close cleanly and it's not immediately obvious how to do it (possibly some via hook in createSink/Flow)
  • usage of Actor to send messages back is weak in terms of back-pressure. Akka Http and Streams users recommend instead using some kind of queue. This needs investigation.
  • createSource usage of Source.actorRef requires a CompletionMatcher and FailureMatcher and it's not clear how we should handle those.

@phderome
Copy link
Contributor Author

subsumed by #219.

@phderome phderome closed this Feb 17, 2020
@phderome phderome deleted the pderome-72 branch February 17, 2020 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants