-
Notifications
You must be signed in to change notification settings - Fork 268
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
Wrap all routes in toStrictEntity #1032
Conversation
# Conflicts: # eclair-core/src/main/scala/fr/acinq/eclair/api/Service.scala
I think it's the right solution, just taking a bit more time to review it. |
# Conflicts: # eclair-core/src/main/scala/fr/acinq/eclair/api/Service.scala
Codecov Report
@@ Coverage Diff @@
## master #1032 +/- ##
=========================================
+ Coverage 82.23% 82.43% +0.2%
=========================================
Files 99 99
Lines 7559 7561 +2
Branches 291 296 +5
=========================================
+ Hits 6216 6233 +17
+ Misses 1343 1328 -15
|
Using I think using path("connect") {
formFields("uri".as[NodeURI].?, nodeIdFormParam.?, "host".as[String].?, "port".as[Int].?) { (uri_opt, nodeId_opt, host_opt, port_opt) =>
(uri_opt, nodeId_opt, host_opt, port_opt) match {
case (Some(uri), None, None, None) => complete(eclairApi.connect(Left(uri)))
case (None, Some(nodeId), Some(host), _) => complete(eclairApi.connect(Left(NodeURI(nodeId, HostAndPort.fromParts(host, port_opt.getOrElse(NodeURI.DEFAULT_PORT))))))
case (None, Some(nodeId), None, None) => complete(eclairApi.connect(Right(nodeId)))
case _ => reject(MalformedFormFieldRejection("connect", "You must either provide field 'uri' or field 'nodeId' with optional fields 'host' and 'port'"))
}
} This is much closer to what we have and there's only 1 or 2 places where we would need to do this. WDYT ? |
I like the suggestion of not matching on multiple |
It's less elegant than what we have now, but if that solves the issue and saves us from using timeouts, then I'm all for it. |
We're matching multiple
|
And I missed that there is another form field for the API timeout.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one more change request
@@ -70,6 +70,8 @@ trait Service extends ExtraDirectives with Logging { | |||
implicit val actorSystem: ActorSystem | |||
implicit val mat: ActorMaterializer | |||
|
|||
val paramParsingTimeout = 30 seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this is our input time-out i.e the time we'll wait the whole request to be received. Since our API request are really small this time-out should be just a few seconds, I suggest we set it to 5 seconds instead.
There should also be a comment that explains what this timeout is for, and the impact this change if we ever decide to add API calls with very large inputs (which is unlikely)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be specific this timeout puts a limit on the time spent receiving data of a request parameter, ACK your suggestion I'll put a smaller timeout and a comment.
Looks ok, hope there won't be side effects ! |
This PR fixes #1030 by ensuring that the API parameters are parsed in a strict manner so without partially reading the data and stopping but ensuring that once we start reading we get the full package even if then it is rejected by the unmarshaller. The issue arises mostly when there are concurrent calls to the same endpoint and is a known behavior of akka, see issue.