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

Discussion - Asynchronous Actions #58

Closed
alexstandiford opened this issue Jul 1, 2020 · 5 comments
Closed

Discussion - Asynchronous Actions #58

alexstandiford opened this issue Jul 1, 2020 · 5 comments

Comments

@alexstandiford
Copy link
Collaborator

I really wish it were possible to do asynchronous actions in BerlinDB. There are numerous instances in-which a process does not need to wait for a database change to happen to continue.

A simple example is deleting related data from other related tables, such as metadata.

There are also less-common scenarios where the system needs to save data, but does not need to use that record right away.

I recognize that PHP doesn't have any true async capabilities like Javascript, but perhaps we could set something up that runs a set of operations in a separate request.

I'm writing this with the intent to discuss different ways to approach this, identify pitfalls, and even identify if this sort of thing should be in BerlinDB at all.

@ashleyfae
Copy link
Contributor

My first thought is that it's out of scope for BerlinDB and is better implemented separately, such as via integrating with wp-background-processing or Gearman etc. Click a button, that fires off a background task, and the callback of that task uses BerlinDB. But the actual part that makes it asynchronous isn't BerlinDB itself.

But if you feel otherwise then I'd love to hear the reasoning.

@alexstandiford
Copy link
Collaborator Author

alexstandiford commented Jul 2, 2020

Well, I suppose the thought that crossed my mind was that there could be another argument on query actions (delete, add_item) that could basically say “do this action asynchronously”. It would gather up all the async tasks, and do them in a separate thread, perhaps it’s fired on php shutdown.

I don’t think it would be intended to be a be-all-end-all solution to async, not at all. I do think it could provide a down-and-dirty, accessible way to make Berlin run faster on some implementations.

I’m definitely on the fence, but I also lean toward “out of scope”. I’m pretty inexperienced with async php, so I don’t fully understand the nuance well enough to get the implications I’m making.

@alexstandiford
Copy link
Collaborator Author

I figured it could work via wp_remote_post with async set to true. A button in an interface, and using Jacascript to do this makes sense but it’s not always possible to do it that way - sometimes I want the data to be adapted in the background during a typical request.

@JJJ
Copy link
Collaborator

JJJ commented Jul 28, 2020

WordPress doesn't make it easy to implement asynchronicity, due to everything being completely dependent on the HTTP request.

There are a few different ways of doing async in PHP these days, but I wouldn't call it popular or easy. This will likely require a lot of work.

Berlin will theoretically be more easily adapted into an asynchronous framework once #39 happens.

Tend to agree that it's somewhat out of scope for core Berlin, but all of the core code should at least be async-friendly as we go!

@alexstandiford
Copy link
Collaborator Author

Yep, okay I'm in on that. Even if we build something in, it may prevent other async systems from working properly.

Okay, I'm going to go ahead and close this.

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

No branches or pull requests

3 participants