getting a head start on a long post-commit task

Kelvin Jarrett laff2deth at yahoo.com
Thu Apr 12 20:16:00 EDT 2012


I want to store large images in Riak.

As soon as Riak has saved the entire blob, I want to use a post-commit hook to create thumbnails of various sizes.

I plan to show the mobile user a progress bar that will advance during the upload, and continue even after the last byte has entered the cluster, while the nodes are approaching quorum.

To the clients, a progress bar at 100% will indicate a safely completed upload. To other developers, a progress bar at 100% will indicate that all background tasks are complete and the mobile client can disconnect from the service.

It occurs to me that I might be able to start some downsampling immediately after the first copy of the image has been written into the cluster. I could shoot a small thumbnail back into the client before I move the progress bar to 100%.

The wiki [0] seems clear on the subject: "API & Behavior  ...  Hook functions must accept a single argument, the riak_object instance just written."

It seems that the post-commit action can only start on a fully-qualified Riak object, which would be available only after all n copies of the image have been distributed and verified as written.

Is there a sensible way to short-circuit this process within Riak? Is starting early on post-commit work a reckless idea?

Many thanks.

KJ

[0] wiki.basho.com/Commit-Hooks.html





More information about the riak-users mailing list