Skip to content

Commit 7cc4cf7

Browse files
authored
Update README.md
1 parent 268abd9 commit 7cc4cf7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ the caller.
5555
1. For anything bigger it runs parallel map, but does it asynchronously and sends a response when it
5656
it done with the work.
5757

58+
The idea behind this is simple: If the result is going to be calculatable quicly, then I'll wait for it.
59+
Otherwise notifiy me when the result is ready.
60+
61+
For example, you have a website that does some calculation for the user. If the calculation result is
62+
obtainable quickly, then just do it and return it to the user. If it looks like it is going to take a while,
63+
then tell the user "please check back in a few seconds" - or better yet, send them a message via websockets
64+
when the result is ready.
65+
66+
This same technique works for things like processing queues. If nothing is ahead of your task in a queue,
67+
then you can run it immediately. If the queue is long, then tell the user to check back later. This is actually
68+
how the Logger works. You don't want your code to slow down, just because the disk is temporarily slow, but most
69+
of the time you would like to know that the logger completed your task.
70+
71+
5872
Waiting for the delayed result is accomplished by waiting for a message from
5973
the <b>pid</b>.
6074

0 commit comments

Comments
 (0)