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

Ajax retry configuration #1762

Closed
wants to merge 7 commits into from
Closed

Ajax retry configuration #1762

wants to merge 7 commits into from

Conversation

joescii
Copy link
Contributor

@joescii joescii commented Jan 29, 2016

This PR is to give Lift applications more control over ajax retries. With these changes an application can change the ajax queue's sorting logic and retry timeout calculation.

See this ML thread for some discussion regarding this idea.

val ajaxAddMetaAndQueueSortFuncs: FactoryMaker[Box[(JsVar => JsCmd, JsVar => JsCmd)]] = new FactoryMaker[Box[(JsVar => JsCmd, JsVar => JsCmd)]]( () =>
Full((ajaxAddMetaDefaultFunc, ajaxQueueSortDefaultFunc))
) {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd love to have some feedback on the design of this setting. To achieve ordered messages, you have to change both of these functions together. I think this will be the most common use case. However, I can imagine where someone may want to change the ajaxAddMeta function, but not ajaxQueueSort. For instance, if they wanted to add some meta data related to ajaxCalcRetryTime since it has access to the meta.

I went around in circles a bit and decided to just get it out here and have some feedback.

Copy link
Member

Choose a reason for hiding this comment

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

Could we have this FactoryMaker vend some case class instead of a tuple? Would make the code a lot easier to reason about while scanning. And would also avoid client code doing a lot of _1 and _2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely could. I'm just not quite sold on making sure they're coupled together once I noticed that the ajaxAddMeta could conceivably be useful for ajaxCalcRetryTime. Maybe I'm being too open-minded to the world of possibilities which stretches beyond what anybody would actually attempt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ultimately, I'm trying to get the flexibility intended here, while making really easy for a developer to do the right thing.

Copy link
Member

Choose a reason for hiding this comment

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

So the case here is we want to make it easy for the developer to do what they want while encouraging them to couple these things as well because it's important to consider both at the same time? Am I interpreting that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. The ajax queue contains all of the requests wrapped with meta data. Hence ajaxQueueSort() works on those wrappers. If you want to do something different in ajaxQueueSort(), then it's highly likely you'll need to add to that wrapper in ajaxAddMeta().

Furthermore, the out-of-the-box configuration alternative we're offering here is the retry in order, which certainly needs both in order to function correctly. Hence I made the pair a single setting so it's not easy to set it incorrectly.

Another alternative I considered was having these two as separate settings and provide a LiftRules function of type Unit => Unit which sets both correctly for retrying in order. I'm not aware of a prior precedent for this approach in LiftRules, though.

@farmdawgnation
Copy link
Member

👀

@joescii
Copy link
Contributor Author

joescii commented Jan 31, 2016

After discussion, we have decided the the same functionality of this PR can be achieve by overriding the ajax call in its entirety. The complication of our JS settings don't seem worth having.

@joescii joescii closed this Jan 31, 2016
@Shadowfiend
Copy link
Member

Some more thoughts here so it's written down somewhere public :)

I think the goal of lift.js should be to provide a reasonable set of
core behavior that the framework is built around, but that customization
of that behavior should be possible but not necessarily easy. My thought
is just that Lift's core competency isn't really JS—we're trying to provide
just enough glue to make interaction between Lift and the client relatively
painless, but not try to accommodate the 10% case of needing to
potentially change that behavior easily.

So, if we find something you can't customize, we should probably fix
that. It's also probably worth publishing some documentation/a wiki page/
something of the sort regarding how to customize queueing behavior and
things like that. Might be something we can pull from the work you ultimately
do for lift-ng! :)

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.

None yet

3 participants