Skip to content

Instantly share code, notes, and snippets.

@gunzip
Last active September 28, 2017 11:30
Show Gist options
  • Save gunzip/8905e35fd6345654a8d71e727ef3e976 to your computer and use it in GitHub Desktop.
Save gunzip/8905e35fd6345654a8d71e727ef3e976 to your computer and use it in GitHub Desktop.
azure queue defer
const failCb = (ctx: IContextWithBindings, error: string) => ctx.done(error);
export function index(context: IContextWithBindings): void {
const fail = (ctx: IContextWithBindings, error: string, timeOut: number) =>
setTimeout(failCb, timeOut, ctx, error);
const timeout = Math.pow(2, context.bindingData.dequeueCount) * 1000;
context.log("sleeping:" + timeout);
fail(context, "error", timeout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment