Skip to content

Well Rested Futures: Implement Scala Future support in RestHelper#1741

Merged
farmdawgnation merged 7 commits into
masterfrom
well-rested-futures
Dec 12, 2015
Merged

Well Rested Futures: Implement Scala Future support in RestHelper#1741
farmdawgnation merged 7 commits into
masterfrom
well-rested-futures

Conversation

@Shadowfiend
Copy link
Copy Markdown
Member

RestHelper has long supported returning an LAFuture as the result of
a RestHelper block and auto-wrapped those in RestHelper.async so
they're dealt with via continuation, much like comet responses. This PR
extends RestHelper to support the same functionality for Scala Futures,
thus rounding out our dual support for Scala and Lift futures both here and
in snippet bindings.

We do this by moving the CanResolveAsync abstraction introduced for
snippet async future binding into lift-util and then reusing that abstraction
in RestHelper. We also add some specs for CanResolveAsync and a
spec to prove that LAFuture is still working as expected.

Closes #1735.

It's really a general abstraction, and we'll want to reuse it for RestHelper.
This should allow RestHelper to auto-wrap Scala Future responses into
RestHelper.async handling, in addition to the LAFuture support that already
existed. Also, the RestHelper.async thread will no longer block while waiting
for its future (Lift or Scala or whatever) to resolve.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What makes an implicit low or high priority?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Where it is in the resolution order; these, however, are misnomers. They'd be low priority if they were in a trait mixed into the singleton. Need to fix that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Made them actually low priority.

@Shadowfiend
Copy link
Copy Markdown
Member Author

This should be good for another 👀.

@farmdawgnation
Copy link
Copy Markdown
Member

Code looks good but it looks like your spec fails in Travis.

https://travis-ci.org/lift/framework/builds/96416723#L2972-L2977

@Shadowfiend
Copy link
Copy Markdown
Member Author

I'm thinking probably the satisfy call satisfies async rather than sync, so I need to drop the .complete_? check in the specs.

We were using that to fail if the spec hadn't sastified its
result future with the value received from the async resolution,
but it looks like those satisfactions happen async, so we can't
be sure that the future will be immediately complete once we
hit that line of code. Instead we just let `get` block until we get
the proper resolution, which should still be very quick.
@Shadowfiend
Copy link
Copy Markdown
Member Author

Looks like the remaining codacy issues are related to duplication and “complexity”, but I don't see how we can improve on those, so I think this should be good to merge.

@farmdawgnation
Copy link
Copy Markdown
Member

Lehgo!

farmdawgnation added a commit that referenced this pull request Dec 12, 2015
RestHelper has long supported returning an LAFuture as the result of
a RestHelper block and auto-wrapped those in RestHelper.async so
they're dealt with via continuation, much like comet responses. This PR
extends RestHelper to support the same functionality for Scala Futures,
thus rounding out our dual support for Scala and Lift futures both here and
in snippet bindings.
@farmdawgnation farmdawgnation merged commit 4c7775a into master Dec 12, 2015
@farmdawgnation farmdawgnation deleted the well-rested-futures branch December 12, 2015 17:49
@fmpwizard fmpwizard added this to the 3.0-M8 milestone Jan 28, 2016
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.

3 participants