gemi 0.222.1 → 0.223.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +1 -1
- package/dist/{chunk-ejvjn9tq.js → chunk-fn166jp3.js} +1 -1
- package/dist/{chunk-nqjchwdj.js → chunk-ke1q6hfm.js} +1 -1
- package/dist/chunk-p1ern8r4.js +577 -0
- package/dist/chunk-p1ern8r4.js.map +27 -0
- package/dist/{chunk-y8dpexn0.js → chunk-qtczhd81.js} +2 -2
- package/dist/{chunk-y8dpexn0.js.map → chunk-qtczhd81.js.map} +1 -1
- package/dist/{chunk-t7ppe7gt.js → chunk-qvxs1vjh.js} +1 -1
- package/dist/{chunk-dy01vy29.js → chunk-rw45xz3f.js} +3 -3
- package/dist/{chunk-dy01vy29.js.map → chunk-rw45xz3f.js.map} +3 -3
- package/dist/{chunk-qvspq5tm.js → chunk-sqyf0gey.js} +1 -1
- package/dist/console/run.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/queue/DatabaseQueueDriver.d.ts +16 -0
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/DatabaseSlots.d.ts +100 -0
- package/dist/services/queue/DatabaseSlots.d.ts.map +1 -0
- package/dist/services/queue/Job.d.ts +20 -3
- package/dist/services/queue/Job.d.ts.map +1 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts +11 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueDriver.d.ts +24 -0
- package/dist/services/queue/QueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueManager.d.ts +28 -8
- package/dist/services/queue/QueueManager.d.ts.map +1 -1
- package/dist/services/queue/slots.d.ts +111 -0
- package/dist/services/queue/slots.d.ts.map +1 -0
- package/dist/services/queue/work.js +1 -1
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +2 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/Workflow.d.ts +16 -0
- package/dist/services/queue/workflow/Workflow.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts +10 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-9kdqdjdf.js +0 -521
- package/dist/chunk-9kdqdjdf.js.map +0 -25
- /package/dist/{chunk-ejvjn9tq.js.map → chunk-fn166jp3.js.map} +0 -0
- /package/dist/{chunk-nqjchwdj.js.map → chunk-ke1q6hfm.js.map} +0 -0
- /package/dist/{chunk-t7ppe7gt.js.map → chunk-qvxs1vjh.js.map} +0 -0
- /package/dist/{chunk-qvspq5tm.js.map → chunk-sqyf0gey.js.map} +0 -0
package/dist/services/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rb as J$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-ejvjn9tq.js";import{kc as d4}from"../chunk-t7ppe7gt.js";import"../chunk-kp7wcpx7.js";import{be as D9,ce as H9,de as N9,ee as U9,fe as x9,ge as R9,he as O9,ie as _9,je as V9,ke as k9,le as C9,me as T9,ne as P9,oe as b9,pe as w9,qe as q9}from"../chunk-dy01vy29.js";import{re as S9}from"../chunk-7xe5vd4w.js";import{Ae as oZ,Be as aZ,Ce as tZ,De as rZ,Ee as eZ,Fe as W9,Ge as Z9,He as $9,Ie as Q9,Je as Y9,Ke as K9,Pe as J9,se as cZ,te as uZ,ue as pZ,ve as dZ,we as lZ,xe as nZ,ye as iZ,ze as sZ}from"../chunk-9kdqdjdf.js";import{Qe as h9,Re as E9}from"../chunk-vcw98sp6.js";import"../chunk-qy0k2s5f.js";import{$e as W8,Af as Y6,Ag as DZ,Ah as yZ,Bf as M8,Bg as HZ,Bh as AZ,Cf as F8,Cg as NZ,Df as L8,Dg as UZ,Ef as D8,Ff as H8,Ig as R,Jg as i,Kg as xZ,Lg as SZ,Mg as RZ,Ng as OZ,Og as _Z,Qg as VZ,Rg as kZ,Sg as CZ,Tg as TZ,Uf as T8,Vf as P8,Vg as PZ,Wf as b8,Xf as w8,Yf as q8,Yg as bZ,Ze as V6,Zf as v8,Zg as wZ,_e as e5,_g as qZ,af as Z8,bh as vZ,cf as $8,eg as e8,fg as q6,gf as k6,gg as WZ,gh as IZ,hf as C4,if as B6,jf as T4,kf as P4,kg as ZZ,kh as fZ,lg as $Z,mg as YZ,of as f6,oh as i4,pf as y6,pg as KZ,ph as z1,qg as JZ,rf as Q8,rg as zZ,sf as Y8,sg as GZ,tf as K8,uf as J8,ug as XZ,vf as z8,vg as BZ,wf as G8,wg as jZ,xf as X8,xg as MZ,yf as B8,yg as FZ,zf as j8,zg as LZ}from"../chunk-bs4p7dys.js";import"../chunk-j9abwrkv.js";import"../chunk-4v5nwqw6.js";import{$i as U8,Ni as h4,Ri as j1,Ti as Y1,Xi as _4,Yi as C1,Zi as p1,_i as N8,aj as x8,bj as S8,cj as R8,oj as mW,pj as cW,sj as O8,ti as k4,tj as _8,ui as O4,vi as k1,vj as V8,wj as k8,xj as C8,zj as d1}from"../chunk-8gnbc9dg.js";import"../chunk-h1wmpa03.js";import{Fj as q}from"../chunk-t586p2g2.js";import"../chunk-qs2xvc8g.js";import{Rj as g8,Sj as m8,Tj as U,Uj as c8,Vj as b,Wj as u8,Xj as p8}from"../chunk-2y0nr525.js";import{bk as A8,ck as h8,dk as E8}from"../chunk-p4v71qfx.js";import"../chunk-anc5v266.js";import{Mk as QZ}from"../chunk-wy82t7mz.js";import{$k as a8,Ok as I8,Pk as f8,Qk as y8,Rk as d8,Sk as l8,Tk as n8,Uk as i8,Vk as s8,Wk as o8,al as t8,bl as r8}from"../chunk-tac25cnj.js";import"../chunk-0k2r6bep.js";import"../chunk-0av1gyns.js";import"../chunk-zmt5kdpb.js";import"../chunk-rat2827k.js";import{$l as gZ,Yl as w4,Zl as hZ,_l as EZ,bm as mZ}from"../chunk-t8ygf6zj.js";import"../chunk-yj7pbbnm.js";import{lm as C}from"../chunk-37209psn.js";import"../chunk-fqhkkpq3.js";import"../chunk-swmf6w3z.js";import"../chunk-6r7956dh.js";import"../chunk-5mrtgr7q.js";import"../chunk-55btq9c7.js";import{Qm as u1}from"../chunk-3dkv4989.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-nqgeny8m.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
2
|
+
import{rb as J$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-fn166jp3.js";import{kc as d4}from"../chunk-qvxs1vjh.js";import"../chunk-kp7wcpx7.js";import{be as D9,ce as H9,de as N9,ee as U9,fe as x9,ge as R9,he as O9,ie as _9,je as V9,ke as k9,le as C9,me as T9,ne as P9,oe as b9,pe as w9,qe as q9}from"../chunk-rw45xz3f.js";import{re as S9}from"../chunk-7xe5vd4w.js";import{Ae as oZ,Be as aZ,Ce as tZ,De as rZ,Ee as eZ,Fe as W9,Ge as Z9,He as $9,Ie as Q9,Je as Y9,Ke as K9,Pe as J9,se as cZ,te as uZ,ue as pZ,ve as dZ,we as lZ,xe as nZ,ye as iZ,ze as sZ}from"../chunk-p1ern8r4.js";import{Qe as h9,Re as E9}from"../chunk-vcw98sp6.js";import"../chunk-qy0k2s5f.js";import{$e as W8,Af as Y6,Ag as DZ,Ah as yZ,Bf as M8,Bg as HZ,Bh as AZ,Cf as F8,Cg as NZ,Df as L8,Dg as UZ,Ef as D8,Ff as H8,Ig as R,Jg as i,Kg as xZ,Lg as SZ,Mg as RZ,Ng as OZ,Og as _Z,Qg as VZ,Rg as kZ,Sg as CZ,Tg as TZ,Uf as T8,Vf as P8,Vg as PZ,Wf as b8,Xf as w8,Yf as q8,Yg as bZ,Ze as V6,Zf as v8,Zg as wZ,_e as e5,_g as qZ,af as Z8,bh as vZ,cf as $8,eg as e8,fg as q6,gf as k6,gg as WZ,gh as IZ,hf as C4,if as B6,jf as T4,kf as P4,kg as ZZ,kh as fZ,lg as $Z,mg as YZ,of as f6,oh as i4,pf as y6,pg as KZ,ph as z1,qg as JZ,rf as Q8,rg as zZ,sf as Y8,sg as GZ,tf as K8,uf as J8,ug as XZ,vf as z8,vg as BZ,wf as G8,wg as jZ,xf as X8,xg as MZ,yf as B8,yg as FZ,zf as j8,zg as LZ}from"../chunk-bs4p7dys.js";import"../chunk-j9abwrkv.js";import"../chunk-4v5nwqw6.js";import{$i as U8,Ni as h4,Ri as j1,Ti as Y1,Xi as _4,Yi as C1,Zi as p1,_i as N8,aj as x8,bj as S8,cj as R8,oj as mW,pj as cW,sj as O8,ti as k4,tj as _8,ui as O4,vi as k1,vj as V8,wj as k8,xj as C8,zj as d1}from"../chunk-8gnbc9dg.js";import"../chunk-h1wmpa03.js";import{Fj as q}from"../chunk-t586p2g2.js";import"../chunk-qs2xvc8g.js";import{Rj as g8,Sj as m8,Tj as U,Uj as c8,Vj as b,Wj as u8,Xj as p8}from"../chunk-2y0nr525.js";import{bk as A8,ck as h8,dk as E8}from"../chunk-p4v71qfx.js";import"../chunk-anc5v266.js";import{Mk as QZ}from"../chunk-wy82t7mz.js";import{$k as a8,Ok as I8,Pk as f8,Qk as y8,Rk as d8,Sk as l8,Tk as n8,Uk as i8,Vk as s8,Wk as o8,al as t8,bl as r8}from"../chunk-tac25cnj.js";import"../chunk-0k2r6bep.js";import"../chunk-0av1gyns.js";import"../chunk-zmt5kdpb.js";import"../chunk-rat2827k.js";import{$l as gZ,Yl as w4,Zl as hZ,_l as EZ,bm as mZ}from"../chunk-t8ygf6zj.js";import"../chunk-yj7pbbnm.js";import{lm as C}from"../chunk-37209psn.js";import"../chunk-fqhkkpq3.js";import"../chunk-swmf6w3z.js";import"../chunk-6r7956dh.js";import"../chunk-5mrtgr7q.js";import"../chunk-55btq9c7.js";import{Qm as u1}from"../chunk-3dkv4989.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-nqgeny8m.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
3
3
|
local currentKey = KEYS[1]
|
|
4
4
|
local previousKey = KEYS[2]
|
|
5
5
|
local limit = tonumber(ARGV[1])
|
|
@@ -3,6 +3,7 @@ import type { Dialect } from "../../database/dialect";
|
|
|
3
3
|
import { DatabaseLockStore } from "../lock/DatabaseLockStore";
|
|
4
4
|
import { type BatchStatus } from "./batch";
|
|
5
5
|
import type { ClaimOptions, ClaimedJob, EnqueueBatch, EnqueueJob, JobFailure, JobRelease, QueueDriver } from "./QueueDriver";
|
|
6
|
+
import type { SlotRequest } from "./slots";
|
|
6
7
|
import { DatabaseWorkflowStore } from "./workflow/DatabaseWorkflowStore";
|
|
7
8
|
export type DatabaseQueueDriverOptions = {
|
|
8
9
|
/**
|
|
@@ -37,6 +38,12 @@ export type DatabaseQueueDriverOptions = {
|
|
|
37
38
|
* jobs table of another name. Only touched by what uses them.
|
|
38
39
|
*/
|
|
39
40
|
workflowSourceTable?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The table concurrency slots are kept in (#1319). Default
|
|
43
|
+
* `gemi_job_slots`, or `<table>_slots` beside a jobs table of another name.
|
|
44
|
+
* Only touched by jobs and workflows that declare `concurrency`.
|
|
45
|
+
*/
|
|
46
|
+
slotTable?: string;
|
|
40
47
|
/**
|
|
41
48
|
* SQLite only: how long, in milliseconds, a statement waits for another
|
|
42
49
|
* process's write lock before failing with `SQLITE_BUSY`. Default `1000`.
|
|
@@ -123,7 +130,9 @@ export declare class DatabaseQueueDriver implements QueueDriver {
|
|
|
123
130
|
readonly workflowStepTable: string;
|
|
124
131
|
readonly workflowItemTable: string;
|
|
125
132
|
readonly workflowSourceTable: string;
|
|
133
|
+
readonly slotTable: string;
|
|
126
134
|
private workflows;
|
|
135
|
+
private slotLines;
|
|
127
136
|
private readonly sql;
|
|
128
137
|
private readonly dialect;
|
|
129
138
|
/** The connection's name, when it came with one; see `transaction`. */
|
|
@@ -246,6 +255,13 @@ export declare class DatabaseQueueDriver implements QueueDriver {
|
|
|
246
255
|
* step's record and the tick or batch it schedules commit together.
|
|
247
256
|
*/
|
|
248
257
|
workflowStore(): DatabaseWorkflowStore;
|
|
258
|
+
/**
|
|
259
|
+
* Concurrency slots (#1319), in `slotTable`, shared by every process on
|
|
260
|
+
* this database; see `DatabaseSlots`.
|
|
261
|
+
*/
|
|
262
|
+
acquireSlots(request: SlotRequest): Promise<boolean>;
|
|
263
|
+
releaseSlots(holder: string): Promise<void>;
|
|
264
|
+
private slots;
|
|
249
265
|
reportProgress(job: ClaimedJob, progress: number): Promise<void>;
|
|
250
266
|
/**
|
|
251
267
|
* Deletes batches that finished more than `olderThanMs` ago, and resolves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseQueueDriver.d.ts","sourceRoot":"","sources":["../../../services/queue/DatabaseQueueDriver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAIL,KAAK,WAAW,EAQjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":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,CAAC,MAAM,CAAC;IAUxD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAuCnB,yDAAyD;YAC3C,KAAK;IASnB;;;;OAIG;YACW,aAAa;IAU3B,gFAAgF;YAClE,SAAS;IAavB;;;;;OAKG;YACW,SAAS;IAWvB;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU;IAwBlB,uEAAuE;YACzD,KAAK;IAKnB,8EAA8E;IAC9E,OAAO,CAAC,UAAU;IAIlB,8EAA8E;IAC9E,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;YACW,aAAa;IAsC3B;;;;;;;;;;;;;;OAcG;YACW,YAAY;YA6BZ,cAAc;IAgD5B;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAUjB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,QAAQ;IAahB;;;;;OAKG;IACH,OAAO,CAAC,IAAI;IAIZ,iEAAiE;IACjE,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IAKd,mDAAmD;IACnD,OAAO,CAAC,GAAG;IAcX;;;OAGG;IACH,OAAO,CAAC,EAAE;CAMX;AAYD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAiD/E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBnF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA2CpF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { SQL } from "bun";
|
|
2
|
+
import type { Dialect } from "../../database/dialect";
|
|
3
|
+
import type { EnqueueJob } from "./QueueDriver";
|
|
4
|
+
import type { SlotRequest } from "./slots";
|
|
5
|
+
/**
|
|
6
|
+
* Concurrency slots (#1319) in a table of the queue's database, so every
|
|
7
|
+
* process sharing it shares one line per key. The model is in `slots.ts`.
|
|
8
|
+
*
|
|
9
|
+
* ### The table
|
|
10
|
+
*
|
|
11
|
+
* One row per key and holder, keyed by both. The empty holder is the key's
|
|
12
|
+
* **gate** row: every step on a line starts by upserting it, which locks it
|
|
13
|
+
* (a row lock on Postgres and MySQL, the file's write lock on SQLite), so the
|
|
14
|
+
* steps on one key run one at a time across processes, and it keeps the
|
|
15
|
+
* limit the line was last admitted under, for a release that has none. A
|
|
16
|
+
* step on several keys locks their gates in sorted order first, so two steps
|
|
17
|
+
* never wait on each other in a cycle.
|
|
18
|
+
*
|
|
19
|
+
* ### Indexed, all of it
|
|
20
|
+
*
|
|
21
|
+
* Every statement is on `(slot_key, state, queued_at, holder)`, on `(holder)`,
|
|
22
|
+
* or a primary-key lookup, and the counts are `LIMIT`ed to the limit: an
|
|
23
|
+
* admission costs the same with ten waiters or ten thousand, and nothing
|
|
24
|
+
* counts or scans the jobs table. `DatabaseSlots.test.ts` runs `EXPLAIN` on
|
|
25
|
+
* each statement on all three databases.
|
|
26
|
+
*
|
|
27
|
+
* On MySQL a step runs at READ COMMITTED on a connection of its own, as the
|
|
28
|
+
* claim does: at REPEATABLE READ the range deletes and counts would take gap
|
|
29
|
+
* locks reaching into the next key's rows, and steps on different keys would
|
|
30
|
+
* wait on each other.
|
|
31
|
+
*
|
|
32
|
+
* ### Bun 1.3 and Postgres
|
|
33
|
+
*
|
|
34
|
+
* Bun 1.3's Postgres pool can send a query made on the pool (the queue's
|
|
35
|
+
* claim, say) down a connection that is inside a `sql.begin` or reserved.
|
|
36
|
+
* The claim then runs in the step's transaction, the step's next statement
|
|
37
|
+
* never comes back, and the key's gate row stays locked, so every other step
|
|
38
|
+
* on the key waits for good. Bun 1.4 does not. So under Bun 1.3, on
|
|
39
|
+
* Postgres, steps run one at a time per driver on a client of their own (one
|
|
40
|
+
* connection, closed when idle) that nothing else uses.
|
|
41
|
+
*/
|
|
42
|
+
export declare class DatabaseSlots {
|
|
43
|
+
private readonly db;
|
|
44
|
+
private readonly statements;
|
|
45
|
+
/** Bun 1.3 on Postgres: the steps' own client, and the step running on it. */
|
|
46
|
+
private own;
|
|
47
|
+
private ownTail;
|
|
48
|
+
constructor(db: {
|
|
49
|
+
sql: SQL;
|
|
50
|
+
dialect: Dialect;
|
|
51
|
+
configure(): Promise<void>;
|
|
52
|
+
atomically<T>(fn: (q: SQL) => Promise<T>): Promise<T>;
|
|
53
|
+
insertJob(q: SQL, job: EnqueueJob): Promise<string>;
|
|
54
|
+
}, tables: SlotTables);
|
|
55
|
+
acquire(request: SlotRequest): Promise<boolean>;
|
|
56
|
+
release(holder: string): Promise<void>;
|
|
57
|
+
/** Drops holders whose job or workflow is gone. */
|
|
58
|
+
private prune;
|
|
59
|
+
/** Makes the first waiters due, as many as `key` has free slots, dropping dead ones. */
|
|
60
|
+
private wake;
|
|
61
|
+
private count;
|
|
62
|
+
/**
|
|
63
|
+
* One step on the lines, in a transaction of its own. On MySQL at READ
|
|
64
|
+
* COMMITTED on a reserved connection (see the class), and every step is
|
|
65
|
+
* retried a few times on a deadlock, which MySQL can still report for two
|
|
66
|
+
* first upserts of one gate row.
|
|
67
|
+
*/
|
|
68
|
+
private step;
|
|
69
|
+
private transaction;
|
|
70
|
+
/** See "Bun 1.3 and Postgres" above. */
|
|
71
|
+
private ownClient;
|
|
72
|
+
private runner;
|
|
73
|
+
}
|
|
74
|
+
type Params = Record<string, string | number | null>;
|
|
75
|
+
export type SlotTables = {
|
|
76
|
+
slots: string;
|
|
77
|
+
jobs: string;
|
|
78
|
+
workflows: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The slots table, as Prisma generates it for the `GemiJobSlot` model in the
|
|
82
|
+
* docs, with `IF NOT EXISTS` added.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createSlotTableStatements(dialect: Dialect, table: string): string[];
|
|
85
|
+
export type StatementName = "clock" | "lockGate" | "touchGate" | "gate" | "placeOf" | "ticket" | "insertWaiting" | "pointAt" | "hold" | "deleteTicket" | "keysOf" | "countHolders" | "countAhead" | "nextWaiters" | "pruneJobHolders" | "hasWorkflowHolders" | "pruneWorkflowHolders" | "wakeJob" | "jobStatus" | "workflowStatus" | "park";
|
|
86
|
+
export type SlotStatements = {
|
|
87
|
+
table: string;
|
|
88
|
+
/** The text of every statement, with `{name}` placeholders, for `EXPLAIN`. */
|
|
89
|
+
texts: Record<StatementName, string>;
|
|
90
|
+
/** A statement as the dialect's text and its positional values. */
|
|
91
|
+
compile(name: StatementName, params: Params): [string, unknown[]];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Every statement the slots run, per dialect, as text: one place to read
|
|
95
|
+
* them, and what the test hands to `EXPLAIN`. Placeholders are `{name}`, and
|
|
96
|
+
* `compile` turns them into `$n` (Postgres) or `?` (MySQL, SQLite).
|
|
97
|
+
*/
|
|
98
|
+
export declare function slotStatements(dialect: Dialect, tables: SlotTables): SlotStatements;
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=DatabaseSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseSlots.d.ts","sourceRoot":"","sources":["../../../services/queue/DatabaseSlots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,aAAa;IAOtB,OAAO,CAAC,QAAQ,CAAC,EAAE;IANrB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,8EAA8E;IAC9E,OAAO,CAAC,GAAG,CAAkB;IAC7B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,GACZ,aAAa,GACb,iBAAiB,GACjB,oBAAoB,GACpB,sBAAsB,GACtB,SAAS,GACT,WAAW,GACX,gBAAgB,GAChB,MAAM,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACrC,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;CACnE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,CAuGnF"}
|
|
@@ -56,10 +56,17 @@ export declare class Job {
|
|
|
56
56
|
throttle(..._args: any[]): JobThrottle | JobThrottle[] | undefined | null;
|
|
57
57
|
/**
|
|
58
58
|
* At most `limit` jobs with this `key` running at once, across every process
|
|
59
|
-
* sharing the queue's storage.
|
|
60
|
-
*
|
|
59
|
+
* sharing the queue's storage (#1319). Called each time the job is about to
|
|
60
|
+
* run, so it may be `async` and read the limit from config or the database.
|
|
61
|
+
* Return a list for several limits ("1 per org, 5 overall"): they are taken
|
|
62
|
+
* in order and all are needed, so list the narrowest first, in the same
|
|
63
|
+
* order everywhere.
|
|
64
|
+
*
|
|
65
|
+
* A job with no free slot waits its turn, first come first served, without
|
|
66
|
+
* spending an attempt and without holding a queue slot or a connection: it
|
|
67
|
+
* is put back and made due again as soon as a slot frees.
|
|
61
68
|
*/
|
|
62
|
-
concurrency(..._args: any[]):
|
|
69
|
+
concurrency(..._args: any[]): JobConcurrencyResult | Promise<JobConcurrencyResult>;
|
|
63
70
|
/**
|
|
64
71
|
* Called from `run`: puts the job back to wait `delayMs` once `run`
|
|
65
72
|
* returns, without counting the attempt or calling any hook. For a provider
|
|
@@ -100,6 +107,10 @@ export declare class Job {
|
|
|
100
107
|
kind: "fail";
|
|
101
108
|
error: Error;
|
|
102
109
|
retry: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** The claim was parked to wait for a concurrency slot; nothing is reported on it. */
|
|
112
|
+
| {
|
|
113
|
+
kind: "parked";
|
|
103
114
|
} | undefined;
|
|
104
115
|
run(..._args: any[]): Promise<any> | any;
|
|
105
116
|
onFail(_error: Error, ..._args: any[]): void;
|
|
@@ -161,8 +172,14 @@ export type JobThrottle = {
|
|
|
161
172
|
/** The window, in milliseconds. */
|
|
162
173
|
window: number;
|
|
163
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* One concurrency limit: at most `limit` holders of `key` at once. `limit`
|
|
177
|
+
* is a whole number; `0` holds every job of the key until it is raised.
|
|
178
|
+
*/
|
|
164
179
|
export type JobConcurrency = {
|
|
165
180
|
key: string;
|
|
166
181
|
limit: number;
|
|
167
182
|
};
|
|
183
|
+
/** What `concurrency` returns: one limit, several, or none. */
|
|
184
|
+
export type JobConcurrencyResult = JobConcurrency | readonly JobConcurrency[] | undefined | null;
|
|
168
185
|
//# sourceMappingURL=Job.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Job.d.ts","sourceRoot":"","sources":["../../../services/queue/Job.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAiB,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAgB,MAAM,gBAAgB,CAAC;AAE1F,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG;IACrB,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,I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M,GAAG,OAAO,CAAC,OAAO,CAAC;CAGjD;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,+DAA+D;AAC/D,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,SAAS,cAAc,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BatchStatus } from "./batch";
|
|
2
2
|
import type { ClaimOptions, ClaimedJob, EnqueueBatch, EnqueueJob, JobFailure, JobRelease, QueueDriver } from "./QueueDriver";
|
|
3
|
-
import type
|
|
3
|
+
import { MemorySlots, type SlotRequest } from "./slots";
|
|
4
|
+
import { type WorkflowStore } from "./workflow/WorkflowStore";
|
|
4
5
|
/**
|
|
5
6
|
* The default driver: a Map in this process's memory.
|
|
6
7
|
*
|
|
@@ -36,6 +37,8 @@ export declare class MemoryQueueDriver implements QueueDriver {
|
|
|
36
37
|
private entries;
|
|
37
38
|
private batches;
|
|
38
39
|
private workflows;
|
|
40
|
+
/** Concurrency slots (#1319), per process like the jobs. */
|
|
41
|
+
readonly slots: MemorySlots;
|
|
39
42
|
private listeners;
|
|
40
43
|
private timer;
|
|
41
44
|
private timerAt;
|
|
@@ -59,6 +62,13 @@ export declare class MemoryQueueDriver implements QueueDriver {
|
|
|
59
62
|
* store's writes, ticks and batches included, happen synchronously here.
|
|
60
63
|
*/
|
|
61
64
|
workflowStore(): WorkflowStore;
|
|
65
|
+
/**
|
|
66
|
+
* Concurrency slots (#1319), in this process's memory: the same order,
|
|
67
|
+
* parking and waking as the database driver's, and per process, as every
|
|
68
|
+
* job here is.
|
|
69
|
+
*/
|
|
70
|
+
acquireSlots(request: SlotRequest): Promise<boolean>;
|
|
71
|
+
releaseSlots(holder: string): Promise<void>;
|
|
62
72
|
reportProgress(job: ClaimedJob, progress: number): Promise<void>;
|
|
63
73
|
claim(limit: number, options: ClaimOptions): Promise<ClaimedJob[]>;
|
|
64
74
|
complete(job: ClaimedJob): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryQueueDriver.d.ts","sourceRoot":"","sources":["../../../services/queue/MemoryQueueDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAQjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryQueueDriver.d.ts","sourceRoot":"","sources":["../../../services/queue/MemoryQueueDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAQjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAoBjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAAkC;IACnD,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,cAmCX;IACH,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO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AC,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IASzE,2DAA2D;IAC3D,OAAO,CAAC,KAAK;IAcb,2EAA2E;IAC3E,OAAO,CAAC,IAAI;IAMZ,oEAAoE;IACpE,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,qBAAqB;IAQ7B,SAAS,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAKvC;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,IAAI;IAIZ,2EAA2E;IAC3E,OAAO,CAAC,QAAQ;CAoBjB"}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
*/
|
|
43
43
|
import type { LockStore } from "../lock/LockStore";
|
|
44
44
|
import type { BatchCallbacks, BatchStatus } from "./batch";
|
|
45
|
+
import type { SlotRequest } from "./slots";
|
|
45
46
|
import type { WorkflowStore } from "./workflow/WorkflowStore";
|
|
46
47
|
export interface QueueDriver {
|
|
47
48
|
/**
|
|
@@ -150,6 +151,29 @@ export interface QueueDriver {
|
|
|
150
151
|
* once per manager.
|
|
151
152
|
*/
|
|
152
153
|
lockStore?(): LockStore;
|
|
154
|
+
/**
|
|
155
|
+
* Takes the concurrency slots a job or a workflow asks for (#1319), in the
|
|
156
|
+
* order given, and resolves to whether it got all of them. See `slots.ts`
|
|
157
|
+
* for the model.
|
|
158
|
+
*
|
|
159
|
+
* When it did not, the request's claim has been parked in the same atomic
|
|
160
|
+
* step as the decision: back to waiting, its attempt taken back, due after
|
|
161
|
+
* `recheckMs`, and the holder keeps its place in the key's line (and the
|
|
162
|
+
* slots it got for earlier keys). The manager must not report on that
|
|
163
|
+
* claim again. Whenever the step finds a line with free slots, it makes the
|
|
164
|
+
* line's first waiters due at once.
|
|
165
|
+
*
|
|
166
|
+
* Taking a slot the holder already holds succeeds, so a job reclaimed after
|
|
167
|
+
* its process died gets its own slot back. Optional, with `releaseSlots`:
|
|
168
|
+
* without them, job concurrency falls back to slot locks in the lock store
|
|
169
|
+
* (no order, waiters polling), and a workflow's `concurrency` is refused.
|
|
170
|
+
*/
|
|
171
|
+
acquireSlots?(request: SlotRequest): Promise<boolean>;
|
|
172
|
+
/**
|
|
173
|
+
* Ends every slot and place in line `holder` has, and wakes the waiters
|
|
174
|
+
* that frees slots for. Releasing nothing is not an error.
|
|
175
|
+
*/
|
|
176
|
+
releaseSlots?(holder: string): Promise<void>;
|
|
153
177
|
/**
|
|
154
178
|
* Records a batch and all of its jobs in one atomic step: either every job
|
|
155
179
|
* and the batch are recorded, or none is. Optional; a driver without it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueDriver.d.ts","sourceRoot":"","sources":["../../../services/queue/QueueDriver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,IAAI,OAAO,CAAC;IAE7B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAEnE;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE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MAAM,CAAC;IACb,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
|
|
@@ -433,17 +433,37 @@ export declare class QueueManager {
|
|
|
433
433
|
/** What `this.batch` and `this.progress()` reach in a job of a batch. */
|
|
434
434
|
private batchHandle;
|
|
435
435
|
/**
|
|
436
|
-
* Takes
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
436
|
+
* Takes the job's `concurrency` slots and a hit under each of its
|
|
437
|
+
* `throttle` keys, so the limits hold across every process sharing the
|
|
438
|
+
* queue's storage. Resolves to what to undo after the run, or `undefined`
|
|
439
|
+
* when the job was put back to wait for capacity.
|
|
440
440
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
441
|
+
* Slots are the driver's lines (#1319, `slots.ts`): first come first
|
|
442
|
+
* served, and a job without a slot is parked by the driver, holding
|
|
443
|
+
* nothing, until one frees. A driver without them falls back to `limit`
|
|
444
|
+
* slot locks per key in the lock store, leased for the visibility timeout
|
|
445
|
+
* and renewed while the job runs, with a waiter put back to poll.
|
|
446
|
+
* Throttles are fixed windows counted when a job is admitted, whether it
|
|
447
|
+
* then succeeds or not.
|
|
445
448
|
*/
|
|
446
449
|
private admit;
|
|
450
|
+
/**
|
|
451
|
+
* When a job or workflow parked for a slot is claimed again to re-check
|
|
452
|
+
* (see `SlotRequest.recheckMs`): after the visibility timeout for the first
|
|
453
|
+
* waiters of a line, by when a holder whose process died has had its job
|
|
454
|
+
* reclaimed, and hourly for the rest. Neither is how a waiter normally
|
|
455
|
+
* moves up; a freed slot wakes it at once.
|
|
456
|
+
*/
|
|
457
|
+
/** @internal */
|
|
458
|
+
slotRecheck(): {
|
|
459
|
+
near: number;
|
|
460
|
+
far: number;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* The fallback for a driver without `acquireSlots`: one of `limit` slot
|
|
464
|
+
* locks per key, all keys or none. No order, and a waiter polls.
|
|
465
|
+
*/
|
|
466
|
+
private lockSlots;
|
|
447
467
|
}
|
|
448
468
|
/**
|
|
449
469
|
* Whether this process should claim from a driver shared with other
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueManager.d.ts","sourceRoot":"","sources":["../../../services/queue/QueueManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EAAiB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIjE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO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ACrE,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,OAAO;IAwBf;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAoBjB;;;;;;;OAOG;YACW,GAAG;IAgOjB,yEAAyE;IACzE,OAAO,CAAC,WAAW;IAanB;;;;;;;;;;;;;OAaG;YACW,KAAK;IA8DnB;;;;;;OAMG;IACH,gBAAgB;IAChB,WAAW;;;;IAIX;;;OAGG;YACW,SAAS;CAkBxB;AAmBD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,YAIlC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,WAEtF;AAQD,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,MAAM,UAAO,QAE5C;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concurrency slots (#1319): at most `limit` holders per key, handed out in
|
|
3
|
+
* the order the work first asked, with waiting work parked rather than
|
|
4
|
+
* polling.
|
|
5
|
+
*
|
|
6
|
+
* ### The model
|
|
7
|
+
*
|
|
8
|
+
* Each key has a **line**: the holders of its slots and, behind them, the
|
|
9
|
+
* waiters, ordered by when each first asked (`order`, then the holder's id).
|
|
10
|
+
* A request is granted when the holders plus the waiters ahead of it are
|
|
11
|
+
* fewer than the limit, so work that asked later never overtakes work that
|
|
12
|
+
* asked earlier, however often either is re-admitted. A waiter keeps its
|
|
13
|
+
* place until it is granted or ends.
|
|
14
|
+
*
|
|
15
|
+
* A **holder** is a job (by its id) or a workflow (`workflow:<id>`). Several
|
|
16
|
+
* keys are taken in the order given and all are needed; a waiter for a later
|
|
17
|
+
* key keeps the earlier ones, since it is first in their lines anyway.
|
|
18
|
+
*
|
|
19
|
+
* ### Nothing waits in a process
|
|
20
|
+
*
|
|
21
|
+
* A request that cannot be granted parks its job: the claim goes back to
|
|
22
|
+
* waiting, its attempt taken back, due after `recheckMs` — `near` for a
|
|
23
|
+
* waiter among the first `limit` of its line (at least the first one), `far`
|
|
24
|
+
* for the rest — and in
|
|
25
|
+
* the same atomic step as the decision, so a slot freed a moment later is
|
|
26
|
+
* not missed. Whenever a line has free slots (a holder released, a limit
|
|
27
|
+
* was raised, a holder turned out to be gone), the step that sees it makes
|
|
28
|
+
* the first waiters due at once. The rechecks are only a safety net for a
|
|
29
|
+
* process that died between ending its work and handing its slot on.
|
|
30
|
+
*
|
|
31
|
+
* ### Holders that are gone
|
|
32
|
+
*
|
|
33
|
+
* A slot is never leased. A job's is valid while its job is still waiting
|
|
34
|
+
* or claimed (a crashed holder's job is reclaimed and takes its own slot
|
|
35
|
+
* back), and a workflow's while the workflow is neither ended nor paused.
|
|
36
|
+
* Every step on a line first drops the holders that are no longer valid, so
|
|
37
|
+
* a slot whose release was lost frees itself at the line's next step.
|
|
38
|
+
*/
|
|
39
|
+
import type { ClaimedJob } from "./QueueDriver";
|
|
40
|
+
/** One limit: at most `limit` holders of `key` at once. */
|
|
41
|
+
export type SlotLimit = {
|
|
42
|
+
key: string;
|
|
43
|
+
limit: number;
|
|
44
|
+
};
|
|
45
|
+
export type SlotRequest = {
|
|
46
|
+
/** A job's id, or `workflow:<id>` for a workflow's slots. */
|
|
47
|
+
holder: string;
|
|
48
|
+
/** For a workflow's slots: the workflow, whose status decides whether its slots are still held. */
|
|
49
|
+
workflowId?: string;
|
|
50
|
+
/** The claim that asks: parked when the request is not granted, and woken when its turn comes. */
|
|
51
|
+
job: ClaimedJob;
|
|
52
|
+
/** The limits, taken in this order. */
|
|
53
|
+
slots: SlotLimit[];
|
|
54
|
+
/** When a parked request is claimed again to re-check, in milliseconds. */
|
|
55
|
+
recheckMs: {
|
|
56
|
+
near: number;
|
|
57
|
+
far: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** The holder a workflow's slots are kept under. */
|
|
61
|
+
export declare function workflowHolder(workflowId: string): string;
|
|
62
|
+
/** The longest key a slot may have: it is a VARCHAR(191) column on MySQL. */
|
|
63
|
+
export declare const SLOT_KEY_LIMIT = 191;
|
|
64
|
+
/**
|
|
65
|
+
* What a job's or a workflow's `concurrency` returned, checked: one limit or
|
|
66
|
+
* a list, `undefined` or `null` for none. Throws, on the caller's attempt,
|
|
67
|
+
* for a key or a limit the line could not hold.
|
|
68
|
+
*/
|
|
69
|
+
export declare function slotLimits(value: unknown, owner: string): SlotLimit[];
|
|
70
|
+
/** What `MemorySlots` needs from the memory driver, all synchronous. */
|
|
71
|
+
export type MemorySlotHost = {
|
|
72
|
+
/** Whether the job is still waiting or claimed. */
|
|
73
|
+
jobAlive(id: string): boolean;
|
|
74
|
+
/** Whether the workflow exists and is neither ended nor paused. */
|
|
75
|
+
workflowAlive(id: string): boolean;
|
|
76
|
+
/** Puts a current claim back to waiting, due after `ms`, its attempt taken back. */
|
|
77
|
+
park(job: ClaimedJob, ms: number): void;
|
|
78
|
+
/** Makes a waiting job due now; `false` when there is no such job. */
|
|
79
|
+
wake(id: string): boolean;
|
|
80
|
+
/** Enqueues a tick for the workflow, and returns its job id. */
|
|
81
|
+
tick(workflowId: string): string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The lines in this process's memory, for the memory driver: the same
|
|
85
|
+
* order, parking and waking as the database driver's, and like everything
|
|
86
|
+
* on that driver, per process.
|
|
87
|
+
*/
|
|
88
|
+
export declare class MemorySlots {
|
|
89
|
+
private readonly host;
|
|
90
|
+
private lines;
|
|
91
|
+
private keysOf;
|
|
92
|
+
private order;
|
|
93
|
+
constructor(host: MemorySlotHost);
|
|
94
|
+
/** Holders and waiters of `key`, for tests. */
|
|
95
|
+
line(key: string): {
|
|
96
|
+
holding: string[];
|
|
97
|
+
waiting: string[];
|
|
98
|
+
};
|
|
99
|
+
acquire(request: SlotRequest): boolean;
|
|
100
|
+
release(holder: string): void;
|
|
101
|
+
private sorted;
|
|
102
|
+
private holders;
|
|
103
|
+
private ahead;
|
|
104
|
+
private alive;
|
|
105
|
+
/** Drops holders whose job or workflow is gone. */
|
|
106
|
+
private prune;
|
|
107
|
+
/** Makes the first waiters due, as many as the line has free slots, dropping dead ones. */
|
|
108
|
+
private wake;
|
|
109
|
+
private forget;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../../services/queue/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,2DAA2D;AAC3D,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kGAAkG;IAClG,GAAG,EAAE,UAAU,CAAC;IAChB,uCAAuC;IACvC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,2EAA2E;IAC3E,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,oDAAoD;AACpD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,6EAA6E;AAC7E,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,CA2BrE;AAED,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,mEAAmE;IACnE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,oFAAoF;IACpF,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,sEAAsE;IACtE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,gEAAgE;IAChE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC,CAAC;AAYF;;;;GAIG;AACH,qBAAa,WAAW;IAKV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,KAAK,CAAK;gBAEW,IAAI,EAAE,cAAc;IAEjD,+CAA+C;IAC/C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAS3D,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAmDtC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAc7B,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,KAAK;IAMb,mDAAmD;IACnD,OAAO,CAAC,KAAK;IAMb,2FAA2F;IAC3F,OAAO,CAAC,IAAI;IAqBZ,OAAO,CAAC,MAAM;CAMf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ke as J,Ne as A}from"../../chunk-
|
|
2
|
+
import{Ke as J,Ne as A}from"../../chunk-p1ern8r4.js";import{Mk as V}from"../../chunk-wy82t7mz.js";import"../../chunk-tac25cnj.js";import"../../chunk-0k2r6bep.js";import"../../chunk-0av1gyns.js";import"../../chunk-zmt5kdpb.js";import"../../chunk-37209psn.js";import"../../chunk-fqhkkpq3.js";import{Am as _,Em as I,vm as Y,ym as N,zm as Z}from"../../chunk-6r7956dh.js";import{Im as x}from"../../chunk-5mrtgr7q.js";import"../../chunk-3dkv4989.js";import $ from"path";function X(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof V))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class L extends Error{name="QueueWorkerRefused"}class O{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={..._(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(J))throw new L("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(J);if(!C.durable)throw new L('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=X(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){let C=Date.now()+z.timeoutMs;Y();let E=this.kernel.app,F=E.resolved(J)?E.make(J):void 0;if(F)console.log(`[gemi] Shutting down: waiting for ${F.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await F.drain(z.timeoutMs);let G=N()===0;if(!G){let U=C-Date.now();if(G=U>0&&await Promise.race([Z().then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),U))]),!G)console.error(`[gemi] Shutdown grace period elapsed with ${N()} held background task(s) still running; abandoning them.`)}let H=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let T=G&&(F?.running??0)===0&&H.failed.length===0&&H.timedOut.length===0;return console.log(`[gemi] Shutdown ${T?"complete":"finished with errors"}.`),T?0:1}}async function j(){let z=x();process.env.ROOT_DIR=z,process.env.APP_DIR=$.join(z,"app"),A();let C=$.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new O(F);I(()=>G.stop());try{await G.start()}catch(H){if(!(H instanceof L))throw H;return console.error(H.message),1}return}j().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
|
|
3
3
|
|
|
4
4
|
//# debugId=07AAF52CEDF447F964756E2164756E21
|
|
@@ -30,6 +30,8 @@ export declare class MemoryWorkflowStore implements WorkflowStore {
|
|
|
30
30
|
}): Promise<WorkflowState | null>;
|
|
31
31
|
acquire(id: string, owner: string, leaseMs: number): Promise<AcquireResult>;
|
|
32
32
|
renew(id: string, owner: string, leaseMs: number): Promise<boolean>;
|
|
33
|
+
/** The workflow's status, synchronously, for the memory driver's slots. */
|
|
34
|
+
statusOf(id: string): WorkflowRecord["status"] | undefined;
|
|
33
35
|
update<T>(id: string, options: UpdateOptions, decide: (snapshot: {
|
|
34
36
|
workflow: WorkflowRecord;
|
|
35
37
|
step: StepRecord | null;
|