1import{j as e,am as j,T as o,an as b,aw as W,e as M,c as z,S as R,B as C,ax as J}from"./index-CqmYRcVu.js";import{L as r}from"./Layout-BYL344x5.js";import{C as $}from"./CodeBlock-CL0V1uES.js";import{C as Q}from"./Codetab-NxNmhPQj.js";import{s as x}from"./use-cases.module-CgCBBWPE.js";const Z="_wrapper_87xsg_1",ee="_flowRoot_87xsg_7",se="_stage_87xsg_11",ae="_caption_87xsg_15",te="_chromeStroke_87xsg_22",ne="_chromeDash_87xsg_26",ce="_chromeDashRect_87xsg_31",re="_chromeTick_87xsg_35",oe="_chromeMajorTick_87xsg_39",le="_chromeFill_87xsg_43",ie="_histCells_87xsg_48",de="_histAccent_87xsg_52",he="_histAccentGreen_87xsg_57",ue="_stageLabel_87xsg_64",xe="_anchorLeft_87xsg_77",me="_labelMuted_87xsg_81",_e="_cursorLine_87xsg_87",pe="_nowTag_87xsg_93",je="_square_87xsg_106",ge="_record_87xsg_136",ye="_residue_87xsg_162",fe="_workerBox_87xsg_169",c={wrapper:Z,flowRoot:ee,stage:se,caption:ae,chromeStroke:te,chromeDash:ne,chromeDashRect:ce,chromeTick:re,chromeMajorTick:oe,chromeFill:le,histCells:ie,histAccent:de,histAccentGreen:he,stageLabel:ue,anchorLeft:xe,labelMuted:me,cursorLine:_e,nowTag:pe,square:je,record:ge,residue:ye,workerBox:fe},q=320,Y=204,h=70,m=50,u=130,_=264,Ne=26,be=14,ve=20,Re=4,we=[[40,"12:00"],[152,"12:30"],[264,"13:00"]],g=36,A=296,w=600,T=15e3,Le=s=>g+(s-w)/T*(A-g),Ce=s=>w+(s-g)/(A-g)*T,i={x:16,y:152,w:174,h:40},N=6.5,Se=9.5,ke=17,Ee=26,Ae=[{y:169,fillP:.6},{y:179,fillP:.34}],L=(()=>{const s=W("schedule-history"),t=["","",""];let l="",n="";const d=[];for(const p of Ae)for(let v=0;v<ke;v++){const B=Ee+v*Se;if(s()>=p.fillP){d.push({x:B+N/2,y:p.y+N/2});continue}const D=`M${B} ${p.y}h${N}v${N}h-${N}z`,G=s();if(G<.05)l+=D;else if(G<.09)n+=D;else{const P=s();t[P<.32?0:P<.72?1:2]+=D}}return{fg:t,blue:l,green:n,gaps:d}})(),Te=[.3,.48,.68],S=N/5,De=650,H=140,K=420,Me=5,V=350,$e=480,Ie=W("schedule-timing"),f=[{x:124,post:900},{x:234,post:1800},{x:178,post:4600}].map((s,t)=>{const l=Math.max(g,Le(s.post)),n=Math.round(Ce(s.x)),d=n+H+K+Math.max(260,(_-s.x)*Me),p=d+Math.round(1100+Ie()*300),v=Math.round(t*(L.gaps.length-1)/2);return{...s,origin:l,fire:n,land:s.post+De,arrive:d,procEnd:p,storeAt:p+V+$e,cell:L.gaps[v]}}),Oe=Math.max(...f.map(s=>s.storeAt)),y=Math.ceil((Oe+1900)/100)*100,He=Math.round((f[0].arrive+f[0].procEnd)/2),Be=(s,t)=>{const l=Math.min(s.storeAt+1500,y-360);return b(`payload-${t}`,[{t:s.post,x:s.origin,y:62,opacity:0,scale:.6,state:"posting"},{t:s.post+140,x:s.origin+6,y:54,opacity:1,scale:1,ease:"linear"},{t:s.post+400,x:(s.origin+s.x)/2,y:28,ease:"linear"},{t:s.land,x:s.x,y:m,ease:"out",state:"scheduled"},{t:s.fire,x:s.x,y:m,ease:"hold",state:"fired"},{t:s.fire+H,x:s.x,y:m,ease:"hold"},{t:s.fire+H+K,x:s.x,y:u,ease:"in"},{t:s.arrive,x:_,y:u,ease:"inOut",state:"active"},{t:s.procEnd,x:_,y:u,ease:"hold",state:"done"},{t:s.procEnd+V,x:_,y:u,ease:"hold"},{t:s.storeAt,x:s.cell.x,y:s.cell.y,scale:S,ease:"inOut",state:"stored"},{t:l,x:s.cell.x,y:s.cell.y,scale:S,ease:"hold",state:"settled"},{t:y-320,x:s.cell.x,y:s.cell.y,scale:S,ease:"hold"},{t:y,x:s.cell.x,y:s.cell.y,scale:S,opacity:0,ease:"linear"}])},Ge=(s,t)=>b(`record-${t}`,[{t:s.land-40,x:s.x,y:m,opacity:0,scale:.5,state:"record"},{t:s.land+60,x:s.x,y:m,opacity:1,scale:1.12,ease:"out"},{t:s.land+240,x:s.x,y:m,scale:1,ease:"inOut"},{t:s.fire,x:s.x,y:m,ease:"hold",state:"firing"},{t:s.fire+700,x:s.x,y:m,ease:"hold"},{t:s.fire+1e3,x:s.x,y:m,opacity:0,ease:"linear"}]),Pe=(s,t)=>b(`residue-${t}`,[{t:s.fire+250,x:s.x,y:h,opacity:0,state:"residue"},{t:s.fire+550,x:s.x,y:h,opacity:1,ease:"linear"},{t:y-500,x:s.x,y:h,ease:"hold"},{t:y,x:s.x,y:h,opacity:0,ease:"linear"}]),Fe=f.map(Be),Ue=f.map(Ge),We=f.map(Pe),X=s=>[{t:0,x:g,y:s,opacity:0},{t:200,x:g,y:s,opacity:0,ease:"hold"},{t:w,x:g,y:s,opacity:1,ease:"linear"},{t:w+T,x:A,y:s,ease:"linear"},{t:w+T+500,x:A,y:s,opacity:0,ease:"linear"}],qe=b("cursor-line",X(57)),Ye=b("cursor-tag",X(26)),Ke=b("worker",[{t:0,x:_,y:u,state:"idle"},...[...f].sort((s,t)=>s.arrive-t.arrive).flatMap(s=>[{t:s.arrive,x:_,y:u,state:"busy",ease:"hold"},{t:s.procEnd,x:_,y:u,state:"idle",ease:"hold"}]),{t:y,x:_,y:u,ease:"hold"}]),F={fill:"none",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"},I={fill:"none",strokeWidth:1,vectorEffect:"non-scaling-stroke"},Ve=()=>e.jsxs("svg",{viewBox:`0 0 ${q} ${Y}`,"aria-hidden":"true",children:[e.jsx("rect",{x:12.5,y:h-1.5,width:3,height:3,className:c.chromeFill}),e.jsx("line",{x1:14,y1:h,x2:299,y2:h,className:c.chromeStroke,...F}),e.jsx("path",{d:`M 296.5 ${h-4} L 302 ${h} L 296.5 ${h+4}`,className:c.chromeStroke,...F}),Array.from({length:ve},(s,t)=>{const l=Ne+t*be,n=t%Re===1,d=n?3.5:2;return e.jsx("line",{x1:l,y1:h-d,x2:l,y2:h+d,className:n?c.chromeMajorTick:c.chromeTick,...I},t)}),e.jsx("line",{x1:112,y1:u,x2:238,y2:u,className:c.chromeDash,...I}),e.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,className:c.chromeDashRect,...I,strokeDasharray:"2 3"}),[[i.x,i.y],[i.x+i.w,i.y],[i.x,i.y+i.h],[i.x+i.w,i.y+i.h]].map(([s,t])=>e.jsx("rect",{x:s-1.5,y:t-1.5,width:3,height:3,className:c.chromeFill},`${s}-${t}`)),L.fg.map((s,t)=>e.jsx("path",{d:s,className:c.histCells,fillOpacity:Te[t]},t)),e.jsx("path",{d:L.blue,className:c.histAccent}),e.jsx("path",{d:L.green,className:c.histAccentGreen})]}),k=({x:s,y:t,anchor:l="center",muted:n=!1,children:d})=>e.jsx("div",{className:`${c.stageLabel} ${l==="left"?c.anchorLeft:""} ${n?c.labelMuted:""}`,style:{left:`calc(var(--flow-u) * ${s})`,top:`calc(var(--flow-u) * ${t})`},children:d}),Xe="Schedule a run for any point in the future.",ze="Animated diagram of future scheduling in Hatchet: runs are posted onto a timeline at future trigger times, wait as durable schedule entries while a NOW cursor advances, then fire into a worker exactly when their time arrives and settle into run history.",Je=({style:s})=>e.jsxs("div",{className:c.wrapper,style:s,children:[e.jsx(j.Root,{duration:y,posterTime:He,className:c.flowRoot,"aria-label":ze,children:e.jsxs(j.Stage,{width:q,height:Y,className:c.stage,children:[e.jsx(Ve,{}),e.jsx(k,{x:16,y:6,anchor:"left",children:"schedules · durable"}),we.map(([t,l])=>e.jsx(k,{x:t,y:78,muted:!0,children:l},t)),e.jsx(k,{x:_,y:108,children:"worker"}),e.jsx(k,{x:24,y:157,anchor:"left",muted:!0,children:"completed runs"}),e.jsx(j.Token,{track:Ke,children:e.jsx("div",{className:c.workerBox})}),e.jsx(j.Token,{track:qe,children:e.jsx("div",{className:c.cursorLine})}),e.jsx(j.Token,{track:Ye,children:e.jsx("div",{className:c.nowTag,children:"now"})}),Ue.map(t=>e.jsx(j.Token,{track:t,children:e.jsx("div",{className:c.record})},t.id)),We.map(t=>e.jsx(j.Token,{track:t,children:e.jsx("div",{className:c.residue})},t.id)),Fe.map(t=>e.jsx(j.Token,{track:t,children:e.jsx("div",{className:c.square})},t.id))]})}),e.jsx(o.Small,{as:"p",secondary:!0,balance:!0,className:`${c.caption} max-w-5`,children:Xe})]}),Qe="_wrap_1is7c_11",Ze="_frame_1is7c_18",es="_sequenceRoot_1is7c_26",ss="_caption_1is7c_30",as="_panel_1is7c_7",ts="_header_1is7c_53",ns="_title_1is7c_61",cs="_createBtn_1is7c_68",rs="_band_1is7c_80",os="_bandLabel_1is7c_91",ls="_bandCount_1is7c_99",is="_cronGrid_1is7c_111",ds="_colHead_1is7c_124",hs="_colLabel_1is7c_129",us="_cronRow_1is7c_141",xs="_nameCell_1is7c_151",ms="_statusDot_1is7c_159",_s="_name_1is7c_151",ps="_value_1is7c_174",js="_nextRun_1is7c_180",gs="_nextRunValue_1is7c_190",ys="_nextRunEmpty_1is7c_195",fs="_recent_1is7c_201",Ns="_runDot_1is7c_208",bs="_toggle_1is7c_236",vs="_knob_1is7c_246",Rs="_schedRow_1is7c_294",ws="_schedGrid_1is7c_309",Ls="_schedDot_1is7c_321",Cs="_trash_1is7c_327",Ss="_trashSvg_1is7c_335",ks="_cursorLayer_1is7c_369",Es="_cursor_1is7c_369",As="_cursorArrow_1is7c_407",Ts="_cursorSvg_1is7c_434",a={wrap:Qe,frame:Ze,sequenceRoot:es,caption:ss,panel:as,header:ts,title:ns,createBtn:cs,band:rs,bandLabel:os,bandCount:ls,cronGrid:is,colHead:ds,colLabel:hs,cronRow:us,nameCell:xs,statusDot:ms,name:_s,value:ps,nextRun:js,nextRunValue:gs,nextRunEmpty:ys,recent:fs,runDot:Ns,toggle:bs,knob:vs,schedRow:Rs,schedGrid:ws,schedDot:Ls,trash:Cs,trashSvg:Ss,cursorLayer:ks,cursor:Es,cursorArrow:As,cursorSvg:Ts},Ds=[{value:"steady",duration:2600},{value:"aim-off",duration:1100},{value:"off",duration:3e3},{value:"aim-del",duration:1100},{value:"deleted",duration:2800},{value:"aim-on",duration:1100},{value:"on",duration:2600}],Ms=new Set(["off","aim-del","deleted","aim-on"]),$s=new Set(["deleted","aim-on","on"]),U=[{name:"report-customer-a",expression:"0 12 * * *",nextRun:"Aug 10, 12:00 PM",pingDelay:"0s"},{name:"report-customer-b",expression:"0 12 * * *",nextRun:"Aug 10, 12:00 PM",target:!0,pingDelay:"0.9s"},{name:"sync-usage-metrics",expression:"*/15 * * * *",nextRun:"Aug 10, 9:15 AM",pingDelay:"1.8s"}],O=[{name:"reindex-search",runAt:"Aug 12, 2:00 AM"},{name:"backfill-invoices",runAt:"Aug 15, 6:00 AM",target:!0}],Is=()=>e.jsxs("svg",{className:a.cursorSvg,viewBox:"0 0 25 32",fill:"none","aria-hidden":"true",children:[e.jsx("path",{fill:"#fff",d:"M4.398 28.68C3.13 29.916 1 29.02 1 27.248V4.829c0-1.782 2.154-2.675 3.414-1.415l16.372 16.372c1.26 1.26.367 3.414-1.414 3.414H10.6l-.8.2z"}),e.jsx("path",{stroke:"#000",strokeOpacity:".12",d:"M.508 4.623c.16-2.089 2.734-3.088 4.26-1.562L21.14 19.433c1.5
174 1.575.458 4.267-1.769 4.267h-8.708l-.61.152-5.306 5.185C3.164 30.584.5 29.462.5 27.25V4.829z"}),e.jsx("path",{fill:"#000",d:"M3 4.8v22.4l6-5.8.8-.2h9.6z"})]}),Os=()=>e.jsx("svg",{className:a.trashSvg,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 4.25h10.5M6.25 4.25V3a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 .75.75v1.25M4.25 4.25l.63 8.42a1 1 0 0 0 1 .93h4.24a1 1 0 0 0 1-.93l.63-8.42M6.6 6.9v3.9M9.4 6.9v3.9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),Hs=[0,1,2,3,4],Bs=({beat:s})=>{const t=Ms.has(s),l=$s.has(s);return e.jsxs("div",{className:a.panel,"data-beat":s,children:[e.jsxs("div",{className:a.header,children:[e.jsx("span",{className:a.title,children:"Triggers"}),e.jsx("span",{className:a.createBtn,children:"+ New cron"})]}),e.jsxs("div",{className:a.band,children:[e.jsx("span",{className:a.bandLabel,children:"Cron jobs"}),e.jsx("span",{className:a.bandCount,children:U.length})]}),e.jsxs("div",{className:`${a.cronGrid} ${a.colHead}`,children:[e.jsx("span",{className:a.colLabel,children:"Name"}),e.jsx("span",{className:a.colLabel,children:"Expression"}),e.jsx("span",{className:a.colLabel,children:"Next run"}),e.jsx("span",{className:a.colLabel,children:"Recent"}),e.jsx("span",{})]}),U.map(n=>{const d=n.target?!t:!0;return e.jsxs("div",{className:`${a.cronGrid} ${a.cronRow}`,"data-target":n.target||void 0,"data-enabled":d,style:{"--ping-delay":n.pingDelay},children:[e.jsxs("span",{className:a.nameCell,children:[e.jsx("span",{className:a.statusDot}),e.jsx("span",{className:a.name,children:n.name})]}),e.jsx("span",{className:a.value,children:n.expression}),e.jsxs("span",{className:a.nextRun,children:[e.jsx("span",{className:a.nextRunValue,children:n.nextRun}),e.jsx("span",{className:a.nextRunEmpty,children:"â"})]}),e.jsx("span",{className:a.recent,children:Hs.map(p=>e.jsx("span",{className:a.runDot},p))}),e.jsx("span",{className:a.toggle,children:e.jsx("span",{className:a.knob})})]},n.name)}),e.jsxs("div",{className:a.band,children:[e.jsx("span",{className:a.bandLabel,children:"Scheduled runs"}),e.jsx("span",{className:a.bandCount,children:l?O.length-1:O.length})]}),O.map(n=>e.jsx("div",{className:a.schedRow,"data-target":n.target||void 0,"data-deleted":n.target?l:!1,children:e.jsxs("div",{className:a.schedGrid,children:[e.jsxs("span",{className:a.nameCell,children:[e.jsx("span",{className:`${a.statusDot} ${a.schedDot}`}),e.jsx("span",{className:a.name,children:n.name})]}),e.jsx("span",{className:a.value,children:n.runAt}),e.jsx("span",{className:a.trash,children:e.jsx(Os,{})})]})},n.name)),e.jsx("div",{className:a.cursorLayer,children:e.jsx("div",{className:a.cursor,children:e.jsx("span",{className:a.cursorArrow,children:e.jsx(Is,{})})})})]})},Gs=({style:s})=>e.jsxs("div",{className:a.wrap,style:s,children:[e.jsx("div",{className:a.frame,"aria-hidden":"true",children:e.jsxs(M.Root,{loop:!0,autoPlay:!0,additiveCrossfade:!1,defaultTransition:200,className:a.sequenceRoot,children:[Ds.map(t=>e.jsx(M.Scene,{value:t.value,duration:t.duration,children:null},t.value)),e.jsx(M.Persistent,{children:({value:t})=>e.jsx(Bs,{beat:t})})]})}),e.jsx(o.Small,{as:"p",secondary:!0,balance:!0,className:`${a.caption} max-w-5`,children:"Pause, resume, or delete any cron or schedule from the dashboard."})]}),E=J("use-case","cron-jobs");function Ys(){const{redirectUrls:{register:s}}=z();return e.jsxs(e.Fragment,{children:[e.jsxs(R,{theme:"dark",className:x.hero,children:[e.jsx(o.Micro,{brackets:!0,mono:!0,caps:!0,style:{color:"var(--accent-1)"},children:"Use Case"}),e.jsx(o.H1,{balance:!0,children:"Cron jobs and scheduling"}),e.jsx(o.Body,{secondary:!0,balance:!0,className:x.heroDescription,children:"Hatchet ships with all of the scheduling features you need to run at scale."}),e.jsxs(r.Gap,{dir:"x",gap:2,children:[e.jsx(C,{href:s,target:"_blank",children:"Get started"}),e.jsx(C,{type:"secondary",href:E("https://docs.hatchet.run/v1/cron-runs"),target:"_blank",icon:"docs",children:"Read the docs"})]})]}),e.jsx(R,{theme:"dark",className:x.feature,children:e.jsxs(r,{layout:"grid",gap:4,children:[e.jsx(r.Child,{span:"half",className:x.alignCenter,children:e.jsxs(r.Gap,{gap:2,children:[e.jsx(o.Micro,{brackets:!0,mono:!0,caps:!0,style:{color:"var(--accent-1)"},children:"Feature"}),e.jsx(o.H3,{children:"Dynamic cron jobs"}),e.jsxs(o.Body,{balance:!0,className:"max-w-5",children:["Each Hatchet SDK comes with a"," ",e.jsx("a",{href:E("https://docs.hatchet.run/v1/cron-runs"),children:"cron client"}),", allowing you to dynamically register cron schedules. For example, you can register a separate cron schedule per organization, tenant or user."]})]})}),e.jsx(r.Child,{span:"half",children:e.jsx(Q,{filename:"dynamic-crons",languages:{python:e.jsx($,{code:`# Register crons dynamically â thousands, even 2cron = await report_wf.aio_create_cron( 3 cron_name=f"report-{customer.id}", 4 expression="0 12 * * *", 5 input=ReportInput(customer_id=customer.id), 6) 7 8# List and clean up from the same client 9await hatchet.cron.aio_list() 10await hatchet.cron.aio_delete( 11 cron_id=cron.metadata.id 12)`,lang:"python",showLineNumbers:!0}),typescript:e.jsx($,{code:`// Register crons dynamically â thousands, even 13const cron = await hatchet.crons.create( 14 'generate-report', 15 { 16 name: \`report-\${customer.id}\`, 17 expression: '0 12 * * *', 18 input: { customerId: customer.id }, 19 } 20); 21 22// List and clean up from the same client 23await hatchet.crons.list({ 24 workflow: 'generate-report', 25}); 26await hatchet.crons.delete(cron.metadata.id);`,lang:"typescript",showLineNumbers:!0}),go:e.jsx($,{code:`// Register crons dynamically â thousands, even 27cron, err := client.Crons().Create( 28 ctx, "generate-report", 29 features.CreateCronTrigger{ 30 Name: "report-" + customer.ID, 31 Expression: "0 12 * * *", 32 Input: customer.ReportInput(), 33 }) 34 35// Clean up from the same client 36err = client.Crons().Delete( 37 ctx, cron.Metadata.Id, 38)`,lang:"go",showLineNumbers:!0})}})})]})}),e.jsx(R,{theme:"dark",className:x.feature,children:e.jsxs(r,{layout:"x",gap:4,children:[e.jsx(r.Child,{span:"half",className:x.alignCenter,children:e.jsxs(r.Gap,{gap:2,children:[e.jsx(o.Micro,{brackets:!0,mono:!0,caps:!0,style:{color:"var(--accent-1)"},children:"Feature"}),e.jsx(o.H3,{balance:!0,children:"Reliable future scheduling"}),e.jsxs(o.Body,{balance:!0,className:"max-w-5",children:["You can"," ",e.jsx("a",{href:E("https://docs.hatchet.run/v1/scheduled-runs"),children:"schedule runs"})," ","for any point in the future. Like the rest of Hatchet, schedules are durable, so theyâre guaranteed to run after you post them to Hatchet."]})]})}),e.jsx(r.Child,{span:"half",children:e.jsx(Je,{})})]})}),e.jsx(R,{theme:"dark",className:x.feature,children:e.jsxs(r,{layout:"x",gap:4,children:[e.jsx(r.Child,{span:"half",className:x.alignCenter,children:e.jsxs(r.Gap,{gap:2,children:[e.jsx(o.Micro,{brackets:!0,mono:!0,caps:!0,style:{color:"var(--accent-1)"},children:"Feature"}),e.jsx(o.H3,{balance:!0,children:"Admin control"}),e.jsxs(o.Body,{balance:!0,className:"max-w-5",children:["Enable or disable crons, delete schedules, and manage runs, all from the"," ",e.jsx("a",{href:E("https://docs.hatchet.run/v1/cron-runs#managing-cron-jobs-in-the-hatchet-dashboard"),
38children:"Hatchet UI"}),"."]})]})}),e.jsx(r.Child,{span:"half",children:e.jsx(Gs,{})})]})}),e.jsx(R,{theme:"light",className:`${x.ctaSection} py-6 pb-8`,children:e.jsxs(r,{children:[e.jsx(r.Child,{children:e.jsx(r.Gap,{children:e.jsxs(o.H3,{balance:!0,children:["Run your cron jobs on Hatchet."," ",e.jsx(o,{secondary:!0,children:"Reliable scheduling that scales with you."})]})})}),e.jsx(r.Child,{children:e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx(o.Body,{secondary:!0,balance:!0,children:"Start for free â no credit card required"})}),e.jsx("li",{children:e.jsx(o.Body,{secondary:!0,balance:!0,children:"Processing over 100 million tasks/day on Hatchet Cloud"})}),e.jsx("li",{children:e.jsx(o.Body,{secondary:!0,balance:!0,children:"Open-source and self-hostable"})})]})}),e.jsx(r.Child,{children:e.jsxs(r.Gap,{gap:2,dir:"x",children:[e.jsx(C,{href:s,target:"_blank",children:"Start for free"}),e.jsx(C,{type:"secondary",href:"https://cal.com/team/hatchet/talk-to-us",target:"_blank",rel:"noreferrer",children:"Talk to us"})]})})]})})]})}export{Ys as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.