[{"data":1,"prerenderedAt":1982},["ShallowReactive",2],{"docs:/docs/high-level-sdks/queue":3},{"id":4,"title":5,"body":6,"description":17,"extension":1976,"meta":1977,"navigation":279,"path":1978,"seo":1979,"stem":1980,"__hash__":1981},"docs/docs/high-level-sdks/queue.md","Queue SDK",{"type":7,"value":8,"toc":1962},"minimark",[9,14,18,23,66,71,96,100,125,172,176,208,231,235,1207,1211,1214,1219,1404,1492,1496,1595,1598,1788,1792,1958],[10,11,13],"h1",{"id":12},"nolagqueue","@nolag/queue",[15,16,17],"p",{},"Real-time job queues with lifecycle tracking, progress updates, and worker management.",[19,20,22],"h2",{"id":21},"overview","Overview",[15,24,25,26,30,31,30,34,30,37,40,41,44,45,48,49,53,54,57,58,61,62,65],{},"Distribute work across real-time workers with full lifecycle visibility. Jobs follow a state machine: ",[27,28,29],"code",{},"pending"," → ",[27,32,33],{},"claimed",[27,35,36],{},"active",[27,38,39],{},"completed"," or ",[27,42,43],{},"failed",". Every state transition is broadcast instantly to all queue participants. Failed jobs are re-queued automatically until ",[27,46,47],{},"maxRetries"," is exhausted. Three roles participate in a queue: ",[50,51,52],"strong",{},"producers"," add jobs, ",[50,55,56],{},"workers"," claim and process them, and ",[50,59,60],{},"monitors"," observe queue state. A single client can fulfil multiple roles simultaneously. Your app owns one core NoLag client and injects it into ",[27,63,64],{},"NoLagQueue","; the wrapper attaches its behaviour to that connection.",[67,68,70],"h3",{"id":69},"key-features","Key Features",[72,73,74,78,81,84,87,90,93],"ul",{},[75,76,77],"li",{},"State machine lifecycle: pending, claimed, active, completed, failed",[75,79,80],{},"Atomic job claiming, so exactly one worker receives each job",[75,82,83],{},"Configurable priority and automatic retry with backoff",[75,85,86],{},"Real-time progress reporting (0-100) broadcast to all participants",[75,88,89],{},"7-day job history replay on reconnect",[75,91,92],{},"Ephemeral progress channel keeps durable storage lean",[75,94,95],{},"Worker online/offline presence via lobby",[19,97,99],{"id":98},"how-it-works","How It Works",[15,101,102,104,105,108,109,112,113,116,117,120,121,124],{},[27,103,64],{}," attaches to an injected ",[27,106,107],{},"@nolag/js-sdk"," client and maintains a lobby for worker presence. Calling ",[27,110,111],{},"joinQueue(name)"," returns a ",[27,114,115],{},"QueueRoom"," that subscribes to two topics: ",[27,118,119],{},"jobs"," for durable lifecycle events and ",[27,122,123],{},"_progress"," for ephemeral progress updates. Job claiming uses a server-side atomic operation so concurrent claim attempts from multiple workers resolve to exactly one winner. The app owns the socket lifecycle; the wrapper never opens or closes it.",[126,127,128,144],"table",{},[129,130,131],"thead",{},[132,133,134,138,141],"tr",{},[135,136,137],"th",{},"Topic",[135,139,140],{},"Purpose",[135,142,143],{},"Replay",[145,146,147,160],"tbody",{},[132,148,149,154,157],{},[150,151,152],"td",{},[27,153,119],{},[150,155,156],{},"Job lifecycle events: added, claimed, completed, failed, retrying",[150,158,159],{},"7 days",[132,161,162,166,169],{},[150,163,164],{},[27,165,123],{},[150,167,168],{},"In-flight progress updates (0-100), not persisted",[150,170,171],{},"Ephemeral",[19,173,175],{"id":174},"installation","Installation",[177,178,179],"code-tabs",{},[180,181,187],"pre",{"className":182,"code":183,"filename":184,"language":185,"meta":186,"style":186},"language-bash shiki shiki-themes github-light github-dark","npm install @nolag/queue @nolag/js-sdk\n","Terminal","bash","",[27,188,189],{"__ignoreMap":186},[190,191,194,198,202,205],"span",{"class":192,"line":193},"line",1,[190,195,197],{"class":196},"sScJk","npm",[190,199,201],{"class":200},"sZZnC"," install",[190,203,204],{"class":200}," @nolag/queue",[190,206,207],{"class":200}," @nolag/js-sdk\n",[209,210,212],"note",{"title":211},"Shared connection",[15,213,214,215,218,219,222,223,226,227,230],{},"One core NoLag client can back several wrapper SDKs at once, for example a job queue, a dashboard, and notify on a single socket, as long as each wrapper uses a distinct ",[27,216,217],{},"appName",". Each wrapper attaches its handlers on construction and releases them with ",[27,220,221],{},"detach()",", and never touches the socket itself. Your app owns ",[27,224,225],{},"connect()"," and ",[27,228,229],{},"disconnect()",".",[19,232,234],{"id":233},"quick-start","Quick Start",[177,236,237],{},[180,238,243],{"className":239,"code":240,"filename":241,"language":242,"meta":186,"style":186},"language-typescript shiki shiki-themes github-light github-dark","import { NoLag } from '@nolag/js-sdk'\nimport { NoLagQueue } from '@nolag/queue'\n\n// The app owns one core client. In a browser, pass a token provider so the\n// SDK can mint fresh short-lived client tokens from your backend.\nconst client = NoLag(async () => (await (await fetch('/api/nolag-token')).json()).token)\n\n// Inject the client into the queue wrapper (role: 'producer', 'worker', or 'monitor')\nconst queueClient = new NoLagQueue({ client, role: 'worker', concurrency: 4 })\n\nawait client.connect()   // the app owns the connection\nawait queueClient.ready() // wrapper setup complete\n\nconst queue = await queueClient.joinQueue('video-encoding')\n\n// ── Producer ─────────────────────────────────────────────────────────────────\nconst job = await queue.addJob({\n  id: 'job-101',           // optional, auto-generated if omitted\n  payload: { videoId: 'vid_xyz', preset: '1080p' },\n  priority: 10,            // higher = processed sooner\n  maxRetries: 3,\n})\nconsole.log('Added job:', job.id, 'status:', job.status) // 'pending'\n\n// ── Worker ───────────────────────────────────────────────────────────────────\nqueue.on('jobAdded', async ({ job }) => {\n  // Atomically claim the job (only one worker succeeds)\n  const claimed = await queue.claimJob(job.id)\n  if (!claimed) return  // another worker got it first\n\n  console.log('Claimed job:', job.id)\n\n  try {\n    // Report progress (0–100)\n    await queue.reportProgress(job.id, 25)\n    await doExpensiveWork(job.payload)\n    await queue.reportProgress(job.id, 100)\n\n    // Mark complete with result\n    await queue.completeJob(job.id, { outputUrl: 'https://cdn.example.com/vid.mp4' })\n  } catch (err) {\n    // Mark failed (retried automatically if maxRetries not exhausted)\n    await queue.failJob(job.id, err instanceof Error ? err.message : String(err))\n  }\n})\n\n// ── Monitor ───────────────────────────────────────────────────────────────────\nqueue.on('jobProgress', ({ jobId, progress }) => {\n  console.log(`Job ${jobId} is ${progress}% complete`)\n})\n\nqueue.on('jobCompleted', ({ jobId, result }) => {\n  console.log(`Job ${jobId} done:`, result)\n})\n\nqueue.on('jobFailed', ({ jobId, error, attempt, maxRetries }) => {\n  console.warn(`Job ${jobId} failed (attempt ${attempt}/${maxRetries}):`, error)\n})\n\nqueue.on('jobRetrying', ({ jobId, attempt, maxRetries }) => {\n  console.log(`Retrying job ${jobId} (${attempt}/${maxRetries})...`)\n})\n\n// Queue depth monitoring\nconsole.log('Pending:', await queue.pendingCount)\nconsole.log('Active:', await queue.activeCount)\n\n// Teardown: the wrapper releases its handlers; the app closes the socket.\nqueueClient.detach()\nclient.disconnect()\n","TypeScript","typescript",[27,244,245,261,274,281,288,294,349,354,360,391,396,413,430,435,461,466,472,493,508,526,541,553,559,585,590,596,630,636,657,677,682,698,703,711,717,736,747,763,768,774,792,804,810,844,850,855,860,866,895,919,924,929,956,975,980,985,1021,1051,1056,1061,1091,1119,1124,1129,1135,1154,1173,1178,1184,1196],{"__ignoreMap":186},[190,246,247,251,255,258],{"class":192,"line":193},[190,248,250],{"class":249},"szBVR","import",[190,252,254],{"class":253},"sVt8B"," { NoLag } ",[190,256,257],{"class":249},"from",[190,259,260],{"class":200}," '@nolag/js-sdk'\n",[190,262,264,266,269,271],{"class":192,"line":263},2,[190,265,250],{"class":249},[190,267,268],{"class":253}," { NoLagQueue } ",[190,270,257],{"class":249},[190,272,273],{"class":200}," '@nolag/queue'\n",[190,275,277],{"class":192,"line":276},3,[190,278,280],{"emptyLinePlaceholder":279},true,"\n",[190,282,284],{"class":192,"line":283},4,[190,285,287],{"class":286},"sJ8bj","// The app owns one core client. In a browser, pass a token provider so the\n",[190,289,291],{"class":192,"line":290},5,[190,292,293],{"class":286},"// SDK can mint fresh short-lived client tokens from your backend.\n",[190,295,297,300,304,307,310,313,316,319,322,325,328,330,332,335,337,340,343,346],{"class":192,"line":296},6,[190,298,299],{"class":249},"const",[190,301,303],{"class":302},"sj4cs"," client",[190,305,306],{"class":249}," =",[190,308,309],{"class":196}," NoLag",[190,311,312],{"class":253},"(",[190,314,315],{"class":249},"async",[190,317,318],{"class":253}," () ",[190,320,321],{"class":249},"=>",[190,323,324],{"class":253}," (",[190,326,327],{"class":249},"await",[190,329,324],{"class":253},[190,331,327],{"class":249},[190,333,334],{"class":196}," fetch",[190,336,312],{"class":253},[190,338,339],{"class":200},"'/api/nolag-token'",[190,341,342],{"class":253},")).",[190,344,345],{"class":196},"json",[190,347,348],{"class":253},"()).token)\n",[190,350,352],{"class":192,"line":351},7,[190,353,280],{"emptyLinePlaceholder":279},[190,355,357],{"class":192,"line":356},8,[190,358,359],{"class":286},"// Inject the client into the queue wrapper (role: 'producer', 'worker', or 'monitor')\n",[190,361,363,365,368,370,373,376,379,382,385,388],{"class":192,"line":362},9,[190,364,299],{"class":249},[190,366,367],{"class":302}," queueClient",[190,369,306],{"class":249},[190,371,372],{"class":249}," new",[190,374,375],{"class":196}," NoLagQueue",[190,377,378],{"class":253},"({ client, role: ",[190,380,381],{"class":200},"'worker'",[190,383,384],{"class":253},", concurrency: ",[190,386,387],{"class":302},"4",[190,389,390],{"class":253}," })\n",[190,392,394],{"class":192,"line":393},10,[190,395,280],{"emptyLinePlaceholder":279},[190,397,399,401,404,407,410],{"class":192,"line":398},11,[190,400,327],{"class":249},[190,402,403],{"class":253}," client.",[190,405,406],{"class":196},"connect",[190,408,409],{"class":253},"()   ",[190,411,412],{"class":286},"// the app owns the connection\n",[190,414,416,418,421,424,427],{"class":192,"line":415},12,[190,417,327],{"class":249},[190,419,420],{"class":253}," queueClient.",[190,422,423],{"class":196},"ready",[190,425,426],{"class":253},"() ",[190,428,429],{"class":286},"// wrapper setup complete\n",[190,431,433],{"class":192,"line":432},13,[190,434,280],{"emptyLinePlaceholder":279},[190,436,438,440,443,445,448,450,453,455,458],{"class":192,"line":437},14,[190,439,299],{"class":249},[190,441,442],{"class":302}," queue",[190,444,306],{"class":249},[190,446,447],{"class":249}," await",[190,449,420],{"class":253},[190,451,452],{"class":196},"joinQueue",[190,454,312],{"class":253},[190,456,457],{"class":200},"'video-encoding'",[190,459,460],{"class":253},")\n",[190,462,464],{"class":192,"line":463},15,[190,465,280],{"emptyLinePlaceholder":279},[190,467,469],{"class":192,"line":468},16,[190,470,471],{"class":286},"// ── Producer ─────────────────────────────────────────────────────────────────\n",[190,473,475,477,480,482,484,487,490],{"class":192,"line":474},17,[190,476,299],{"class":249},[190,478,479],{"class":302}," job",[190,481,306],{"class":249},[190,483,447],{"class":249},[190,485,486],{"class":253}," queue.",[190,488,489],{"class":196},"addJob",[190,491,492],{"class":253},"({\n",[190,494,496,499,502,505],{"class":192,"line":495},18,[190,497,498],{"class":253},"  id: ",[190,500,501],{"class":200},"'job-101'",[190,503,504],{"class":253},",           ",[190,506,507],{"class":286},"// optional, auto-generated if omitted\n",[190,509,511,514,517,520,523],{"class":192,"line":510},19,[190,512,513],{"class":253},"  payload: { videoId: ",[190,515,516],{"class":200},"'vid_xyz'",[190,518,519],{"class":253},", preset: ",[190,521,522],{"class":200},"'1080p'",[190,524,525],{"class":253}," },\n",[190,527,529,532,535,538],{"class":192,"line":528},20,[190,530,531],{"class":253},"  priority: ",[190,533,534],{"class":302},"10",[190,536,537],{"class":253},",            ",[190,539,540],{"class":286},"// higher = processed sooner\n",[190,542,544,547,550],{"class":192,"line":543},21,[190,545,546],{"class":253},"  maxRetries: ",[190,548,549],{"class":302},"3",[190,551,552],{"class":253},",\n",[190,554,556],{"class":192,"line":555},22,[190,557,558],{"class":253},"})\n",[190,560,562,565,568,570,573,576,579,582],{"class":192,"line":561},23,[190,563,564],{"class":253},"console.",[190,566,567],{"class":196},"log",[190,569,312],{"class":253},[190,571,572],{"class":200},"'Added job:'",[190,574,575],{"class":253},", job.id, ",[190,577,578],{"class":200},"'status:'",[190,580,581],{"class":253},", job.status) ",[190,583,584],{"class":286},"// 'pending'\n",[190,586,588],{"class":192,"line":587},24,[190,589,280],{"emptyLinePlaceholder":279},[190,591,593],{"class":192,"line":592},25,[190,594,595],{"class":286},"// ── Worker ───────────────────────────────────────────────────────────────────\n",[190,597,599,602,605,607,610,613,615,618,622,625,627],{"class":192,"line":598},26,[190,600,601],{"class":253},"queue.",[190,603,604],{"class":196},"on",[190,606,312],{"class":253},[190,608,609],{"class":200},"'jobAdded'",[190,611,612],{"class":253},", ",[190,614,315],{"class":249},[190,616,617],{"class":253}," ({ ",[190,619,621],{"class":620},"s4XuR","job",[190,623,624],{"class":253}," }) ",[190,626,321],{"class":249},[190,628,629],{"class":253}," {\n",[190,631,633],{"class":192,"line":632},27,[190,634,635],{"class":286},"  // Atomically claim the job (only one worker succeeds)\n",[190,637,639,642,645,647,649,651,654],{"class":192,"line":638},28,[190,640,641],{"class":249},"  const",[190,643,644],{"class":302}," claimed",[190,646,306],{"class":249},[190,648,447],{"class":249},[190,650,486],{"class":253},[190,652,653],{"class":196},"claimJob",[190,655,656],{"class":253},"(job.id)\n",[190,658,660,663,665,668,671,674],{"class":192,"line":659},29,[190,661,662],{"class":249},"  if",[190,664,324],{"class":253},[190,666,667],{"class":249},"!",[190,669,670],{"class":253},"claimed) ",[190,672,673],{"class":249},"return",[190,675,676],{"class":286},"  // another worker got it first\n",[190,678,680],{"class":192,"line":679},30,[190,681,280],{"emptyLinePlaceholder":279},[190,683,685,688,690,692,695],{"class":192,"line":684},31,[190,686,687],{"class":253},"  console.",[190,689,567],{"class":196},[190,691,312],{"class":253},[190,693,694],{"class":200},"'Claimed job:'",[190,696,697],{"class":253},", job.id)\n",[190,699,701],{"class":192,"line":700},32,[190,702,280],{"emptyLinePlaceholder":279},[190,704,706,709],{"class":192,"line":705},33,[190,707,708],{"class":249},"  try",[190,710,629],{"class":253},[190,712,714],{"class":192,"line":713},34,[190,715,716],{"class":286},"    // Report progress (0–100)\n",[190,718,720,723,725,728,731,734],{"class":192,"line":719},35,[190,721,722],{"class":249},"    await",[190,724,486],{"class":253},[190,726,727],{"class":196},"reportProgress",[190,729,730],{"class":253},"(job.id, ",[190,732,733],{"class":302},"25",[190,735,460],{"class":253},[190,737,739,741,744],{"class":192,"line":738},36,[190,740,722],{"class":249},[190,742,743],{"class":196}," doExpensiveWork",[190,745,746],{"class":253},"(job.payload)\n",[190,748,750,752,754,756,758,761],{"class":192,"line":749},37,[190,751,722],{"class":249},[190,753,486],{"class":253},[190,755,727],{"class":196},[190,757,730],{"class":253},[190,759,760],{"class":302},"100",[190,762,460],{"class":253},[190,764,766],{"class":192,"line":765},38,[190,767,280],{"emptyLinePlaceholder":279},[190,769,771],{"class":192,"line":770},39,[190,772,773],{"class":286},"    // Mark complete with result\n",[190,775,777,779,781,784,787,790],{"class":192,"line":776},40,[190,778,722],{"class":249},[190,780,486],{"class":253},[190,782,783],{"class":196},"completeJob",[190,785,786],{"class":253},"(job.id, { outputUrl: ",[190,788,789],{"class":200},"'https://cdn.example.com/vid.mp4'",[190,791,390],{"class":253},[190,793,795,798,801],{"class":192,"line":794},41,[190,796,797],{"class":253},"  } ",[190,799,800],{"class":249},"catch",[190,802,803],{"class":253}," (err) {\n",[190,805,807],{"class":192,"line":806},42,[190,808,809],{"class":286},"    // Mark failed (retried automatically if maxRetries not exhausted)\n",[190,811,813,815,817,820,823,826,829,832,835,838,841],{"class":192,"line":812},43,[190,814,722],{"class":249},[190,816,486],{"class":253},[190,818,819],{"class":196},"failJob",[190,821,822],{"class":253},"(job.id, err ",[190,824,825],{"class":249},"instanceof",[190,827,828],{"class":196}," Error",[190,830,831],{"class":249}," ?",[190,833,834],{"class":253}," err.message ",[190,836,837],{"class":249},":",[190,839,840],{"class":196}," String",[190,842,843],{"class":253},"(err))\n",[190,845,847],{"class":192,"line":846},44,[190,848,849],{"class":253},"  }\n",[190,851,853],{"class":192,"line":852},45,[190,854,558],{"class":253},[190,856,858],{"class":192,"line":857},46,[190,859,280],{"emptyLinePlaceholder":279},[190,861,863],{"class":192,"line":862},47,[190,864,865],{"class":286},"// ── Monitor ───────────────────────────────────────────────────────────────────\n",[190,867,869,871,873,875,878,881,884,886,889,891,893],{"class":192,"line":868},48,[190,870,601],{"class":253},[190,872,604],{"class":196},[190,874,312],{"class":253},[190,876,877],{"class":200},"'jobProgress'",[190,879,880],{"class":253},", ({ ",[190,882,883],{"class":620},"jobId",[190,885,612],{"class":253},[190,887,888],{"class":620},"progress",[190,890,624],{"class":253},[190,892,321],{"class":249},[190,894,629],{"class":253},[190,896,898,900,902,904,907,909,912,914,917],{"class":192,"line":897},49,[190,899,687],{"class":253},[190,901,567],{"class":196},[190,903,312],{"class":253},[190,905,906],{"class":200},"`Job ${",[190,908,883],{"class":253},[190,910,911],{"class":200},"} is ${",[190,913,888],{"class":253},[190,915,916],{"class":200},"}% complete`",[190,918,460],{"class":253},[190,920,922],{"class":192,"line":921},50,[190,923,558],{"class":253},[190,925,927],{"class":192,"line":926},51,[190,928,280],{"emptyLinePlaceholder":279},[190,930,932,934,936,938,941,943,945,947,950,952,954],{"class":192,"line":931},52,[190,933,601],{"class":253},[190,935,604],{"class":196},[190,937,312],{"class":253},[190,939,940],{"class":200},"'jobCompleted'",[190,942,880],{"class":253},[190,944,883],{"class":620},[190,946,612],{"class":253},[190,948,949],{"class":620},"result",[190,951,624],{"class":253},[190,953,321],{"class":249},[190,955,629],{"class":253},[190,957,959,961,963,965,967,969,972],{"class":192,"line":958},53,[190,960,687],{"class":253},[190,962,567],{"class":196},[190,964,312],{"class":253},[190,966,906],{"class":200},[190,968,883],{"class":253},[190,970,971],{"class":200},"} done:`",[190,973,974],{"class":253},", result)\n",[190,976,978],{"class":192,"line":977},54,[190,979,558],{"class":253},[190,981,983],{"class":192,"line":982},55,[190,984,280],{"emptyLinePlaceholder":279},[190,986,988,990,992,994,997,999,1001,1003,1006,1008,1011,1013,1015,1017,1019],{"class":192,"line":987},56,[190,989,601],{"class":253},[190,991,604],{"class":196},[190,993,312],{"class":253},[190,995,996],{"class":200},"'jobFailed'",[190,998,880],{"class":253},[190,1000,883],{"class":620},[190,1002,612],{"class":253},[190,1004,1005],{"class":620},"error",[190,1007,612],{"class":253},[190,1009,1010],{"class":620},"attempt",[190,1012,612],{"class":253},[190,1014,47],{"class":620},[190,1016,624],{"class":253},[190,1018,321],{"class":249},[190,1020,629],{"class":253},[190,1022,1024,1026,1029,1031,1033,1035,1038,1040,1043,1045,1048],{"class":192,"line":1023},57,[190,1025,687],{"class":253},[190,1027,1028],{"class":196},"warn",[190,1030,312],{"class":253},[190,1032,906],{"class":200},[190,1034,883],{"class":253},[190,1036,1037],{"class":200},"} failed (attempt ${",[190,1039,1010],{"class":253},[190,1041,1042],{"class":200},"}/${",[190,1044,47],{"class":253},[190,1046,1047],{"class":200},"}):`",[190,1049,1050],{"class":253},", error)\n",[190,1052,1054],{"class":192,"line":1053},58,[190,1055,558],{"class":253},[190,1057,1059],{"class":192,"line":1058},59,[190,1060,280],{"emptyLinePlaceholder":279},[190,1062,1064,1066,1068,1070,1073,1075,1077,1079,1081,1083,1085,1087,1089],{"class":192,"line":1063},60,[190,1065,601],{"class":253},[190,1067,604],{"class":196},[190,1069,312],{"class":253},[190,1071,1072],{"class":200},"'jobRetrying'",[190,1074,880],{"class":253},[190,1076,883],{"class":620},[190,1078,612],{"class":253},[190,1080,1010],{"class":620},[190,1082,612],{"class":253},[190,1084,47],{"class":620},[190,1086,624],{"class":253},[190,1088,321],{"class":249},[190,1090,629],{"class":253},[190,1092,1094,1096,1098,1100,1103,1105,1108,1110,1112,1114,1117],{"class":192,"line":1093},61,[190,1095,687],{"class":253},[190,1097,567],{"class":196},[190,1099,312],{"class":253},[190,1101,1102],{"class":200},"`Retrying job ${",[190,1104,883],{"class":253},[190,1106,1107],{"class":200},"} (${",[190,1109,1010],{"class":253},[190,1111,1042],{"class":200},[190,1113,47],{"class":253},[190,1115,1116],{"class":200},"})...`",[190,1118,460],{"class":253},[190,1120,1122],{"class":192,"line":1121},62,[190,1123,558],{"class":253},[190,1125,1127],{"class":192,"line":1126},63,[190,1128,280],{"emptyLinePlaceholder":279},[190,1130,1132],{"class":192,"line":1131},64,[190,1133,1134],{"class":286},"// Queue depth monitoring\n",[190,1136,1138,1140,1142,1144,1147,1149,1151],{"class":192,"line":1137},65,[190,1139,564],{"class":253},[190,1141,567],{"class":196},[190,1143,312],{"class":253},[190,1145,1146],{"class":200},"'Pending:'",[190,1148,612],{"class":253},[190,1150,327],{"class":249},[190,1152,1153],{"class":253}," queue.pendingCount)\n",[190,1155,1157,1159,1161,1163,1166,1168,1170],{"class":192,"line":1156},66,[190,1158,564],{"class":253},[190,1160,567],{"class":196},[190,1162,312],{"class":253},[190,1164,1165],{"class":200},"'Active:'",[190,1167,612],{"class":253},[190,1169,327],{"class":249},[190,1171,1172],{"class":253}," queue.activeCount)\n",[190,1174,1176],{"class":192,"line":1175},67,[190,1177,280],{"emptyLinePlaceholder":279},[190,1179,1181],{"class":192,"line":1180},68,[190,1182,1183],{"class":286},"// Teardown: the wrapper releases its handlers; the app closes the socket.\n",[190,1185,1187,1190,1193],{"class":192,"line":1186},69,[190,1188,1189],{"class":253},"queueClient.",[190,1191,1192],{"class":196},"detach",[190,1194,1195],{"class":253},"()\n",[190,1197,1199,1202,1205],{"class":192,"line":1198},70,[190,1200,1201],{"class":253},"client.",[190,1203,1204],{"class":196},"disconnect",[190,1206,1195],{"class":253},[19,1208,1210],{"id":1209},"api-reference","API Reference",[67,1212,64],{"id":1213},"nolagqueue-1",[1215,1216,1218],"h4",{"id":1217},"constructor-options","Constructor Options",[126,1220,1221,1234],{},[129,1222,1223],{},[132,1224,1225,1228,1231],{},[135,1226,1227],{},"Option",[135,1229,1230],{},"Type",[135,1232,1233],{},"Description",[145,1235,1236,1254,1269,1288,1306,1321,1337,1352,1369,1386],{},[132,1237,1238,1243,1248],{},[150,1239,1240],{},[27,1241,1242],{},"client",[150,1244,1245],{},[27,1246,1247],{},"NoLagSocket",[150,1249,1250,1253],{},[50,1251,1252],{},"Required."," The injected core NoLag client the app owns and connects.",[132,1255,1256,1261,1266],{},[150,1257,1258],{},[27,1259,1260],{},"workerId",[150,1262,1263],{},[27,1264,1265],{},"string",[150,1267,1268],{},"Stable worker ID for this client (auto-generated if omitted).",[132,1270,1271,1276,1281],{},[150,1272,1273],{},[27,1274,1275],{},"role",[150,1277,1278],{},[27,1279,1280],{},"'producer' | 'worker' | 'monitor'",[150,1282,1283,1284,1287],{},"Role this client plays in the queue (default ",[27,1285,1286],{},"'monitor'",").",[132,1289,1290,1295,1300],{},[150,1291,1292],{},[27,1293,1294],{},"concurrency",[150,1296,1297],{},[27,1298,1299],{},"number",[150,1301,1302,1303,1287],{},"Max jobs to process concurrently (default ",[27,1304,1305],{},"1",[132,1307,1308,1313,1318],{},[150,1309,1310],{},[27,1311,1312],{},"metadata",[150,1314,1315],{},[27,1316,1317],{},"Record\u003Cstring, unknown>",[150,1319,1320],{},"Optional custom data attached to worker presence.",[132,1322,1323,1327,1331],{},[150,1324,1325],{},[27,1326,217],{},[150,1328,1329],{},[27,1330,1265],{},[150,1332,1333,1334,1287],{},"NoLag app for topic prefixes (default ",[27,1335,1336],{},"'queue'",[132,1338,1339,1344,1349],{},[150,1340,1341],{},[27,1342,1343],{},"queues",[150,1345,1346],{},[27,1347,1348],{},"string[]",[150,1350,1351],{},"Queue names this client should participate in.",[132,1353,1354,1359,1363],{},[150,1355,1356],{},[27,1357,1358],{},"loadBalanceGroup",[150,1360,1361],{},[27,1362,1265],{},[150,1364,1365,1366,1287],{},"Subscribe-level load-balance group; workers in the same group receive jobs round-robin (default ",[27,1367,1368],{},"'queue-workers-{queueName}'",[132,1370,1371,1376,1380],{},[150,1372,1373],{},[27,1374,1375],{},"maxJobCache",[150,1377,1378],{},[27,1379,1299],{},[150,1381,1382,1383,1287],{},"Max jobs cached in memory (default ",[27,1384,1385],{},"1000",[132,1387,1388,1393,1398],{},[150,1389,1390],{},[27,1391,1392],{},"debug",[150,1394,1395],{},[27,1396,1397],{},"boolean",[150,1399,1400,1401,1287],{},"Enable wrapper debug logging (default ",[27,1402,1403],{},"false",[126,1405,1406,1418],{},[129,1407,1408],{},[132,1409,1410,1413,1416],{},[135,1411,1412],{},"Method",[135,1414,1415],{},"Returns",[135,1417,1233],{},[145,1419,1420,1435,1449,1463,1477],{},[132,1421,1422,1427,1432],{},[150,1423,1424],{},[27,1425,1426],{},"ready()",[150,1428,1429],{},[27,1430,1431],{},"Promise\u003Cvoid>",[150,1433,1434],{},"Resolves once wrapper setup completed.",[132,1436,1437,1441,1446],{},[150,1438,1439],{},[27,1440,221],{},[150,1442,1443],{},[27,1444,1445],{},"void",[150,1447,1448],{},"Release this wrapper's handlers and topics; terminal, never closes the socket.",[132,1450,1451,1455,1460],{},[150,1452,1453],{},[27,1454,111],{},[150,1456,1457],{},[27,1458,1459],{},"Promise\u003CQueueRoom>",[150,1461,1462],{},"Subscribe to a named queue. Returns the room instance.",[132,1464,1465,1470,1474],{},[150,1466,1467],{},[27,1468,1469],{},"leaveQueue(name)",[150,1471,1472],{},[27,1473,1431],{},[150,1475,1476],{},"Unsubscribe from a queue and release its resources.",[132,1478,1479,1484,1489],{},[150,1480,1481],{},[27,1482,1483],{},"getOnlineWorkers()",[150,1485,1486],{},[27,1487,1488],{},"Worker[]",[150,1490,1491],{},"Return all workers currently present in the lobby.",[67,1493,1495],{"id":1494},"nolagqueue-events","NoLagQueue Events",[126,1497,1498,1510],{},[129,1499,1500],{},[132,1501,1502,1505,1508],{},[135,1503,1504],{},"Event",[135,1506,1507],{},"Payload",[135,1509,1233],{},[145,1511,1512,1525,1540,1552,1566,1581],{},[132,1513,1514,1519,1522],{},[150,1515,1516],{},[27,1517,1518],{},"connected",[150,1520,1521],{},"none",[150,1523,1524],{},"WebSocket connection established.",[132,1526,1527,1532,1537],{},[150,1528,1529],{},[27,1530,1531],{},"disconnected",[150,1533,1534],{},[27,1535,1536],{},"reason: string",[150,1538,1539],{},"Connection closed.",[132,1541,1542,1547,1549],{},[150,1543,1544],{},[27,1545,1546],{},"reconnected",[150,1548,1521],{},[150,1550,1551],{},"Connection restored; job history replay begins automatically.",[132,1553,1554,1558,1563],{},[150,1555,1556],{},[27,1557,1005],{},[150,1559,1560],{},[27,1561,1562],{},"error: Error",[150,1564,1565],{},"A transport or protocol error occurred.",[132,1567,1568,1573,1578],{},[150,1569,1570],{},[27,1571,1572],{},"workerOnline",[150,1574,1575],{},[27,1576,1577],{},"worker: Worker",[150,1579,1580],{},"A worker joined the lobby.",[132,1582,1583,1588,1592],{},[150,1584,1585],{},[27,1586,1587],{},"workerOffline",[150,1589,1590],{},[27,1591,1577],{},[150,1593,1594],{},"A worker left the lobby.",[67,1596,115],{"id":1597},"queueroom",[126,1599,1600,1613],{},[129,1601,1602],{},[132,1603,1604,1606,1609,1611],{},[135,1605,1412],{},[135,1607,1608],{},"Role",[135,1610,1415],{},[135,1612,1233],{},[145,1614,1615,1645,1667,1683,1699,1718,1735,1755,1772],{},[132,1616,1617,1622,1625,1630],{},[150,1618,1619],{},[27,1620,1621],{},"addJob(opts)",[150,1623,1624],{},"Producer",[150,1626,1627],{},[27,1628,1629],{},"Promise\u003CJob>",[150,1631,1632,1633,612,1636,612,1639,612,1642,230],{},"Enqueue a new job. Accepts ",[27,1634,1635],{},"id?",[27,1637,1638],{},"payload",[27,1640,1641],{},"priority?",[27,1643,1644],{},"maxRetries?",[132,1646,1647,1652,1655,1660],{},[150,1648,1649],{},[27,1650,1651],{},"claimJob(jobId)",[150,1653,1654],{},"Worker",[150,1656,1657],{},[27,1658,1659],{},"Promise\u003CJob | null>",[150,1661,1662,1663,1666],{},"Atomically claim a pending job. Returns ",[27,1664,1665],{},"null"," if another worker claimed it first.",[132,1668,1669,1674,1676,1680],{},[150,1670,1671],{},[27,1672,1673],{},"reportProgress(jobId, progress)",[150,1675,1654],{},[150,1677,1678],{},[27,1679,1431],{},[150,1681,1682],{},"Broadcast a progress value (0-100) on the ephemeral channel.",[132,1684,1685,1690,1692,1696],{},[150,1686,1687],{},[27,1688,1689],{},"completeJob(jobId, result?)",[150,1691,1654],{},[150,1693,1694],{},[27,1695,1431],{},[150,1697,1698],{},"Mark the job as completed with an optional result payload.",[132,1700,1701,1706,1708,1712],{},[150,1702,1703],{},[27,1704,1705],{},"failJob(jobId, error)",[150,1707,1654],{},[150,1709,1710],{},[27,1711,1431],{},[150,1713,1714,1715,1717],{},"Mark the job as failed. Triggers retry if ",[27,1716,47],{}," has not been reached.",[132,1719,1720,1725,1728,1732],{},[150,1721,1722],{},[27,1723,1724],{},"getJob(id)",[150,1726,1727],{},"Monitor",[150,1729,1730],{},[27,1731,1659],{},[150,1733,1734],{},"Fetch the current state of a job by ID.",[132,1736,1737,1742,1744,1749],{},[150,1738,1739],{},[27,1740,1741],{},"getJobs(filter?)",[150,1743,1727],{},[150,1745,1746],{},[27,1747,1748],{},"Promise\u003CJob[]>",[150,1750,1751,1752,1287],{},"Fetch jobs filtered by status (",[27,1753,1754],{},"'pending' | 'active' | 'completed' | 'failed'",[132,1756,1757,1762,1764,1769],{},[150,1758,1759],{},[27,1760,1761],{},"pendingCount",[150,1763,1727],{},[150,1765,1766],{},[27,1767,1768],{},"Promise\u003Cnumber>",[150,1770,1771],{},"Number of jobs currently in the pending state.",[132,1773,1774,1779,1781,1785],{},[150,1775,1776],{},[27,1777,1778],{},"activeCount",[150,1780,1727],{},[150,1782,1783],{},[27,1784,1768],{},[150,1786,1787],{},"Number of jobs currently being processed by workers.",[67,1789,1791],{"id":1790},"queueroom-events","QueueRoom Events",[126,1793,1794,1804],{},[129,1795,1796],{},[132,1797,1798,1800,1802],{},[135,1799,1504],{},[135,1801,1507],{},[135,1803,1233],{},[145,1805,1806,1821,1836,1851,1866,1885,1900,1914,1928,1943],{},[132,1807,1808,1813,1818],{},[150,1809,1810],{},[27,1811,1812],{},"jobAdded",[150,1814,1815],{},[27,1816,1817],{},"{ job: Job }",[150,1819,1820],{},"A new job was added to the queue.",[132,1822,1823,1828,1833],{},[150,1824,1825],{},[27,1826,1827],{},"jobClaimed",[150,1829,1830],{},[27,1831,1832],{},"{ jobId, workerId }",[150,1834,1835],{},"A worker successfully claimed a job.",[132,1837,1838,1843,1848],{},[150,1839,1840],{},[27,1841,1842],{},"jobProgress",[150,1844,1845],{},[27,1846,1847],{},"{ jobId, progress: number, workerId }",[150,1849,1850],{},"A worker reported a progress update. Delivered via the ephemeral channel.",[132,1852,1853,1858,1863],{},[150,1854,1855],{},[27,1856,1857],{},"jobCompleted",[150,1859,1860],{},[27,1861,1862],{},"{ jobId, result?, workerId }",[150,1864,1865],{},"A job was completed successfully.",[132,1867,1868,1873,1878],{},[150,1869,1870],{},[27,1871,1872],{},"jobFailed",[150,1874,1875],{},[27,1876,1877],{},"{ jobId, error, attempt, maxRetries, workerId }",[150,1879,1880,1881,1884],{},"A job failed. If ",[27,1882,1883],{},"attempt \u003C maxRetries"," the job will be retried.",[132,1886,1887,1892,1897],{},[150,1888,1889],{},[27,1890,1891],{},"jobRetrying",[150,1893,1894],{},[27,1895,1896],{},"{ jobId, attempt, maxRetries }",[150,1898,1899],{},"A failed job has been re-queued for another attempt.",[132,1901,1902,1907,1911],{},[150,1903,1904],{},[27,1905,1906],{},"workerJoined",[150,1908,1909],{},[27,1910,1577],{},[150,1912,1913],{},"A worker joined this queue.",[132,1915,1916,1921,1925],{},[150,1917,1918],{},[27,1919,1920],{},"workerLeft",[150,1922,1923],{},[27,1924,1577],{},[150,1926,1927],{},"A worker left this queue.",[132,1929,1930,1935,1940],{},[150,1931,1932],{},[27,1933,1934],{},"replayStart",[150,1936,1937],{},[27,1938,1939],{},"{ count: number }",[150,1941,1942],{},"Job history replay has begun.",[132,1944,1945,1950,1955],{},[150,1946,1947],{},[27,1948,1949],{},"replayEnd",[150,1951,1952],{},[27,1953,1954],{},"{ replayed: number }",[150,1956,1957],{},"Job history replay has completed.",[1959,1960,1961],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":186,"searchDepth":263,"depth":263,"links":1963},[1964,1967,1968,1969,1970],{"id":21,"depth":263,"text":22,"children":1965},[1966],{"id":69,"depth":276,"text":70},{"id":98,"depth":263,"text":99},{"id":174,"depth":263,"text":175},{"id":233,"depth":263,"text":234},{"id":1209,"depth":263,"text":1210,"children":1971},[1972,1973,1974,1975],{"id":1213,"depth":276,"text":64},{"id":1494,"depth":276,"text":1495},{"id":1597,"depth":276,"text":115},{"id":1790,"depth":276,"text":1791},"md",{},"/docs/high-level-sdks/queue",{"title":5,"description":17},"docs/high-level-sdks/queue","xiYSZ03h-_LFA64OGwCSqOX0t28Igea7vzDQ81AVnjE",1788160343954]