Commit 1704d2e
Improve schedule() API and fix bugs
This commit enhances the existing schedule() method and fixes critical bugs:
Bug fixes:
- Fixed promise ID pattern to include function name (was missing)
- Fixed resonate:invoke tag to use function name instead of opts.target
- Pattern is now: `{scheduleId}.{{.timestamp}}.{functionName}`
Enhancements:
- Added schedule() method to ResonateFunc interface
- Registered functions can now call .schedule() directly
- Comprehensive documentation with examples
- Example script demonstrating all usage patterns
Examples:
// On Resonate class
await resonate.schedule("daily", "0 9 * * *", myFunc, arg1);
// On registered function
const func = resonate.register("myFunc", async (ctx, x) => x);
await func.schedule("daily", "0 9 * * *", arg1);
// With options
await resonate
.options({ timeout: 3600000, tags: { env: "prod" } })
.schedule("sync", "*/30 * * * *", syncFunc);
The implementation now matches the Python SDK's pattern and provides
a consistent developer experience across both SDKs.
Related:
- TypeScript issue: #435
- Python SDK PR: resonatehq/resonate-sdk-py#397
- Python SDK issue: resonatehq/resonate-sdk-py#328
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 66473a2 commit 1704d2e
2 files changed
Lines changed: 137 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
441 | 442 | | |
442 | 443 | | |
443 | 444 | | |
| 445 | + | |
| 446 | + | |
444 | 447 | | |
445 | 448 | | |
446 | 449 | | |
| |||
720 | 723 | | |
721 | 724 | | |
722 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
723 | 778 | | |
724 | 779 | | |
725 | 780 | | |
| |||
741 | 796 | | |
742 | 797 | | |
743 | 798 | | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
744 | 802 | | |
745 | 803 | | |
746 | 804 | | |
747 | | - | |
| 805 | + | |
748 | 806 | | |
749 | | - | |
| 807 | + | |
750 | 808 | | |
751 | 809 | | |
752 | 810 | | |
753 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
754 | 815 | | |
755 | 816 | | |
756 | | - | |
| 817 | + | |
757 | 818 | | |
758 | 819 | | |
759 | 820 | | |
| |||
0 commit comments