3 ms·
When enqueuing an execution, you get back a unique ID referencing it. We will make that clearer in our documentation, thanks.
by gearnode 4y ago
When enqueuing an execution, you get back a unique ID referencing it. We will make that clearer in our documentation, thanks.
- johtso 4y agoOften you want to specify your own unique id based on some property of the job, like a transaction reference, or just a unique combination of parameters. This means you can later refer to it without having to store the reference somewhere. Is this possible?
- gearnode 4y agoWe specify our unique ID based on KSUID specifications. In addition, we are soon releasing the tag feature, which will enable you to store your references on your Defer executions to identify them your way.
- johtso 4y agoJust ideally the dev experience should be `result = await somethingThatMayHaveBeenCalledBefore(id=txnref, params)` You shouldn't need to first do a check to see if the task already exists using a different api, and then choose whether or not to run a new task. At least this is my preference.. a-la Durable Objects. If you don't specify a custom unique id when calling the task it would then be treated as a task that can (and would make sense to be) run multiple times (i.e. not idempotent).
- gearnode 4y agoCompletely agree with you on the importance of idempotency. We will release our implementation shortly with a pattern close to the following: ``` const somethingThatMayHaveBeenCalledBefore = idempotent(myFunc, txnref); const result = await somethingThatMayHaveBeenCalledBefore(params); ```