From 1424095260ced11b4cae0c46a946cf7416ba1ea5 Mon Sep 17 00:00:00 2001 From: Github Actions for Actionhero Date: Mon, 26 Aug 2024 03:02:36 +0000 Subject: [PATCH] deploy static site @ Mon Aug 26 03:02:36 UTC 2024 --- .nojekyll | 1 + CNAME | 1 + assets/highlight.css | 106 +++ assets/icons.js | 18 + assets/icons.svg | 1 + assets/main.js | 60 ++ assets/navigation.js | 1 + assets/search.js | 1 + assets/style.css | 1448 +++++++++++++++++++++++++++++ classes/Connection.html | 282 ++++++ classes/MultiWorker.html | 272 ++++++ classes/Plugin.html | 14 + classes/Queue.html | 372 ++++++++ classes/Scheduler.html | 252 +++++ classes/Worker.html | 263 ++++++ favicon.ico | Bin 0 -> 1150 bytes index.html | 185 ++++ interfaces/ConnectionOptions.html | 10 + interfaces/ErrorPayload.html | 8 + interfaces/Job.html | 4 + interfaces/Jobs.html | 1 + modules.html | 15 + types/ParsedFailedJobPayload.html | 1 + types/ParsedJob.html | 1 + types/ParsedWorkerPayload.html | 1 + variables/Plugins.html | 1 + 26 files changed, 3319 insertions(+) create mode 100644 .nojekyll create mode 100644 CNAME create mode 100644 assets/highlight.css create mode 100644 assets/icons.js create mode 100644 assets/icons.svg create mode 100644 assets/main.js create mode 100644 assets/navigation.js create mode 100644 assets/search.js create mode 100644 assets/style.css create mode 100644 classes/Connection.html create mode 100644 classes/MultiWorker.html create mode 100644 classes/Plugin.html create mode 100644 classes/Queue.html create mode 100644 classes/Scheduler.html create mode 100644 classes/Worker.html create mode 100644 favicon.ico create mode 100644 index.html create mode 100644 interfaces/ConnectionOptions.html create mode 100644 interfaces/ErrorPayload.html create mode 100644 interfaces/Job.html create mode 100644 interfaces/Jobs.html create mode 100644 modules.html create mode 100644 types/ParsedFailedJobPayload.html create mode 100644 types/ParsedJob.html create mode 100644 types/ParsedWorkerPayload.html create mode 100644 variables/Plugins.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e2ac6616 --- /dev/null +++ b/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..982addb5 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +node-resque.actionherojs.com diff --git a/assets/highlight.css b/assets/highlight.css new file mode 100644 index 00000000..dead2899 --- /dev/null +++ b/assets/highlight.css @@ -0,0 +1,106 @@ +:root { + --light-hl-0: #AF00DB; + --dark-hl-0: #C586C0; + --light-hl-1: #000000; + --dark-hl-1: #D4D4D4; + --light-hl-2: #001080; + --dark-hl-2: #9CDCFE; + --light-hl-3: #A31515; + --dark-hl-3: #CE9178; + --light-hl-4: #0000FF; + --dark-hl-4: #569CD6; + --light-hl-5: #795E26; + --dark-hl-5: #DCDCAA; + --light-hl-6: #008000; + --dark-hl-6: #6A9955; + --light-hl-7: #0070C1; + --dark-hl-7: #4FC1FF; + --light-hl-8: #098658; + --dark-hl-8: #B5CEA8; + --light-hl-9: #267F99; + --dark-hl-9: #4EC9B0; + --light-hl-10: #000000FF; + --dark-hl-10: #D4D4D4; + --light-hl-11: #000000; + --dark-hl-11: #C8C8C8; + --light-code-background: #FFFFFF; + --dark-code-background: #1E1E1E; +} + +@media (prefers-color-scheme: light) { :root { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --code-background: var(--light-code-background); +} } + +@media (prefers-color-scheme: dark) { :root { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --code-background: var(--dark-code-background); +} } + +:root[data-theme='light'] { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --code-background: var(--light-code-background); +} + +:root[data-theme='dark'] { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --code-background: var(--dark-code-background); +} + +.hl-0 { color: var(--hl-0); } +.hl-1 { color: var(--hl-1); } +.hl-2 { color: var(--hl-2); } +.hl-3 { color: var(--hl-3); } +.hl-4 { color: var(--hl-4); } +.hl-5 { color: var(--hl-5); } +.hl-6 { color: var(--hl-6); } +.hl-7 { color: var(--hl-7); } +.hl-8 { color: var(--hl-8); } +.hl-9 { color: var(--hl-9); } +.hl-10 { color: var(--hl-10); } +.hl-11 { color: var(--hl-11); } +pre, code { background: var(--code-background); } diff --git a/assets/icons.js b/assets/icons.js new file mode 100644 index 00000000..e88e8ca7 --- /dev/null +++ b/assets/icons.js @@ -0,0 +1,18 @@ +(function() { + addIcons(); + function addIcons() { + if (document.readyState === "loading") return document.addEventListener("DOMContentLoaded", addIcons); + const svg = document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); + svg.innerHTML = `""`; + svg.style.display = "none"; + if (location.protocol === "file:") updateUseElements(); + } + + function updateUseElements() { + document.querySelectorAll("use").forEach(el => { + if (el.getAttribute("href").includes("#icon-")) { + el.setAttribute("href", el.getAttribute("href").replace(/.*#/, "#")); + } + }); + } +})() \ No newline at end of file diff --git a/assets/icons.svg b/assets/icons.svg new file mode 100644 index 00000000..e371b8b5 --- /dev/null +++ b/assets/icons.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/main.js b/assets/main.js new file mode 100644 index 00000000..35728810 --- /dev/null +++ b/assets/main.js @@ -0,0 +1,60 @@ +"use strict"; +window.translations={"copy":"Copy","copied":"Copied!","normally_hidden":"This member is normally hidden due to your filter settings."}; +"use strict";(()=>{var Pe=Object.create;var ie=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&ie(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Pe(Re(t)):{},De(e||!t||!t.__esModule?ie(n,"default",{value:t,enumerable:!0}):n,t));var ue=Fe((ae,le)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. +`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof ae=="object"?le.exports=n():e.lunr=n()}(this,function(){return t})})()});var se=[];function G(t,e){se.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){se.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!Ve(e)){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r,document.querySelector(".col-sidebar").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};function Ve(t){let e=t.getBoundingClientRect(),n=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(e.bottom<0||e.top-n>=0)}var oe=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var pe=Ae(ue());async function ce(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=pe.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function fe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ce(e,t)}),ce(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{te(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),He(t,i,r,e)}function He(t,e,n,r){n.addEventListener("input",oe(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?Be(e,t):i.key=="ArrowUp"?(de(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(de(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),te(t))})}function te(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=he(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` + ${he(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function de(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function Be(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),te(e)}}function he(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ee(t.substring(s,o)),`${ee(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ee(t.substring(s))),i.join("")}var je={"&":"&","<":"<",">":">","'":"'",'"':"""};function ee(t){return t.replace(/[&<>"'"]/g,e=>je[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",ye="mousemove",N="mouseup",J={x:0,y:0},me=!1,ne=!1,qe=!1,D=!1,ve=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ve?"is-mobile":"not-mobile");ve&&"ontouchstart"in document.documentElement&&(qe=!0,F="touchstart",ye="touchmove",N="touchend");document.addEventListener(F,t=>{ne=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(ye,t=>{if(ne&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(N,()=>{ne=!1});document.addEventListener("click",t=>{me&&(t.preventDefault(),t.stopImmediatePropagation(),me=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(N,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(N,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var re;try{re=localStorage}catch{re={getItem(){return null},setItem(){}}}var Q=re;var ge=document.head.appendChild(document.createElement("style"));ge.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ge.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } +`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var $e=new U;Object.defineProperty(window,"app",{value:$e});fe();we();})(); +/*! Bundled license information: + +lunr/lunr.js: + (** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9 + * Copyright (C) 2020 Oliver Nightingale + * @license MIT + *) + (*! + * lunr.utils + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Set + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.tokenizer + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Pipeline + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Vector + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.stemmer + * Copyright (C) 2020 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + *) + (*! + * lunr.stopWordFilter + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.trimmer + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.TokenSet + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Index + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Builder + * Copyright (C) 2020 Oliver Nightingale + *) +*/ diff --git a/assets/navigation.js b/assets/navigation.js new file mode 100644 index 00000000..c58230e7 --- /dev/null +++ b/assets/navigation.js @@ -0,0 +1 @@ +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4WST0/DMAzFv4vPFbCiDegVwaESWtEOHBAHtzE0Wkiq/EGb0L476obadMnSSw72ez/5OX7/BUs7CwU8KimpsVxJyKBD20IBjUBjyFyPvavWfgvIYMslg2KR3x+ygfDihOVvSm9JhwivmWJUwn3xyASnesr56shRaDyWU75N0xJzIjbz0Er5LwWezzpudd31rxkhXFrSn9hMdv+vmiLz5cpDPmmtdIV7oZBFab4gBSpVHfWXqp6xxVP0jZSxQm2IPSMXxEpVBxHsvuuvIKo649483C2WecCeJPJxYaQLhNOPJkebSGapx5v29vWDmmMthnM/29htfvj4A7LX5LewAwAA" \ No newline at end of file diff --git a/assets/search.js b/assets/search.js new file mode 100644 index 00000000..917f9ede --- /dev/null +++ b/assets/search.js @@ -0,0 +1 @@ +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA61d23LjOJL9F9Wr1s0EePVbT89MRF92u2dmY/vBUVEhSyyX2jKp0aV6Kirq3zcAEmQCSAAp2k+yJSAPCBwkEnlI8Ovq1P95Xt0/fF0977vd6h5EvV51m5d2db/6oe+6dnvZ991qvbqeDqv71fawOZ/b83fzT3efLi+H1dr8srpfrb6tjbUCxGRt23fny+m6vfSnlLl3dllker06bk5td7FbNwNCJvIJsT+qX89JtLncUqTtUKLdca5sKrkU7dTu9umrMqVuQBFZXrvXxL2iVyAd+s3ul+smiTSXW4r01F5+br+k+24utxSp7dJcGMosRXhuvyQRhjK38AxN/39c22vrQehv32TSz5ZY831oTnwCUq7KhplLLUAJORQEkfIlUft/9I9R4+PvPMsWWeL9ckN/OFa3MYK8G39fYDnkfPzBXGafmp7IdmxmJuxu+120T6YSi6z/OzEn381Fltv/PtrvuNByjB+jhMSFFmDoytGZNJVYYH3XHlKu8R0qswDh0HZPl08x+1OJZe1PNH2x3b98+fu1S7pht+AyrL+2h80XIuKygeZSC1DO20/t7npod/EZYRdbgHPZv7Tny+blGOWsVWpZn6muiF8LLrR05kXHZCqxwPrmwBl1q9SS2ddvn6MDYQosG4Nf+u1zYgTGIgvs/9mfnttTtPVzkYX2993Tr9H5jQstG+XfOTBOuQVIH/vTtv3h0G6633WnxNCIskviGmXg18Pu9/Q4+UWXXOFmf2h3P/TXLjrr7WKLcdIQy6yf2pf+c/v3JIZTbhHS5fTl+273TzYiWX4p8r8u1+3zT4ldgFdyUYSx2cX5PpVYsm5eNpfoJZgCi1v+M7H59Rr/c2T362M0FRTzxvW3zenc7n7qHyeYy5dje/5u+j66BS6LQpaTrQ8fVN2ooXdTGbq5c3NCG2BVjQNxZ0omgO7GFgXw7I1IDC++H+HibU5PvMsbC74O7Xi4Pu27X53tfgzWrXEz/lLK2Mij3f8CdhOclqdmxLAa/bb5opJxZPusEm8zS3yTvPliNzaUTb12HzaX23Dvpkps+MXzKdwIzsy6pQ1/2kEQrxF/xqOh21txvIlb0yyYar2iHTTlh1X9p/4xxnq30NsQn7TK477X6tsHPYbOG3fPwtJJEG0KZx7c2JIYCaNt4fHwxtYMsXPIS0Xbg6u+YYva/2zbo5XnYbcIV33LFp1O/QIam2pv2JLHzfb5ctpsFzAZV31li5CQ868xP+XH+9MvbyLo2NZYos7ctBslFwcrJbskcUjpxQGJyi9JBP2RQBjLLEQIbOocjMTGLolyunbdvntKwczFFuIcT/22PZ8ZUFbJhWi0sOIAxReaJEZEpPSnTkqoTKKpdHGSDKYQHyMlK7oT87YrSMuLnv2Is0wiDAmj7w+HX/bnS9tRGTmX1lSNheghkZMmw3Kc82VzSqKYQgsxKEHVQYiJqkn7x/7gq1auHxjKLERIJoMdNHZCmJypaHkOwA1fv8nCjEyxVuWxRTcuyRgltR7HEcjFGJuPrsRx25rnRFIXm5/LLEEgF3psPrrKx20HlG1sPSFtM+ynzS9lzmn/tO82Afnc4o9TcgmavSOgUOLBf9z6qT1fD75XxeanIsvsb3Z+jts2P5RYZD0QxFn2ExFcHGEUAaMIc5klCMrd/y8Z5GAMXGoRi7pdGgQVWnQl++6JcSWo1EKvmnKqCy1HAltn6UlFtQzv9OvjH1TQ5PmoqdwSpH18gdjfsDakAmbL7d3QM+lQ2bYciZPjthlBsu2W2BFyHDcUHhOUWohAB8ZeJLDQ+r7bx42PBZbYpsJtxyEttHxsTx/708uP3WHfxSnlllw0xp/a7fM/0kGNXY47o1GQ/d/Xw2UfiLTRb28Sbrv2WDE3buCNgbeHl4q+GVhkCO4BReNwBkrodiUPKHXTEgOLDMs9oGhszkAJBVYeUCq6YvYeCysVZzGw2s9td/ml749/UXe/EfsnD5So8Xp0fWPfDdim/OuRf1AeSN8hxfAg70LVFrfjfOmPP3a/DZnONL5bfDGudrx0bOq7OVz2FsRUiOQ7uHCcxECgl32iD2NrPwunP/KG6jUoVCjg8zESDwRYgBbP3/QtIh7K8PWbLJnIFGu1HFt0i6vHEFEvH7ft6OWU9ZQ0HrUf2+NgEM4eh4GUxlho/eO120aNjwWW2KZ2sth0bCcbt2zdZkaZjt9eFrUdCt+w+VTk5iFEbyWJINylbiIZqvTEbWHI9zy2H/tT+7fAY0kY1i3JvDz7xvCPl/bEAXMKLsEa2vvbsMVhXNlccvGVccCcgkwsKRxXPpPw8+a03zweJpjz8huXaFPJu5XGBgUmjQ7g9MbPem4iinXnVYpCJ27n+Kl/vAF6Lv0azP/pUeQQBxyLvgbt1u59q579p7qRnYlpyt6IJ4qZrvMDz+6NvXsVnX/cbK0nqM0dtbH5YGdxn5/4Ft8NpenL8VsagPzUny83YI7FXwl67E+3gI7FXwm621w2j5tzewMwqvJKcPVxPuI7utLouM4r4Q99f8T7/DT4XOOV0G7MkobmH6aRgLZPuUgDc8+7SMCet5vOfl4qDY3r3A6PfRR+4AThpp43IR5eILtuenZgLkO3N/KkCf1sRBgk9UyEDRWNMJIg5vEHEUMLPvHwRth3Hz7su137H/OF5DfGPJMxWggOgRMpkm1LBImv7fbBfGoboa9wbEmQ8SEWxddebORvSsh3b89HxvDv/InkbPVj9lJ7fquBrP14FC2+s+GAuTe4R+FSN7UHALmkCgKm2GVVPMYvWFtYgp54YI5qwy3Pst3SkmjyYUFD/Lv4o61J37nPYZ59W04cMHp/DgfMvxc/Cpi+/54D6j+uEQVNP6Jhg75fr4bV4f7r6nN7OqsBuV+JO3nXrNarj/v2sFMnupks6LZ/eWl1aLLrt1f95/ux2P+1KsmqCg+lv8tW64dsLas7WVXv368fTGX9g/7C2Ji/0RVhtX6AtZR3ZdNYFcGrCFZFsVo/iLUUd6KsrYrCqyisinK1fpDrvL6TpbQqSq+itCrmq/VDvs7lnSgKq2LuVcytisVq/VBQnVN4FQurYrlaP5RUU0uvYmlVrFbrh4qqWHkVK6tivVo/1GtZ3Em7pbVXr7bqNav1Q0MBNl7Fxh5/RQfI1hLuMrAxwecOOOQJs4egj80fECHKgs8gsCkEMkQ+8EkENotAcQOA6GPweQQ2kUDRAwTZaJ9LYJMJFEVArmVzVzud5dMJbD5BFaIw+IwCm1IQ4hT4pAKbVaC4AjnFK/CJBTazhGZWQVUWPrOEzSyhmUXOPeFTSziuSbEFyPknCO9kc0soukBN+Rnhk0vY5BKaXOREFD67hM0uofgiMrKyzy5hs0sowgggK/v0Eja9hGKMEGRln1/C5pdQnBGkRxc+w4TNMKE4I0iGCZ9hwmaYVJwRJMOkzzBpM0wqzgiSYdJnmLQZJvXqRzJM+gyTzgKovVdNVibWQJthUnFGkAyTPsOkzTCpOCNJhkmfYdJmmFSckUBNDOkzTNoMk4ozkmSY9BkmbYZJxRlJxww+w6TNMKk4I8m4QfoMkzbDcsUZSTIs9xmW2wzLFWckybDcZ1huMyxXnJEkw3KfYbnNsFzHWCTDcp9huRNmKc5IkmE5EWnZDMsVZ3KSYbnPsNxmWK44k5MMy32G5TbDcsWZnGRY7jMstxmWK87kJMNyn2G5zbBccSYnfVjuMyy3GVYozuTFWtR3TZZblQufYYXNsEJxJi+pDit8hhU2wwoRjPwKn2GFzbBCcSaviGCm8AlW2AQrdCBPrrCFT7DCieWLcH8R4bxNsEITjKR24ROssAlWVGFkn2CFTbBCUaYg50XhE6ywCVY04ZHyCVbYBCsVZQoq3i19fpU2v0rFmEIQo1z69CptepWKMAU5pUqfXqVNr1IG+7r0+VXa/Crz4BX79CptepVFsKtLn16ls10sg91FbBhtdpU6wieXqdJnV2mzq9TsKsjKPrtKm12l4ktRUq32yVXa5Ko0uSoKuPLZVdnsqjS7yFWq8ulV2fSqRGjrWfnsqmx2VcHtY+WTq7LJVQW3j5VPrsomV6UTEQ21jat8clU2uarw4lj57KqcfITiS5kRY1wRGQmbXJWiS0nuLCqfXJVNrirsuiqfXZXNrjqY1ap9ctU2uWpFl5IMB2qfXLVNrloE9/m1z67aZlctQ/v82mdXbbOrVoQpJTXItU+v2qZXHcxz1T67aptdtU515VSjfXLVNrnqKpS08rlVO+kuzS0yvq6JlJfNrToc2dc+t2qbW01wWWx8bjU2t5pg2qvxqdXY1GqCedPGZ1ZjM6uRId/T+MxqbGY1mlnkZqTxmdXYzGrCjqvxqdXY1GrKYEKl8bnV2NxqqqD/aHx2NTa7Gs0ucg/V+OxqnIxqcFlsiJyqm1RVhCnJpW34za6Ovhvra+9FBqrDb259J7eaiZC/H35yqzvp1Uxxp8qoIRt+c+s7KdZM0acil4zhN7e+k2bNFIMq0nkPv7n1nUxrpkhUkbHn8Jtb38m2Zjp/T3nD4Se3upNwzepgajsjcq6Zk3TNFJkqMpobfnPrO+TTSfqKnOpA5fS9pD6Es9xkXt8hn07W04luKrXv5vZ1vp5eA4FK77v5fZ2zp3PlVIbfTfHrrD25EgKV43eT/DpxX5E+B6g8v5voh9BiClSm30316/x9RfsdKt3v5vt1Cr+i/Q6V8XdS/qCz+DW5zQUi6Q9O1h9EWFAi0v7g5P1BBBdXIBL/4GT+QQTXVyBS/+Dk/kGn8+kEKRDZf3DS/yDCqywQAgA4CgDopD7t9AkJABwNAHRaP+D0CRUAHBkAdGa/pp0+IQSAowSATu7XtNMntABwxADQ+f2advqEHACOHgA6xV/TYhehCIAjCYDO8tdkLAuEKACOKgA60R9wu4QuAI4wADrXTzsuQhkARxoAne2v6VWDEAfAUQdAJ/xJx0WoA+DIA6Az/jXtNgmBAByFAHTSn3YchEQAjkYAOu0fmHqESgCOTAB5cDcBhE4AjlAAOvcfWPEJqQAcrQDycCoXCLUAHLkAtAJQ08sGIRiAoxiAFgHoeImQDMDRDGAQDahkMhCiATiqAWghgPb6hGwAjm4AeTivC4RyAI50AFoNqOk1kxAPwFEPQAsCDb1mEvoBOAICaE2gof0uISGAoyGAlgUa2u8SKgI4MgJoZaCh4zVCSABHSYAinOsFQkwAR00ALRA0tN8m9ARwBAXQGkFD+21CUgBHUwAtEzS04yRUBXBkBdBKQUO7PkJYAEdZAC0WNPTkJbQFcMQF0HpBQ/OXkBfA0RegHO4goglMaAzgiAyghQPIaAYTQgM4SgOUg/ujKUyIDeCoDaAFBMjo2IEQHMBRHECrCJDRJCRUB3BkBxh1B5qFhPIAjvQAZdgJEuIDOOoDaEGBTKUBIT+Aoz+AlhQgoycBIUGAo0GA1hXoFYRQIcCRIUArCwEfRAgR4CgRoMUFWpIEQosAR4wALTAEfBihR4AjSEAV8YGEJgGOKAGDKpHRToQQJsBRJqAKy6pAaBPgiBOg9QZ660SoE+DIE1ANaT7aiRESBTgaBWjZgQ7ACJECHJUCIjIFEDoFOEIFaPGBVP6AkCrA0SpAyw+B3ifUCnDkCtAKBH0fABCCBTiKBdRBNR8IzQIc0QK0DkHLj0DIFuDoFjAIF1SqFQjlAhzpArQcQYuQQKgX4MgXUIelVyAkDPOdvpv7c6vOG/1xuKv74WF6VuLranwQ6D4vzO3lX1dFtrr/+m29Korxsxo+Szl8qthy+KMw31TC/DF9M1ZWLLj/+u3bfKO4/tq0U/+mGq6fPJ/eLjo3rMnmhqmgkm1rekAJ2RLIVsFs1+GwM2/7my3Nh5d8XUnJNTSek6QecJhNSYlM1TxT+jkNNHgVGrxpkKYB4LUPPZswWy6Q5SozBkueQX1wATGkdYOHlHfJgzFqTAGPacYypg8SMufYzqYq3C7gUU2bGk85R1eIZpPKoLAsDY8BoVEt0aiC6XuusXbT9YfddK4Z4htqW87sL3MKIiIGapuZ8cNnbf6H/Bbj9vzCc+IWK3t7biHfYcg7Oqra/J/x+Dfbnx5ARhzExCmYxMGnEM2mMJtNPw6fxsU25nth/mB6jfl5dQSXoZ6GktfX+g2+yBeiNgueaxg96sailEB8lzznrO3oiXzQx0WgIcnxkPCYuGsPj18+Tu8NRi1D64aouLaoZQP1tmCOWntwr00iWsuCa8Vzw4BYK3g9ZF4ujozgfuYxX58VhnzlbKA2Tm6coybMMK5F5WOZCJ5LrvDan/F6jVi7ADk+wfOeoxWb7IDILnhkH+3sLWoCWqAFb20Yn3pEvhy1pWxGL9OYsWB2lTI6PceLHQwaX7UfYhlTpxuqMyYezdGOiC7YQzLn0GRPr9Zbc1oiMoq9oGQOqzG6G86ARNYw1QRzUszPvqKBQWQrp8nBm6rmfbjIbSCq5DyqoEdHUavQlC/NzKx5IzsY3A5nWaCmIQbmvNmgX4+hwxzzaDwyh1ooRyLXvHEYTo1DY4npm/PWx6f28tx+sUNLFEazbAxH6eB5hHlf8vpob41/hTpZ3U3BsqCPkEY2KmyD5431aXnIBF4xMsOfPB//KHnj9Ef/6C35OOgueG5rOGAYdTPu5bFJ1fjZmJ2VmPa4vA54bi33gJZd3rWaN2qhrQFqZl6OzeQ1ZjDmNClH/o+5ITu03dPlkxXcoLBE8LpfrRaH6wZbwWsR08b22RpDgTpY8pzldJ4RnnCYTiXvel7UUae+P6pxDoMZNejy2OuiqzK5lcZstYT5Q/IY1c2HR+ErxjOz5PVcp4+HQ+TGTqbgjaC96IGVpBmdt0kvwbTn4bni4bUEyLi13RmNm+kMvEWR2ADi/YFp4Dgrx8/GfC/MH2beKpGDBTu+ssYLSUvkkxve5D3qtzwOi/Ef/SMRtxWoo0pevwxGHW+fI04xs3eDnWEWES3L0URgEoy6PjRk5Uiq0oxIzZuiRDZKiRso3OXNodHOfnzRAVoqcfABzKHdd0/+5gfTPmN22rPjD7ETK5k9NB7sjFwh7h/Ji4UGK8S0y1H/FCaAqHix0XRCGfJduJeKKaPNvFT9cjg0K9HyUTOHrj8c/KHDEUnGJJQ+EhGPHfap3OmM3nqJLgs1p+Jdlr+HxkwyWsPY3cUYrpej56/MfnQKFKdx4XkTjW4nYRAFmblZOsWEqVzwqKwN9eOp2miQcayRma03cyfkJ7IBzQsTrDa8WT++9AsNOM5tZrwWjUcloomKFgGz6vE6bHjbz+ZwOMxv+0GNQzO2NpaBFxoMloltMuo85obPvIgNNQx77oznQU7DEbSIYNhIwZts2sim2wWvDg1nzvMm2uT5ct0+u7ulHE3knBchn66dm05ARrgXad5tgjocWamMr8imoItHfnXOppebUPeLIOfJa+F5fCenm+JGE4GZGDKW7IwdYgZzvRvfNoF6DLWlNpEPTBsJHjemN1kiu6i7GraVi00stF7lPEcxvOYCBRp41JhZcmVj3x3NW02QMbwzYmoT3kpeootiiuLKxvmyeTnauw20WjCTlf6etEALeTkuwqXJdBhxLDd/MJd6Sm5EONLQjCk3TO8VQiulFTtMGRkeR2j9HQ0LJyB9v14d98dWx+r3D++/fft/gnNJ++ScAAA="; \ No newline at end of file diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 00000000..9d619a64 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,1448 @@ +:root { + /* Light */ + --light-color-background: #f2f4f8; + --light-color-background-secondary: #eff0f1; + --light-color-warning-text: #222; + --light-color-background-warning: #e6e600; + --light-color-icon-background: var(--light-color-background); + --light-color-accent: #c5c7c9; + --light-color-active-menu-item: var(--light-color-accent); + --light-color-text: #222; + --light-color-text-aside: #6e6e6e; + --light-color-link: #1f70c2; + --light-color-focus-outline: #3584e4; + + --light-color-ts-keyword: #056bd6; + --light-color-ts-project: #b111c9; + --light-color-ts-module: var(--light-color-ts-project); + --light-color-ts-namespace: var(--light-color-ts-project); + --light-color-ts-enum: #7e6f15; + --light-color-ts-enum-member: var(--light-color-ts-enum); + --light-color-ts-variable: #4760ec; + --light-color-ts-function: #572be7; + --light-color-ts-class: #1f70c2; + --light-color-ts-interface: #108024; + --light-color-ts-constructor: var(--light-color-ts-class); + --light-color-ts-property: var(--light-color-ts-variable); + --light-color-ts-method: var(--light-color-ts-function); + --light-color-ts-call-signature: var(--light-color-ts-method); + --light-color-ts-index-signature: var(--light-color-ts-property); + --light-color-ts-constructor-signature: var(--light-color-ts-constructor); + --light-color-ts-parameter: var(--light-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --light-color-ts-type-parameter: #a55c0e; + --light-color-ts-accessor: var(--light-color-ts-property); + --light-color-ts-get-signature: var(--light-color-ts-accessor); + --light-color-ts-set-signature: var(--light-color-ts-accessor); + --light-color-ts-type-alias: #d51270; + /* reference not included as links will be colored with the kind that it points to */ + --light-color-document: #000000; + + --light-external-icon: url("data:image/svg+xml;utf8,"); + --light-color-scheme: light; + + /* Dark */ + --dark-color-background: #2b2e33; + --dark-color-background-secondary: #1e2024; + --dark-color-background-warning: #bebe00; + --dark-color-warning-text: #222; + --dark-color-icon-background: var(--dark-color-background-secondary); + --dark-color-accent: #9096a2; + --dark-color-active-menu-item: #5d5d6a; + --dark-color-text: #f5f5f5; + --dark-color-text-aside: #dddddd; + --dark-color-link: #00aff4; + --dark-color-focus-outline: #4c97f2; + + --dark-color-ts-keyword: #3399ff; + --dark-color-ts-project: #e358ff; + --dark-color-ts-module: var(--dark-color-ts-project); + --dark-color-ts-namespace: var(--dark-color-ts-project); + --dark-color-ts-enum: #f4d93e; + --dark-color-ts-enum-member: var(--dark-color-ts-enum); + --dark-color-ts-variable: #798dff; + --dark-color-ts-function: #a280ff; + --dark-color-ts-class: #8ac4ff; + --dark-color-ts-interface: #6cff87; + --dark-color-ts-constructor: var(--dark-color-ts-class); + --dark-color-ts-property: var(--dark-color-ts-variable); + --dark-color-ts-method: var(--dark-color-ts-function); + --dark-color-ts-call-signature: var(--dark-color-ts-method); + --dark-color-ts-index-signature: var(--dark-color-ts-property); + --dark-color-ts-constructor-signature: var(--dark-color-ts-constructor); + --dark-color-ts-parameter: var(--dark-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --dark-color-ts-type-parameter: #e07d13; + --dark-color-ts-accessor: var(--dark-color-ts-property); + --dark-color-ts-get-signature: var(--dark-color-ts-accessor); + --dark-color-ts-set-signature: var(--dark-color-ts-accessor); + --dark-color-ts-type-alias: #ff6492; + /* reference not included as links will be colored with the kind that it points to */ + --dark-color-document: #ffffff; + + --dark-external-icon: url("data:image/svg+xml;utf8,"); + --dark-color-scheme: dark; +} + +@media (prefers-color-scheme: light) { + :root { + --color-background: var(--light-color-background); + --color-background-secondary: var(--light-color-background-secondary); + --color-background-warning: var(--light-color-background-warning); + --color-warning-text: var(--light-color-warning-text); + --color-icon-background: var(--light-color-icon-background); + --color-accent: var(--light-color-accent); + --color-active-menu-item: var(--light-color-active-menu-item); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + --color-focus-outline: var(--light-color-focus-outline); + + --color-ts-keyword: var(--light-color-ts-keyword); + --color-ts-module: var(--light-color-ts-module); + --color-ts-namespace: var(--light-color-ts-namespace); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-enum-member: var(--light-color-ts-enum-member); + --color-ts-variable: var(--light-color-ts-variable); + --color-ts-function: var(--light-color-ts-function); + --color-ts-class: var(--light-color-ts-class); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-constructor: var(--light-color-ts-constructor); + --color-ts-property: var(--light-color-ts-property); + --color-ts-method: var(--light-color-ts-method); + --color-ts-call-signature: var(--light-color-ts-call-signature); + --color-ts-index-signature: var(--light-color-ts-index-signature); + --color-ts-constructor-signature: var( + --light-color-ts-constructor-signature + ); + --color-ts-parameter: var(--light-color-ts-parameter); + --color-ts-type-parameter: var(--light-color-ts-type-parameter); + --color-ts-accessor: var(--light-color-ts-accessor); + --color-ts-get-signature: var(--light-color-ts-get-signature); + --color-ts-set-signature: var(--light-color-ts-set-signature); + --color-ts-type-alias: var(--light-color-ts-type-alias); + --color-document: var(--light-color-document); + + --external-icon: var(--light-external-icon); + --color-scheme: var(--light-color-scheme); + } +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--dark-color-background); + --color-background-secondary: var(--dark-color-background-secondary); + --color-background-warning: var(--dark-color-background-warning); + --color-warning-text: var(--dark-color-warning-text); + --color-icon-background: var(--dark-color-icon-background); + --color-accent: var(--dark-color-accent); + --color-active-menu-item: var(--dark-color-active-menu-item); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + --color-focus-outline: var(--dark-color-focus-outline); + + --color-ts-keyword: var(--dark-color-ts-keyword); + --color-ts-module: var(--dark-color-ts-module); + --color-ts-namespace: var(--dark-color-ts-namespace); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-enum-member: var(--dark-color-ts-enum-member); + --color-ts-variable: var(--dark-color-ts-variable); + --color-ts-function: var(--dark-color-ts-function); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-constructor: var(--dark-color-ts-constructor); + --color-ts-property: var(--dark-color-ts-property); + --color-ts-method: var(--dark-color-ts-method); + --color-ts-call-signature: var(--dark-color-ts-call-signature); + --color-ts-index-signature: var(--dark-color-ts-index-signature); + --color-ts-constructor-signature: var( + --dark-color-ts-constructor-signature + ); + --color-ts-parameter: var(--dark-color-ts-parameter); + --color-ts-type-parameter: var(--dark-color-ts-type-parameter); + --color-ts-accessor: var(--dark-color-ts-accessor); + --color-ts-get-signature: var(--dark-color-ts-get-signature); + --color-ts-set-signature: var(--dark-color-ts-set-signature); + --color-ts-type-alias: var(--dark-color-ts-type-alias); + --color-document: var(--dark-color-document); + + --external-icon: var(--dark-external-icon); + --color-scheme: var(--dark-color-scheme); + } +} + +html { + color-scheme: var(--color-scheme); +} + +body { + margin: 0; +} + +:root[data-theme="light"] { + --color-background: var(--light-color-background); + --color-background-secondary: var(--light-color-background-secondary); + --color-background-warning: var(--light-color-background-warning); + --color-warning-text: var(--light-color-warning-text); + --color-icon-background: var(--light-color-icon-background); + --color-accent: var(--light-color-accent); + --color-active-menu-item: var(--light-color-active-menu-item); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + --color-focus-outline: var(--light-color-focus-outline); + + --color-ts-keyword: var(--light-color-ts-keyword); + --color-ts-module: var(--light-color-ts-module); + --color-ts-namespace: var(--light-color-ts-namespace); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-enum-member: var(--light-color-ts-enum-member); + --color-ts-variable: var(--light-color-ts-variable); + --color-ts-function: var(--light-color-ts-function); + --color-ts-class: var(--light-color-ts-class); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-constructor: var(--light-color-ts-constructor); + --color-ts-property: var(--light-color-ts-property); + --color-ts-method: var(--light-color-ts-method); + --color-ts-call-signature: var(--light-color-ts-call-signature); + --color-ts-index-signature: var(--light-color-ts-index-signature); + --color-ts-constructor-signature: var( + --light-color-ts-constructor-signature + ); + --color-ts-parameter: var(--light-color-ts-parameter); + --color-ts-type-parameter: var(--light-color-ts-type-parameter); + --color-ts-accessor: var(--light-color-ts-accessor); + --color-ts-get-signature: var(--light-color-ts-get-signature); + --color-ts-set-signature: var(--light-color-ts-set-signature); + --color-ts-type-alias: var(--light-color-ts-type-alias); + --color-document: var(--light-color-document); + + --external-icon: var(--light-external-icon); + --color-scheme: var(--light-color-scheme); +} + +:root[data-theme="dark"] { + --color-background: var(--dark-color-background); + --color-background-secondary: var(--dark-color-background-secondary); + --color-background-warning: var(--dark-color-background-warning); + --color-warning-text: var(--dark-color-warning-text); + --color-icon-background: var(--dark-color-icon-background); + --color-accent: var(--dark-color-accent); + --color-active-menu-item: var(--dark-color-active-menu-item); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + --color-focus-outline: var(--dark-color-focus-outline); + + --color-ts-keyword: var(--dark-color-ts-keyword); + --color-ts-module: var(--dark-color-ts-module); + --color-ts-namespace: var(--dark-color-ts-namespace); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-enum-member: var(--dark-color-ts-enum-member); + --color-ts-variable: var(--dark-color-ts-variable); + --color-ts-function: var(--dark-color-ts-function); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-constructor: var(--dark-color-ts-constructor); + --color-ts-property: var(--dark-color-ts-property); + --color-ts-method: var(--dark-color-ts-method); + --color-ts-call-signature: var(--dark-color-ts-call-signature); + --color-ts-index-signature: var(--dark-color-ts-index-signature); + --color-ts-constructor-signature: var( + --dark-color-ts-constructor-signature + ); + --color-ts-parameter: var(--dark-color-ts-parameter); + --color-ts-type-parameter: var(--dark-color-ts-type-parameter); + --color-ts-accessor: var(--dark-color-ts-accessor); + --color-ts-get-signature: var(--dark-color-ts-get-signature); + --color-ts-set-signature: var(--dark-color-ts-set-signature); + --color-ts-type-alias: var(--dark-color-ts-type-alias); + --color-document: var(--dark-color-document); + + --external-icon: var(--dark-external-icon); + --color-scheme: var(--dark-color-scheme); +} + +*:focus-visible, +.tsd-accordion-summary:focus-visible svg { + outline: 2px solid var(--color-focus-outline); +} + +.always-visible, +.always-visible .tsd-signatures { + display: inherit !important; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + line-height: 1.2; +} + +h1 { + font-size: 1.875rem; + margin: 0.67rem 0; +} + +h2 { + font-size: 1.5rem; + margin: 0.83rem 0; +} + +h3 { + font-size: 1.25rem; + margin: 1rem 0; +} + +h4 { + font-size: 1.05rem; + margin: 1.33rem 0; +} + +h5 { + font-size: 1rem; + margin: 1.5rem 0; +} + +h6 { + font-size: 0.875rem; + margin: 2.33rem 0; +} + +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +.container { + max-width: 1700px; + padding: 0 2rem; +} + +/* Footer */ +footer { + border-top: 1px solid var(--color-accent); + padding-top: 1rem; + padding-bottom: 1rem; + max-height: 3.5rem; +} +footer > p { + margin: 0 1em; +} + +.container-main { + margin: 0 auto; + /* toolbar, footer, margin */ + min-height: calc(100vh - 41px - 56px - 4rem); +} + +@keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes fade-out { + from { + opacity: 1; + visibility: visible; + } + to { + opacity: 0; + } +} +@keyframes fade-in-delayed { + 0% { + opacity: 0; + } + 33% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@keyframes fade-out-delayed { + 0% { + opacity: 1; + visibility: visible; + } + 66% { + opacity: 0; + } + 100% { + opacity: 0; + } +} +@keyframes pop-in-from-right { + from { + transform: translate(100%, 0); + } + to { + transform: translate(0, 0); + } +} +@keyframes pop-out-to-right { + from { + transform: translate(0, 0); + visibility: visible; + } + to { + transform: translate(100%, 0); + } +} +body { + background: var(--color-background); + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", + Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; + font-size: 16px; + color: var(--color-text); +} + +a { + color: var(--color-link); + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +a.external[target="_blank"] { + background-image: var(--external-icon); + background-position: top 3px right; + background-repeat: no-repeat; + padding-right: 13px; +} +a.tsd-anchor-link { + color: var(--color-text); +} + +code, +pre { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + padding: 0.2em; + margin: 0; + font-size: 0.875rem; + border-radius: 0.8em; +} + +pre { + position: relative; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; + padding: 10px; + border: 1px solid var(--color-accent); +} +pre code { + padding: 0; + font-size: 100%; +} +pre > button { + position: absolute; + top: 10px; + right: 10px; + opacity: 0; + transition: opacity 0.1s; + box-sizing: border-box; +} +pre:hover > button, +pre > button.visible { + opacity: 1; +} + +blockquote { + margin: 1em 0; + padding-left: 1em; + border-left: 4px solid gray; +} + +.tsd-typography { + line-height: 1.333em; +} +.tsd-typography ul { + list-style: square; + padding: 0 0 0 20px; + margin: 0; +} +.tsd-typography .tsd-index-panel h3, +.tsd-index-panel .tsd-typography h3, +.tsd-typography h4, +.tsd-typography h5, +.tsd-typography h6 { + font-size: 1em; +} +.tsd-typography h5, +.tsd-typography h6 { + font-weight: normal; +} +.tsd-typography p, +.tsd-typography ul, +.tsd-typography ol { + margin: 1em 0; +} +.tsd-typography table { + border-collapse: collapse; + border: none; +} +.tsd-typography td, +.tsd-typography th { + padding: 6px 13px; + border: 1px solid var(--color-accent); +} +.tsd-typography thead, +.tsd-typography tr:nth-child(even) { + background-color: var(--color-background-secondary); +} + +.tsd-breadcrumb { + margin: 0; + padding: 0; + color: var(--color-text-aside); +} +.tsd-breadcrumb a { + color: var(--color-text-aside); + text-decoration: none; +} +.tsd-breadcrumb a:hover { + text-decoration: underline; +} +.tsd-breadcrumb li { + display: inline; +} +.tsd-breadcrumb li:after { + content: " / "; +} + +.tsd-comment-tags { + display: flex; + flex-direction: column; +} +dl.tsd-comment-tag-group { + display: flex; + align-items: center; + overflow: hidden; + margin: 0.5em 0; +} +dl.tsd-comment-tag-group dt { + display: flex; + margin-right: 0.5em; + font-size: 0.875em; + font-weight: normal; +} +dl.tsd-comment-tag-group dd { + margin: 0; +} +code.tsd-tag { + padding: 0.25em 0.4em; + border: 0.1em solid var(--color-accent); + margin-right: 0.25em; + font-size: 70%; +} +h1 code.tsd-tag:first-of-type { + margin-left: 0.25em; +} + +dl.tsd-comment-tag-group dd:before, +dl.tsd-comment-tag-group dd:after { + content: " "; +} +dl.tsd-comment-tag-group dd pre, +dl.tsd-comment-tag-group dd:after { + clear: both; +} +dl.tsd-comment-tag-group p { + margin: 0; +} + +.tsd-panel.tsd-comment .lead { + font-size: 1.1em; + line-height: 1.333em; + margin-bottom: 2em; +} +.tsd-panel.tsd-comment .lead:last-child { + margin-bottom: 0; +} + +.tsd-filter-visibility h4 { + font-size: 1rem; + padding-top: 0.75rem; + padding-bottom: 0.5rem; + margin: 0; +} +.tsd-filter-item:not(:last-child) { + margin-bottom: 0.5rem; +} +.tsd-filter-input { + display: flex; + width: -moz-fit-content; + width: fit-content; + align-items: center; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; +} +.tsd-filter-input input[type="checkbox"] { + cursor: pointer; + position: absolute; + width: 1.5em; + height: 1.5em; + opacity: 0; +} +.tsd-filter-input input[type="checkbox"]:disabled { + pointer-events: none; +} +.tsd-filter-input svg { + cursor: pointer; + width: 1.5em; + height: 1.5em; + margin-right: 0.5em; + border-radius: 0.33em; + /* Leaving this at full opacity breaks event listeners on Firefox. + Don't remove unless you know what you're doing. */ + opacity: 0.99; +} +.tsd-filter-input input[type="checkbox"]:focus-visible + svg { + outline: 2px solid var(--color-focus-outline); +} +.tsd-checkbox-background { + fill: var(--color-accent); +} +input[type="checkbox"]:checked ~ svg .tsd-checkbox-checkmark { + stroke: var(--color-text); +} +.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-background { + fill: var(--color-background); + stroke: var(--color-accent); + stroke-width: 0.25rem; +} +.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-checkmark { + stroke: var(--color-accent); +} + +.settings-label { + font-weight: bold; + text-transform: uppercase; + display: inline-block; +} + +.tsd-filter-visibility .settings-label { + margin: 0.75rem 0 0.5rem 0; +} + +.tsd-theme-toggle .settings-label { + margin: 0.75rem 0.75rem 0 0; +} + +.tsd-hierarchy { + list-style: square; + margin: 0; +} +.tsd-hierarchy .target { + font-weight: bold; +} + +.tsd-full-hierarchy:not(:last-child) { + margin-bottom: 1em; + padding-bottom: 1em; + border-bottom: 1px solid var(--color-accent); +} +.tsd-full-hierarchy, +.tsd-full-hierarchy ul { + list-style: none; + margin: 0; + padding: 0; +} +.tsd-full-hierarchy ul { + padding-left: 1.5rem; +} +.tsd-full-hierarchy a { + padding: 0.25rem 0 !important; + font-size: 1rem; + display: inline-flex; + align-items: center; + color: var(--color-text); +} + +.tsd-panel-group.tsd-index-group { + margin-bottom: 0; +} +.tsd-index-panel .tsd-index-list { + list-style: none; + line-height: 1.333em; + margin: 0; + padding: 0.25rem 0 0 0; + overflow: hidden; + display: grid; + grid-template-columns: repeat(3, 1fr); + column-gap: 1rem; + grid-template-rows: auto; +} +@media (max-width: 1024px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(2, 1fr); + } +} +@media (max-width: 768px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(1, 1fr); + } +} +.tsd-index-panel .tsd-index-list li { + -webkit-page-break-inside: avoid; + -moz-page-break-inside: avoid; + -ms-page-break-inside: avoid; + -o-page-break-inside: avoid; + page-break-inside: avoid; +} + +.tsd-flag { + display: inline-block; + padding: 0.25em 0.4em; + border-radius: 4px; + color: var(--color-comment-tag-text); + background-color: var(--color-comment-tag); + text-indent: 0; + font-size: 75%; + line-height: 1; + font-weight: normal; +} + +.tsd-anchor { + position: relative; + top: -100px; +} + +.tsd-member { + position: relative; +} +.tsd-member .tsd-anchor + h3 { + display: flex; + align-items: center; + margin-top: 0; + margin-bottom: 0; + border-bottom: none; +} + +.tsd-navigation.settings { + margin: 1rem 0; +} +.tsd-navigation > a, +.tsd-navigation .tsd-accordion-summary { + width: calc(100% - 0.25rem); + display: flex; + align-items: center; +} +.tsd-navigation a, +.tsd-navigation summary > span, +.tsd-page-navigation a { + display: flex; + width: calc(100% - 0.25rem); + align-items: center; + padding: 0.25rem; + color: var(--color-text); + text-decoration: none; + box-sizing: border-box; +} +.tsd-navigation a.current, +.tsd-page-navigation a.current { + background: var(--color-active-menu-item); +} +.tsd-navigation a:hover, +.tsd-page-navigation a:hover { + text-decoration: underline; +} +.tsd-navigation ul, +.tsd-page-navigation ul { + margin-top: 0; + margin-bottom: 0; + padding: 0; + list-style: none; +} +.tsd-navigation li, +.tsd-page-navigation li { + padding: 0; + max-width: 100%; +} +.tsd-navigation .tsd-nav-link { + display: none; +} +.tsd-nested-navigation { + margin-left: 3rem; +} +.tsd-nested-navigation > li > details { + margin-left: -1.5rem; +} +.tsd-small-nested-navigation { + margin-left: 1.5rem; +} +.tsd-small-nested-navigation > li > details { + margin-left: -1.5rem; +} + +.tsd-page-navigation-section { + margin-left: 10px; +} +.tsd-page-navigation-section > summary { + padding: 0.25rem; +} +.tsd-page-navigation-section > div { + margin-left: 20px; +} +.tsd-page-navigation ul { + padding-left: 1.75rem; +} + +#tsd-sidebar-links a { + margin-top: 0; + margin-bottom: 0.5rem; + line-height: 1.25rem; +} +#tsd-sidebar-links a:last-of-type { + margin-bottom: 0; +} + +a.tsd-index-link { + padding: 0.25rem 0 !important; + font-size: 1rem; + line-height: 1.25rem; + display: inline-flex; + align-items: center; + color: var(--color-text); +} +.tsd-accordion-summary { + list-style-type: none; /* hide marker on non-safari */ + outline: none; /* broken on safari, so just hide it */ +} +.tsd-accordion-summary::-webkit-details-marker { + display: none; /* hide marker on safari */ +} +.tsd-accordion-summary, +.tsd-accordion-summary a { + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + + cursor: pointer; +} +.tsd-accordion-summary a { + width: calc(100% - 1.5rem); +} +.tsd-accordion-summary > * { + margin-top: 0; + margin-bottom: 0; + padding-top: 0; + padding-bottom: 0; +} +.tsd-accordion .tsd-accordion-summary > svg { + margin-left: 0.25rem; + vertical-align: text-top; +} +.tsd-index-content > :not(:first-child) { + margin-top: 0.75rem; +} +.tsd-index-heading { + margin-top: 1.5rem; + margin-bottom: 0.75rem; +} + +.tsd-kind-icon { + margin-right: 0.5rem; + width: 1.25rem; + height: 1.25rem; + min-width: 1.25rem; + min-height: 1.25rem; +} +.tsd-kind-icon path { + transform-origin: center; + transform: scale(1.1); +} +.tsd-signature > .tsd-kind-icon { + margin-right: 0.8rem; +} + +.tsd-panel { + margin-bottom: 2.5rem; +} +.tsd-panel.tsd-member { + margin-bottom: 4rem; +} +.tsd-panel:empty { + display: none; +} +.tsd-panel > h1, +.tsd-panel > h2, +.tsd-panel > h3 { + margin: 1.5rem -1.5rem 0.75rem -1.5rem; + padding: 0 1.5rem 0.75rem 1.5rem; +} +.tsd-panel > h1.tsd-before-signature, +.tsd-panel > h2.tsd-before-signature, +.tsd-panel > h3.tsd-before-signature { + margin-bottom: 0; + border-bottom: none; +} + +.tsd-panel-group { + margin: 2rem 0; +} +.tsd-panel-group.tsd-index-group { + margin: 2rem 0; +} +.tsd-panel-group.tsd-index-group details { + margin: 2rem 0; +} +.tsd-panel-group > .tsd-accordion-summary { + margin-bottom: 1rem; +} + +#tsd-search { + transition: background-color 0.2s; +} +#tsd-search .title { + position: relative; + z-index: 2; +} +#tsd-search .field { + position: absolute; + left: 0; + top: 0; + right: 2.5rem; + height: 100%; +} +#tsd-search .field input { + box-sizing: border-box; + position: relative; + top: -50px; + z-index: 1; + width: 100%; + padding: 0 10px; + opacity: 0; + outline: 0; + border: 0; + background: transparent; + color: var(--color-text); +} +#tsd-search .field label { + position: absolute; + overflow: hidden; + right: -40px; +} +#tsd-search .field input, +#tsd-search .title, +#tsd-toolbar-links a { + transition: opacity 0.2s; +} +#tsd-search .results { + position: absolute; + visibility: hidden; + top: 40px; + width: 100%; + margin: 0; + padding: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); +} +#tsd-search .results li { + background-color: var(--color-background); + line-height: initial; + padding: 4px; +} +#tsd-search .results li:nth-child(even) { + background-color: var(--color-background-secondary); +} +#tsd-search .results li.state { + display: none; +} +#tsd-search .results li.current:not(.no-results), +#tsd-search .results li:hover:not(.no-results) { + background-color: var(--color-accent); +} +#tsd-search .results a { + display: flex; + align-items: center; + padding: 0.25rem; + box-sizing: border-box; +} +#tsd-search .results a:before { + top: 10px; +} +#tsd-search .results span.parent { + color: var(--color-text-aside); + font-weight: normal; +} +#tsd-search.has-focus { + background-color: var(--color-accent); +} +#tsd-search.has-focus .field input { + top: 0; + opacity: 1; +} +#tsd-search.has-focus .title, +#tsd-search.has-focus #tsd-toolbar-links a { + z-index: 0; + opacity: 0; +} +#tsd-search.has-focus .results { + visibility: visible; +} +#tsd-search.loading .results li.state.loading { + display: block; +} +#tsd-search.failure .results li.state.failure { + display: block; +} + +#tsd-toolbar-links { + position: absolute; + top: 0; + right: 2rem; + height: 100%; + display: flex; + align-items: center; + justify-content: flex-end; +} +#tsd-toolbar-links a { + margin-left: 1.5rem; +} +#tsd-toolbar-links a:hover { + text-decoration: underline; +} + +.tsd-signature { + margin: 0 0 1rem 0; + padding: 1rem 0.5rem; + border: 1px solid var(--color-accent); + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 14px; + overflow-x: auto; +} + +.tsd-signature-keyword { + color: var(--color-ts-keyword); + font-weight: normal; +} + +.tsd-signature-symbol { + color: var(--color-text-aside); + font-weight: normal; +} + +.tsd-signature-type { + font-style: italic; + font-weight: normal; +} + +.tsd-signatures { + padding: 0; + margin: 0 0 1em 0; + list-style-type: none; +} +.tsd-signatures .tsd-signature { + margin: 0; + border-color: var(--color-accent); + border-width: 1px 0; + transition: background-color 0.1s; +} +.tsd-signatures .tsd-index-signature:not(:last-child) { + margin-bottom: 1em; +} +.tsd-signatures .tsd-index-signature .tsd-signature { + border-width: 1px; +} +.tsd-description .tsd-signatures .tsd-signature { + border-width: 1px; +} + +ul.tsd-parameter-list, +ul.tsd-type-parameter-list { + list-style: square; + margin: 0; + padding-left: 20px; +} +ul.tsd-parameter-list > li.tsd-parameter-signature, +ul.tsd-type-parameter-list > li.tsd-parameter-signature { + list-style: none; + margin-left: -20px; +} +ul.tsd-parameter-list h5, +ul.tsd-type-parameter-list h5 { + font-size: 16px; + margin: 1em 0 0.5em 0; +} +.tsd-sources { + margin-top: 1rem; + font-size: 0.875em; +} +.tsd-sources a { + color: var(--color-text-aside); + text-decoration: underline; +} +.tsd-sources ul { + list-style: none; + padding: 0; +} + +.tsd-page-toolbar { + position: sticky; + z-index: 1; + top: 0; + left: 0; + width: 100%; + color: var(--color-text); + background: var(--color-background-secondary); + border-bottom: 1px var(--color-accent) solid; + transition: transform 0.3s ease-in-out; +} +.tsd-page-toolbar a { + color: var(--color-text); + text-decoration: none; +} +.tsd-page-toolbar a.title { + font-weight: bold; +} +.tsd-page-toolbar a.title:hover { + text-decoration: underline; +} +.tsd-page-toolbar .tsd-toolbar-contents { + display: flex; + justify-content: space-between; + height: 2.5rem; + margin: 0 auto; +} +.tsd-page-toolbar .table-cell { + position: relative; + white-space: nowrap; + line-height: 40px; +} +.tsd-page-toolbar .table-cell:first-child { + width: 100%; +} +.tsd-page-toolbar .tsd-toolbar-icon { + box-sizing: border-box; + line-height: 0; + padding: 12px 0; +} + +.tsd-widget { + display: inline-block; + overflow: hidden; + opacity: 0.8; + height: 40px; + transition: + opacity 0.1s, + background-color 0.2s; + vertical-align: bottom; + cursor: pointer; +} +.tsd-widget:hover { + opacity: 0.9; +} +.tsd-widget.active { + opacity: 1; + background-color: var(--color-accent); +} +.tsd-widget.no-caption { + width: 40px; +} +.tsd-widget.no-caption:before { + margin: 0; +} + +.tsd-widget.options, +.tsd-widget.menu { + display: none; +} +input[type="checkbox"] + .tsd-widget:before { + background-position: -120px 0; +} +input[type="checkbox"]:checked + .tsd-widget:before { + background-position: -160px 0; +} + +img { + max-width: 100%; +} + +.tsd-anchor-icon { + display: inline-flex; + align-items: center; + margin-left: 0.5rem; + vertical-align: middle; + color: var(--color-text); +} + +.tsd-anchor-icon svg { + width: 1em; + height: 1em; + visibility: hidden; +} + +.tsd-anchor-link:hover > .tsd-anchor-icon svg { + visibility: visible; +} + +.deprecated { + text-decoration: line-through !important; +} + +.warning { + padding: 1rem; + color: var(--color-warning-text); + background: var(--color-background-warning); +} + +.tsd-kind-project { + color: var(--color-ts-project); +} +.tsd-kind-module { + color: var(--color-ts-module); +} +.tsd-kind-namespace { + color: var(--color-ts-namespace); +} +.tsd-kind-enum { + color: var(--color-ts-enum); +} +.tsd-kind-enum-member { + color: var(--color-ts-enum-member); +} +.tsd-kind-variable { + color: var(--color-ts-variable); +} +.tsd-kind-function { + color: var(--color-ts-function); +} +.tsd-kind-class { + color: var(--color-ts-class); +} +.tsd-kind-interface { + color: var(--color-ts-interface); +} +.tsd-kind-constructor { + color: var(--color-ts-constructor); +} +.tsd-kind-property { + color: var(--color-ts-property); +} +.tsd-kind-method { + color: var(--color-ts-method); +} +.tsd-kind-call-signature { + color: var(--color-ts-call-signature); +} +.tsd-kind-index-signature { + color: var(--color-ts-index-signature); +} +.tsd-kind-constructor-signature { + color: var(--color-ts-constructor-signature); +} +.tsd-kind-parameter { + color: var(--color-ts-parameter); +} +.tsd-kind-type-literal { + color: var(--color-ts-type-literal); +} +.tsd-kind-type-parameter { + color: var(--color-ts-type-parameter); +} +.tsd-kind-accessor { + color: var(--color-ts-accessor); +} +.tsd-kind-get-signature { + color: var(--color-ts-get-signature); +} +.tsd-kind-set-signature { + color: var(--color-ts-set-signature); +} +.tsd-kind-type-alias { + color: var(--color-ts-type-alias); +} + +/* if we have a kind icon, don't color the text by kind */ +.tsd-kind-icon ~ span { + color: var(--color-text); +} + +* { + scrollbar-width: thin; + scrollbar-color: var(--color-accent) var(--color-icon-background); +} + +*::-webkit-scrollbar { + width: 0.75rem; +} + +*::-webkit-scrollbar-track { + background: var(--color-icon-background); +} + +*::-webkit-scrollbar-thumb { + background-color: var(--color-accent); + border-radius: 999rem; + border: 0.25rem solid var(--color-icon-background); +} + +/* mobile */ +@media (max-width: 769px) { + .tsd-widget.options, + .tsd-widget.menu { + display: inline-block; + } + + .container-main { + display: flex; + } + html .col-content { + float: none; + max-width: 100%; + width: 100%; + } + html .col-sidebar { + position: fixed !important; + overflow-y: auto; + -webkit-overflow-scrolling: touch; + z-index: 1024; + top: 0 !important; + bottom: 0 !important; + left: auto !important; + right: 0 !important; + padding: 1.5rem 1.5rem 0 0; + width: 75vw; + visibility: hidden; + background-color: var(--color-background); + transform: translate(100%, 0); + } + html .col-sidebar > *:last-child { + padding-bottom: 20px; + } + html .overlay { + content: ""; + display: block; + position: fixed; + z-index: 1023; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + visibility: hidden; + } + + .to-has-menu .overlay { + animation: fade-in 0.4s; + } + + .to-has-menu .col-sidebar { + animation: pop-in-from-right 0.4s; + } + + .from-has-menu .overlay { + animation: fade-out 0.4s; + } + + .from-has-menu .col-sidebar { + animation: pop-out-to-right 0.4s; + } + + .has-menu body { + overflow: hidden; + } + .has-menu .overlay { + visibility: visible; + } + .has-menu .col-sidebar { + visibility: visible; + transform: translate(0, 0); + display: flex; + flex-direction: column; + gap: 1.5rem; + max-height: 100vh; + padding: 1rem 2rem; + } + .has-menu .tsd-navigation { + max-height: 100%; + } + #tsd-toolbar-links { + display: none; + } + .tsd-navigation .tsd-nav-link { + display: flex; + } +} + +/* one sidebar */ +@media (min-width: 770px) { + .container-main { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); + grid-template-areas: "sidebar content"; + margin: 2rem auto; + } + + .col-sidebar { + grid-area: sidebar; + } + .col-content { + grid-area: content; + padding: 0 1rem; + } +} +@media (min-width: 770px) and (max-width: 1399px) { + .col-sidebar { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + padding-top: 1rem; + } + .site-menu { + margin-top: 1rem; + } +} + +/* two sidebars */ +@media (min-width: 1200px) { + .container-main { + grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 20rem); + grid-template-areas: "sidebar content toc"; + } + + .col-sidebar { + display: contents; + } + + .page-menu { + grid-area: toc; + padding-left: 1rem; + } + .site-menu { + grid-area: sidebar; + } + + .site-menu { + margin-top: 1rem 0; + } + + .page-menu, + .site-menu { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + } +} diff --git a/classes/Connection.html b/classes/Connection.html new file mode 100644 index 00000000..48aff059 --- /dev/null +++ b/classes/Connection.html @@ -0,0 +1,282 @@ +Connection | node-resque

Class Connection

Hierarchy

  • EventEmitter
    • Connection

Constructors

Properties

connected: boolean
redis: Cluster | Redis
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Returns Promise<void>

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns void

  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Parameters

    • match: string
    • count: number = null
    • keysAry: string[] = []
    • cursor: number = 0

    Returns Promise<string[]>

  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Parameters

    • arg: any
    • Optionalarg2: any
    • Optionalarg3: any
    • Optionalarg4: any

    Returns string

  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Returns void

  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventTarget | EventEmitter<DefaultEventMap>)[]

    Returns void

    v15.4.0

    +
diff --git a/classes/MultiWorker.html b/classes/MultiWorker.html new file mode 100644 index 00000000..07057dcd --- /dev/null +++ b/classes/MultiWorker.html @@ -0,0 +1,272 @@ +MultiWorker | node-resque

Class MultiWorker

Hierarchy

  • EventEmitter
    • MultiWorker

Constructors

  • Parameters

    • options: MultiWorkerOptions
    • jobs: Jobs

    Returns MultiWorker

Properties

checkTimer: Timeout
eventLoopBlocked: boolean
eventLoopCheckCounter: number
eventLoopDelay: number
jobs: Jobs
name: string
options: MultiWorkerOptions
running: boolean
stopInProcess: boolean
workers: Worker[]
working: boolean
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns Promise<void>

  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Parameters

    • event: "end" | "start"
    • cb: ((workerId: number) => void)
        • (workerId): void
        • Parameters

          • workerId: number

          Returns void

    Returns this

  • Parameters

    • event: "cleaning_worker"
    • cb: ((workerId: number, worker: Worker, pid: number) => void)
        • (workerId, worker, pid): void
        • Parameters

          • workerId: number
          • worker: Worker
          • pid: number

          Returns void

    Returns this

  • Parameters

    • event: "poll"
    • cb: ((workerId: number, queue: string) => void)
        • (workerId, queue): void
        • Parameters

          • workerId: number
          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "ping"
    • cb: ((workerId: number, time: number) => void)
        • (workerId, time): void
        • Parameters

          • workerId: number
          • time: number

          Returns void

    Returns this

  • Parameters

    • event: "job"
    • cb: ((workerId: number, queue: string, job: ParsedJob) => void)
        • (workerId, queue, job): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "reEnqueue"
    • cb: ((workerId: number, queue: string, job: ParsedJob, plugin: string) => void)
        • (workerId, queue, job, plugin): void
        • Parameters

          • workerId: number
          • queue: string
          • job: ParsedJob
          • plugin: string

          Returns void

    Returns this

  • Parameters

    • event: "success"
    • cb: ((workerId: number, queue: string, job: ParsedJob, result: any, duration: number) => void)
        • (workerId, queue, job, result, duration): void
        • Parameters

          • workerId: number
          • queue: string
          • job: ParsedJob
          • result: any
          • duration: number

          Returns void

    Returns this

  • Parameters

    • event: "failure"
    • cb: ((workerId: number, queue: string, job: ParsedJob, failure: Error, duration: number) => void)
        • (workerId, queue, job, failure, duration): void
        • Parameters

          • workerId: number
          • queue: string
          • job: ParsedJob
          • failure: Error
          • duration: number

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, workerId: number, queue: string, job: ParsedJob) => void)
        • (error, workerId, queue, job): void
        • Parameters

          • error: Error
          • workerId: number
          • queue: string
          • job: ParsedJob

          Returns void

    Returns this

  • Parameters

    • event: "pause"
    • cb: ((workerId: number) => void)
        • (workerId): void
        • Parameters

          • workerId: number

          Returns void

    Returns this

  • Parameters

    • event: "multiWorkerAction"
    • cb: ((verb: string, delay: number) => void)
        • (verb, delay): void
        • Parameters

          • verb: string
          • delay: number

          Returns void

    Returns this

  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Returns void

  • Returns Promise<void>

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventTarget | EventEmitter<DefaultEventMap>)[]

    Returns void

    v15.4.0

    +
diff --git a/classes/Plugin.html b/classes/Plugin.html new file mode 100644 index 00000000..b81c3310 --- /dev/null +++ b/classes/Plugin.html @@ -0,0 +1,14 @@ +Plugin | node-resque

Class PluginAbstract

Constructors

  • Parameters

    • worker: Worker | Queue
    • func: string
    • queue: string
    • job: ParsedJob
    • args: any[]
    • options: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns Plugin

Properties

args: any[]
func: string
name: string
options: {
    [key: string]: any;
}
queue: string
queueObject: Queue
worker: any

Methods

  • Returns Promise<boolean>

  • Returns Promise<boolean>

  • Returns Promise<boolean>

  • Returns Promise<boolean>

diff --git a/classes/Queue.html b/classes/Queue.html new file mode 100644 index 00000000..524d3140 --- /dev/null +++ b/classes/Queue.html @@ -0,0 +1,372 @@ +Queue | node-resque

Class Queue

Hierarchy

  • EventEmitter
    • Queue

Constructors

  • Parameters

    • options: QueueOptions
    • jobs: Jobs = {}

    Returns Queue

Properties

connection: Connection
jobs: Jobs
options: QueueOptions
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
    • +
    • jobsHash is an object with its keys being timestamps, and the values are arrays of jobs at each time.
    • +
    • note that this operation can be very slow and very ram-heavy
    • +
    +

    Returns Promise<{
        [key: string]: any[];
    }>

    • +
    • returns a hash of the results of queue.workingOn with the worker names as keys.
    • +
    +

    Returns Promise<{
        [key: string]: ParsedWorkerPayload;
    }>

  • Parameters

    • age: number

    Returns Promise<{
        [key: string]: any;
    }>

  • Returns Promise<void>

    • +
    • jobs are deleted by those matching a func and argument collection within a given queue.
    • +
    • You might match none, or you might match many.
    • +
    +

    Parameters

    • q: string
    • func: string
    • args: any[] = []
    • count: number = 0

    Returns Promise<number>

  • delByFunction

    +
      +
    • will delete all jobs in the given queue of the named function/class
    • +
    • will not prevent new jobs from being added as this method is running
    • +
    • will not delete jobs in the delayed queues
    • +
    +

    Parameters

    • q: string

      queue to look in

      +
    • func: string

      function name to delete any jobs with

      +
    • start: number = 0

      optional place to start looking in list (default: beginning of list)

      +
    • stop: number = -1

      optional place to end looking in list (default: end of list)

      +

    Returns Promise<number>

    number of jobs deleted from queue

    +
  • Parameters

    • q: string
    • func: string
    • args: any[] = []

    Returns Promise<number[]>

    • +
    • count is an integer. You might delete more than one lock by the name.
    • +
    +

    Parameters

    • key: string

    Returns Promise<number>

    • +
    • delete a queue, and all jobs in that queue.
    • +
    +

    Parameters

    • q: string

    Returns Promise<void>

    • +
    • jobsEnqueuedForThisTimestamp is an array, matching the style of the response of queue.queued
    • +
    +

    Parameters

    • timestamp: number

    Returns Promise<{
        rTimestamp: number;
        tasks: ParsedJob[];
    }>

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Parameters

    • q: string
    • func: string
    • args: any[] = []

    Returns string

  • Returns Promise<void>

    • +
    • Enqueue a named job (defined in jobs to be worked by a worker)
    • +
    • The job will be added to the queueName queue, and that queue will be worked down by available workers assigned to that queue
    • +
    • args is optional, but should be an array of arguments passed to the job. Order of arguments is maintained
    • +
    +

    Parameters

    • q: string
    • func: string
    • args: any[] = []

    Returns Promise<boolean>

    • +
    • In ms, the unix timestamp at which this job is able to start being worked on.
    • +
    • Depending on the number of other jobs in queueName, it is likely that this job will not be excecuted at exactly the time specified, but shortly thereafter.
    • +
    • other options the same as queue.enqueue
    • +
    +

    Parameters

    • timestamp: number
    • q: string
    • func: string
    • args: any[] = []
    • suppressDuplicateTaskError: boolean = false

    Returns Promise<void>

    • +
    • In ms, the number of ms to delay before this job is able to start being worked on.
    • +
    • Depending on the number of other jobs in queueName, it is likely that this job will not be excecuted at exactly the delay specified, but shortly thereafter.
    • +
    • other options the same as queue.enqueue
    • +
    +

    Parameters

    • time: number
    • q: string
    • func: string
    • args: any[] = []
    • suppressDuplicateTaskError: boolean = false

    Returns Promise<void>

  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
    • +
    • failedJobs is an array listing the data of the failed jobs. Each element looks like:
    • +
    +
    {"worker": "host:pid", "queue": "test_queue", "payload": {"class":"slowJob", "queue":"test_queue", "args":[null]}, "exception": "TypeError", "error": "MyImport is not a function", "backtrace": [' at Worker.perform (/path/to/worker:111:24)', ' at <anonymous>'], "failed_at": "Fri Dec 12 2014 14:01:16 GMT-0800 (PST)"}\
    +
    + +
      +
    • To retrieve all failed jobs, use arguments: await queue.failed(0, -1)
    • +
    +

    Parameters

    • start: number
    • stop: number

    Returns Promise<ParsedFailedJobPayload[]>

    • +
    • failedCount is the number of jobs in the failed queue
    • +
    +

    Returns Promise<number>

  • Parameters

    • workerName: string

    Returns Promise<ErrorPayload>

  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Return the currently elected leader

    +

    Returns Promise<string>

  • The redis key which holds the currently elected leader

    +

    Returns string

    • +
    • length is an integer counting the length of the jobs in the queue
    • +
    • this does not include delayed jobs for this queue
    • +
    +

    Parameters

    • q: string

    Returns Promise<number>

  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
    • +
    • types of locks include queue and worker locks, as created by the plugins below
    • +
    • locks is a hash by type and timestamp
    • +
    +

    Returns Promise<{
        [key: string]: string;
    }>

  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string) => void)
        • (error, queue): void
        • Parameters

          • error: Error
          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string) => void)
        • (error, queue): void
        • Parameters

          • error: Error
          • queue: string

          Returns void

    Returns this

  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
    • +
    • list all the jobs (with their payloads) in a queue between start index and stop index.
    • +
    • jobs is an array containing the payload of the job enqueued
    • +
    +

    Parameters

    • q: string
    • start: number
    • stop: number

    Returns Promise<any[]>

    • +
    • queues is an Array with the names of all your queues
    • +
    +

    Returns Promise<string[]>

  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Parameters

    Returns Promise<number>

  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Parameters

    Returns Promise<boolean>

  • Look though the failed jobs to find those which were failed as a result of forceCleanWorker and re-enqueue them. +This is potentially very slow if you have a lot of failed jobs

    +

    Parameters

    • upperLimit: number = Infinity

    Returns Promise<void>

    • +
    • learn the timestamps at which a job is scheduled to be run.
    • +
    • timestampsForJob is an array of integers
    • +
    +

    Parameters

    • q: string
    • func: string
    • args: any[] = []

    Returns Promise<number[]>

  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
    • +
    • stats will be a hash containing details about all the queues in your redis, and how many jobs are in each, and who the leader is
    • +
    +

    Returns Promise<{
        [key: string]: any;
    }>

    • +
    • timestamps is an array of integers for all timestamps which have at least one job scheduled in the future
    • +
    +

    Returns Promise<number[]>

    • +
    • returns a hash of the form: { 'host:pid': 'queue1, queue2', 'host:pid': 'queue1, queue2' }
    • +
    +

    Returns Promise<{
        [key: string]: string;
    }>

    • +
    • returns: {"run_at":"Fri Dec 12 2014 14:01:16 GMT-0800 (PST)","queue":"test_queue","payload":{"class":"slowJob","queue":"test_queue","args":[null]},"worker":"workerA"}
    • +
    +

    Parameters

    • workerName: string
    • queues: string

    Returns Promise<string>

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventTarget | EventEmitter<DefaultEventMap>)[]

    Returns void

    v15.4.0

    +
diff --git a/classes/Scheduler.html b/classes/Scheduler.html new file mode 100644 index 00000000..05a3f4ca --- /dev/null +++ b/classes/Scheduler.html @@ -0,0 +1,252 @@ +Scheduler | node-resque

Class Scheduler

Hierarchy

  • EventEmitter
    • Scheduler

Constructors

  • Parameters

    • options: SchedulerOptions
    • jobs: Jobs = {}

    Returns Scheduler

Properties

connection: Connection
jobs: Jobs
leader: boolean
name: string
options: SchedulerOptions
processing: boolean
queue: Queue
running: boolean
timer: Timeout
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Returns Promise<void>

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns Promise<unknown>

  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Parameters

    • workerName: string
    • delta: number

    Returns Promise<void>

  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Parameters

    • event:
          | "end"
          | "start"
          | "poll"
          | "leader"
    • cb: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "cleanStuckWorker"
    • cb: ((workerName: string, errorPayload: ErrorPayload, delta: number) => void)
        • (workerName, errorPayload, delta): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string) => void)
        • (error, queue): void
        • Parameters

          • error: Error
          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "workingTimestamp"
    • cb: ((timestamp: number) => void)
        • (timestamp): void
        • Parameters

          • timestamp: number

          Returns void

    Returns this

  • Parameters

    • event: "transferredJob"
    • cb: ((timestamp: number, job: Job<any>) => void)
        • (timestamp, job): void
        • Parameters

          • timestamp: number
          • job: Job<any>

          Returns void

    Returns this

  • Parameters

    • event:
          | "end"
          | "start"
          | "poll"
          | "leader"
    • cb: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "cleanStuckWorker"
    • cb: ((workerName: string, errorPayload: ErrorPayload, delta: number) => void)
        • (workerName, errorPayload, delta): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string) => void)
        • (error, queue): void
        • Parameters

          • error: Error
          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "workingTimestamp"
    • cb: ((timestamp: number) => void)
        • (timestamp): void
        • Parameters

          • timestamp: number

          Returns void

    Returns this

  • Parameters

    • event: "transferredJob"
    • cb: ((timestamp: number, job: Job<any>) => void)
        • (timestamp, job): void
        • Parameters

          • timestamp: number
          • job: Job<any>

          Returns void

    Returns this

  • Returns Promise<void>

  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Parameters

    • event: SchedulerEvent

    Returns this

  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Returns Promise<void>

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventTarget | EventEmitter<DefaultEventMap>)[]

    Returns void

    v15.4.0

    +
diff --git a/classes/Worker.html b/classes/Worker.html new file mode 100644 index 00000000..36d8aedf --- /dev/null +++ b/classes/Worker.html @@ -0,0 +1,263 @@ +Worker | node-resque

Class Worker

Hierarchy

  • EventEmitter
    • Worker

Constructors

  • Parameters

    • options: WorkerOptions
    • jobs: Jobs = {}

    Returns Worker

Properties

connection: Connection
endTimer: Timeout
error: Error
id: number
jobs: Jobs
name: string
options: WorkerOptions
originalQueue: string
pingTimer: Timeout
pollTimer: Timeout
queue: string
queueObject: Queue
queues: string | string[]
ready: boolean
result: any
running: boolean
started: boolean
working: boolean
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Returns Promise<void>

  • Returns Promise<void>

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns Promise<void>

  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Returns Promise<void>

  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Parameters

    • event: "pause" | "end" | "start"
    • cb: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "cleaning_worker"
    • cb: ((worker: Worker, pid: string) => void)
        • (worker, pid): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "poll"
    • cb: ((queue: string) => void)
        • (queue): void
        • Parameters

          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "ping"
    • cb: ((time: number) => void)
        • (time): void
        • Parameters

          • time: number

          Returns void

    Returns this

  • Parameters

    • event: "job"
    • cb: ((queue: string, job: ParsedJob) => void)
        • (queue, job): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "reEnqueue"
    • cb: ((queue: string, job: ParsedJob, plugin: string) => void)
        • (queue, job, plugin): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "success"
    • cb: ((queue: string, job: ParsedJob, result: any, duration: number) => void)
        • (queue, job, result, duration): void
        • Parameters

          • queue: string
          • job: ParsedJob
          • result: any
          • duration: number

          Returns void

    Returns this

  • Parameters

    • event: "failure"
    • cb: ((queue: string, job: ParsedJob, failure: Error, duration: number) => void)
        • (queue, job, failure, duration): void
        • Parameters

          • queue: string
          • job: ParsedJob
          • failure: Error
          • duration: number

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string, job: ParsedJob) => void)
        • (error, queue, job): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "pause" | "end" | "start"
    • cb: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "cleaning_worker"
    • cb: ((worker: Worker, pid: string) => void)
        • (worker, pid): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "poll"
    • cb: ((queue: string) => void)
        • (queue): void
        • Parameters

          • queue: string

          Returns void

    Returns this

  • Parameters

    • event: "ping"
    • cb: ((time: number) => void)
        • (time): void
        • Parameters

          • time: number

          Returns void

    Returns this

  • Parameters

    • event: "job"
    • cb: ((queue: string, job: ParsedJob) => void)
        • (queue, job): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "reEnqueue"
    • cb: ((queue: string, job: ParsedJob, plugin: string) => void)
        • (queue, job, plugin): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "success"
    • cb: ((queue: string, job: ParsedJob, result: any) => void)
        • (queue, job, result): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "failure"
    • cb: ((queue: string, job: ParsedJob, failure: any) => void)
        • (queue, job, failure): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • cb: ((error: Error, queue: string, job: ParsedJob) => void)
        • (error, queue, job): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • func: string
    • args: any[] = []

    Returns Promise<any>

  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Parameters

    • event: string

    Returns this

  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Returns Promise<void>

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterableIterator<any[]>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventTarget | EventEmitter<DefaultEventMap>)[]

    Returns void

    v15.4.0

    +
diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..254561ae39c21c8987d2576f95d19ed7347c25a2 GIT binary patch literal 1150 zcmZ9L3rtgI6o3yALgzq%3?~s~7zvZ9qrZ2*x2eFm1wpjWG|NWQ7W_WJS<3Hzo_x|^P z07T#?E)KAL1&&4nYyf~)vEmfYg!0${;M(B2kgkkFW({`#*ND%XyJD+a2UxwlVmUaYke?Op7XoivI14K3vlv zcF}Erad~(3#hEFZ=r01k?N+~d_8P&dtR7I7yr)6*+&jTdX@AtwVyf1~CSHQ5n4ci( zg_E&~$rrxQVD$$|4&6mxh(>Om?Iqq6cat$98Ig6J)NZhl3T`re95b&e9IZFdV2#gQO zFh4V`2E3MFG8s;Ly>8_7dOc>dnU7hDXX*5MuFLggF&L!y$3IYfXJ=oSmr8qp%9%_? ziO=W3yvJ=cnRs~aOgx9o&f!U}*=&0_OgPb3wG+fk$>%q2&1equNvVynHopGl6JOp@ z4GufdBa6e(Luk2}rPp+k(Pw%I=HX*<1-E1bF$81F=~>;sZb@rO0w~At*bK>A&uvV7 zt*wd9Q!VrNkE7DhZrrGsk7VQZTiJtqXnBpGto8Vg>?M>;B$$QJnx-akt6KDY{nM>^N1Z2#rY3`Sdk_m&E&Cl=7s zQUC>m0W_(7f(j0dqFp&Mf9j4)ZM;M6347iSoga$dUv7mriY~$~zBE4XaLcieE9AYi zvvazI1*dZX8>@9*cU0Kln_t>~oL(SJ$T|2M6qn9W=qhO%)k33M8`*H3WV8>Bv+q67 zG4Jbi%&S8a>@(L0=FfyCs*%vFVxAw=$Oxd;RNO_rjy;P~9A{!r!~Xg9m9cX@fFT+{ hiEnc)zTpwI_>wCDq75OXVk$?~s2-}9Vtgq8{{f6q@i_nh literal 0 HcmV?d00001 diff --git a/index.html b/index.html new file mode 100644 index 00000000..30c2233e --- /dev/null +++ b/index.html @@ -0,0 +1,185 @@ +node-resque

node-resque

node-resque: The best background jobs in node.

Distributed delayed jobs in nodejs. Resque is a background job system backed by Redis (version 2.6.0 and up required). It includes priority queues, plugins, locking, delayed jobs, and more! This project is a very opinionated but API-compatible with Resque and Sidekiq (caveats). We also implement some of the popular Resque plugins, including resque-scheduler and resque-retry

+

The full API documentation for this package is automatically generated from the main via typedoc branch and published to https://node-resque.actionherojs.com/

+

Nodei stats

+

Test

+

Resque is a queue based task processing system that can be thought of as a "Kanban" style factory. Workers in this factory can each only work one Job at a time. They pull Jobs from Queues and work them to completion (or failure). Each Job has two parts: instructions on how to complete the job (the perform function), and any inputs necessary to complete the Job.

+

In our factory example, Queues are analogous to conveyor belts. Jobs are placed on the belts (Queues) and are held in order waiting for a Worker to pick them up. There are three types of Queues: regular work Queues, Delayed Job Queues, and the Failed Job Queue. The Delayed Job Queues contains Job definitions that are intended to be worked at or in a specified time. The Failed Job Queue is where Workers place any Jobs that have failed during execution.

+

Our Workers are the heart of the factory. Each Worker is assigned one or more Queues to check for work. After taking a Job from a Queue the Worker attempts to complete the Job. If successful, they go back to check out more work from the Queues. However, if there is a failure, the Worker records the job and its inputs in the Failed Jobs Queue before going back for more work.

+

The Scheduler can be thought of as a specialized type of Worker. Unlike other Workers, the Scheduler does not execute any Jobs, instead it manages the Delayed Job Queue. As Job definitions are added to the Delayed Job Queue they must specify when they can become available for execution. The Scheduler constantly checks to see if any Delayed Jobs are ready to execute. When a Delayed Job becomes ready for execution the Scheduler places a new instance of that Job in its defined Queue.

+

You can read the API docs for Node Resque @ node-resque.actionherojs.com. These are generated automatically from the master branch via TypeDoc

+
    +
  • The version of redis required is >= 2.6.0 as we use lua scripting to create custom atomic operations
  • +
  • ‼️ Version 6+ of Node Resque uses TypeScript. We will still include JavaScript transpiled code in NPM releases, but they will be generated from the TypeScript source. Functionality between node-resque v5 and v6 should be the same.
  • +
  • ‼️ Version 5+ of Node Resque uses async/await. There is no upgrade path from previous versions. Node v8.0.0+ is required.
  • +
+

I learn best by examples:

+
import { Worker, Plugins, Scheduler, Queue } from "node-resque";

async function boot() {
// ////////////////////////
// SET UP THE CONNECTION //
// ////////////////////////

const connectionDetails = {
pkg: "ioredis",
host: "127.0.0.1",
password: null,
port: 6379,
database: 0,
// namespace: 'resque',
// looping: true,
// options: {password: 'abc'},
};

// ///////////////////////////
// DEFINE YOUR WORKER TASKS //
// ///////////////////////////

let jobsToComplete = 0;

const jobs = {
add: {
plugins: [Plugins.JobLock],
pluginOptions: {
JobLock: { reEnqueue: true },
},
perform: async (a, b) => {
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
jobsToComplete--;
tryShutdown();

const answer = a + b;
return answer;
},
},
subtract: {
perform: (a, b) => {
jobsToComplete--;
tryShutdown();

const answer = a - b;
return answer;
},
},
};

// just a helper for this demo
async function tryShutdown() {
if (jobsToComplete === 0) {
await new Promise((resolve) => {
setTimeout(resolve, 500);
});
await scheduler.end();
await worker.end();
process.exit();
}
}

// /////////////////
// START A WORKER //
// /////////////////

const worker = new Worker(
{ connection: connectionDetails, queues: ["math", "otherQueue"] },
jobs,
);
await worker.connect();
worker.start();

// ////////////////////
// START A SCHEDULER //
// ////////////////////

const scheduler = new Scheduler({ connection: connectionDetails });
await scheduler.connect();
scheduler.start();

// //////////////////////
// REGISTER FOR EVENTS //
// //////////////////////

worker.on("start", () => {
console.log("worker started");
});
worker.on("end", () => {
console.log("worker ended");
});
worker.on("cleaning_worker", (worker, pid) => {
console.log(`cleaning old worker ${worker}`);
});
worker.on("poll", (queue) => {
console.log(`worker polling ${queue}`);
});
worker.on("ping", (time) => {
console.log(`worker check in @ ${time}`);
});
worker.on("job", (queue, job) => {
console.log(`working job ${queue} ${JSON.stringify(job)}`);
});
worker.on("reEnqueue", (queue, job, plugin) => {
console.log(`reEnqueue job (${plugin}) ${queue} ${JSON.stringify(job)}`);
});
worker.on("success", (queue, job, result, duration) => {
console.log(
`job success ${queue} ${JSON.stringify(
job,
)} >> ${result} (${duration}ms)`,
);
});
worker.on("failure", (queue, job, failure, duration) => {
console.log(
`job failure ${queue} ${JSON.stringify(
job,
)} >> ${failure} (${duration}ms)`,
);
});
worker.on("error", (error, queue, job) => {
console.log(`error ${queue} ${JSON.stringify(job)} >> ${error}`);
});
worker.on("pause", () => {
console.log("worker paused");
});

scheduler.on("start", () => {
console.log("scheduler started");
});
scheduler.on("end", () => {
console.log("scheduler ended");
});
scheduler.on("poll", () => {
console.log("scheduler polling");
});
scheduler.on("leader", () => {
console.log("scheduler became leader");
});
scheduler.on("error", (error) => {
console.log(`scheduler error >> ${error}`);
});
scheduler.on("cleanStuckWorker", (workerName, errorPayload, delta) => {
console.log(
`failing ${workerName} (stuck for ${delta}s) and failing job ${errorPayload}`,
);
});
scheduler.on("workingTimestamp", (timestamp) => {
console.log(`scheduler working timestamp ${timestamp}`);
});
scheduler.on("transferredJob", (timestamp, job) => {
console.log(`scheduler enquing job ${timestamp} >> ${JSON.stringify(job)}`);
});

// //////////////////////
// CONNECT TO A QUEUE //
// //////////////////////

const queue = new Queue({ connection: connectionDetails }, jobs);
queue.on("error", function (error) {
console.log(error);
});
await queue.connect();
await queue.enqueue("math", "add", [1, 2]);
await queue.enqueue("math", "add", [1, 2]);
await queue.enqueue("math", "add", [2, 3]);
await queue.enqueueIn(3000, "math", "subtract", [2, 1]);
jobsToComplete = 4;
}

boot();

// and when you are done
// await queue.end()
// await scheduler.end()
// await worker.end() +
+ +

There are 3 main classes in node-resque: Queue, Worker, and Scheduler

+
    +
  • Queue: This is the interface your program uses to interact with resque's queues - to insert jobs, check on the performance of things, and generally administer your background jobs.
  • +
  • Worker: This interface is how jobs get processed. Workers are started and then they check for jobs enqueued into various queues and complete them. If there's an error, they write to the error queue. +
      +
    • There's a special class called multiWorker in Node Resque which will run many workers at once for you (see below).
    • +
    +
  • +
  • Scheduler: The scheduler can be thought of as the coordinator for Node Resque. It is primarily in charge of checking when jobs told to run later (with queue.enqueueIn or queue.enqueueAt) should be processed, but it performs some other jobs like checking for 'stuck' workers and general cluster cleanup. +
      +
    • You can (and should) run many instances of the scheduler class at once, but only one will be elected to be the 'leader', and actually do work.
    • +
    • The 'delay' defined on a scheduled job does not specify when the job should be run, but rather when the job should be enqueued. This means that node-resque can not guarantee when a job is going to be executed, only when it will become available for execution (added to a Queue).
    • +
    +
  • +
+
    +
  • new queue requires only the "queue" variable to be set. If you intend to run plugins with beforeEnqueue or afterEnqueue hooks, you should also pass the jobs object to it.
  • +
  • new worker has some additional options:
  • +
+
options = {
looping: true,
timeout: 5000,
queues: "*",
name: os.hostname() + ":" + process.pid,
}; +
+ +

Note that when using "*" queue:

+
    +
  • there's minor performance impact for checking the queues
  • +
  • queues are processed in undefined order
  • +
+

The configuration hash passed to new NodeResque.Worker, new NodeResque.Scheduler or new NodeResque.Queue can also take a connection option.

+
const connectionDetails = {
pkg: "ioredis",
host: "127.0.0.1",
password: "",
port: 6379,
database: 0,
namespace: "resque", // Also allow array of strings
};

const worker = new NodeResque.Worker(
{ connection: connectionDetails, queues: "math" },
jobs,
);

worker.on("error", (error) => {
// handler errors
});

await worker.connect();
worker.start();

// and when you are done
// await worker.end() +
+ +

You can also pass redis client directly.

+
// assume you already initialized redis client before
// the "redis" key can be IORedis.Redis or IORedis.Cluster instance

const redisClient = new Redis();
const connectionDetails = { redis: redisClient };

// or

const redisCluster = new Cluster();
const connectionDetails = { redis: redisCluster };

const worker = new NodeResque.Worker(
{ connection: connectionDetails, queues: "math" },
jobs,
);

worker.on("error", (error) => {
// handler errors
});

await worker.connect();
worker.start();

// and when you are done
await worker.end(); +
+ +
    +
  • Be sure to call await worker.end(), await queue.end() and await scheduler.end() before shutting down your application if you want to properly clear your worker status from resque.
  • +
  • When ending your application, be sure to allow your workers time to finish what they are working on
  • +
  • This project implements the "scheduler" part of rescue-scheduler (the daemon which can promote enqueued delayed jobs into the work queues when it is time), but not the CRON scheduler proxy. To learn more about how to use a CRON-like scheduler, read the Job Schedules section of this document.
  • +
  • "Namespace" is a string which is appended to the front of your keys in redis. Normally, it is "resque". This is helpful if you want to store multiple work queues in one redis database. Do not use keyPrefix if you are using the ioredis (default) redis driver in this project (see https://github.com/actionhero/node-resque/issues/245 for more information.)
  • +
  • If you are using any plugins which effect beforeEnqueue or afterEnqueue, be sure to pass the jobs argument to the new NodeResque.Queue() constructor
  • +
  • If a job fails, it will be added to a special failed queue. You can then inspect these jobs, write a plugin to manage them, move them back to the normal queues, etc. Failure behavior by default is just to enter the failed queue, but there are many options. Check out these examples from the ruby ecosystem for inspiration: + +
  • +
  • If you plan to run more than one worker per nodejs process, be sure to name them something distinct. Names must follow the pattern hostname:pid+unique_id. For example:
  • +
  • For the Retry plugin, a success message will be emitted from the worker on each attempt (even if the job fails) except the final retry. The final retry will emit a failure message instead.
  • +
+

If you want to learn more about running Node-Resque with docker, please view the examples here: https://github.com/actionhero/node-resque/tree/master/examples/docker

+
const name = os.hostname() + ":" + process.pid + "+" + counter;
const worker = new NodeResque.Worker(
{ connection: connectionDetails, queues: "math", name: name },
jobs,
); +
+ +

DO NOT USE THIS IN PRODUCTION. In tests or special cases, you may want to process/work a job in-line. To do so, you can use worker.performInline(jobName, arguments, callback). If you are planning on running a job via #performInline, this worker should also not be started, nor should be using event emitters to monitor this worker. This method will also not write to redis at all, including logging errors, modify resque's stats, etc.

+
const queue = new NodeResque.Queue({ connection: connectionDetails, jobs });
await queue.connect(); +
+ +

API documentation for the main methods you will be using to enqueue jobs to be worked can be found @ node-resque.actionherojs.com.

+

From time to time, your jobs/workers may fail. Resque workers will move failed jobs to a special failed queue which will store the original arguments of your job, the failing stack trace, and additional metadata.

+

error example

+

You can work with these failed jobs with the following methods:

+

let failedCount = await queue.failedCount()

+
    +
  • failedCount is the number of jobs in the failed queue
  • +
+

let failedJobs = await queue.failed(start, stop)

+
    +
  • failedJobs is an array listing the data of the failed jobs. Each element looks like: +{"worker": "host:pid", "queue": "test_queue", "payload": {"class":"slowJob", "queue":"test_queue", "args":[null]}, "exception": "TypeError", "error": "MyImport is not a function", "backtrace": [' at Worker.perform (/path/to/worker:111:24)', ' at <anonymous>'], "failed_at": "Fri Dec 12 2014 14:01:16 GMT-0800 (PST)"}
  • +
  • To retrieve all failed jobs, use arguments: await queue.failed(0, -1)
  • +
+

We use a try/catch pattern to catch errors in your jobs. If any job throws an +uncaught exception, it will be caught, and the job's payload moved to the error +queue for inspection. +Do not use domain, process.on("exit"), or any other method +of "catching" a process crash.

+

The error payload looks like:

+
{ worker: 'busted-worker-3',
queue: 'busted-queue',
payload: { class: 'busted_job', queue: 'busted-queue', args: [ 1, 2, 3 ] },
exception: 'ERROR_NAME',
error: 'I broke',
failed_at: 'Sun Apr 26 2015 14:00:44 GMT+0100 (BST)' } +
+ +

await queue.removeFailed(failedJob)

+
    +
  • the input failedJob is an expanded node object representing the failed job, retrieved via queue.failed
  • +
+

await queue.retryAndRemoveFailed(failedJob)

+
    +
  • the input failedJob is an expanded node object representing the failed job, retrieved via queue.failed
  • +
  • this method will instantly re-enqueue a failed job back to its original queue, and delete the failed entry for that job
  • +
+

By default, the scheduler will check for workers which haven't pinged redis in 60 minutes. If this happens, we will assume the process crashed, and remove it from redis. If this worker was working on a job, we will place it in the failed queue for later inspection. Every worker has a timer running in which it then updates a key in redis every timeout (default: 5 seconds). If your job is slow, but async, there should be no problem. However, if your job consumes 100% of the CPU of the process, this timer might not fire.

+

To modify the 60 minute check, change stuckWorkerTimeout when configuring your scheduler, ie:

+
const scheduler = new NodeResque.Scheduler({
stuckWorkerTimeout: (1000 * 60 * 60) // 1 hour, in ms
connection: connectionDetails
}) +
+ +

Set your scheduler's stuckWorkerTimeout = false to disable this behavior.

+
const scheduler = new NodeResque.Scheduler({
stuckWorkerTimeout: false // will not fail jobs which haven't pinged redis
connection: connectionDetails
}) +
+ +

Sometimes a worker crashes is a severe way, and it doesn't get the time/chance to notify redis that it is leaving the pool (this happens all the time on PAAS providers like Heroku). When this happens, you will not only need to extract the job from the now-zombie worker's "working on" status, but also remove the stuck worker. To aid you in these edge cases, await queue.cleanOldWorkers(age) is available.

+

Because there are no 'heartbeats' in resque, it is impossible for the application to know if a worker has been working on a long job or it is dead. You are required to provide an "age" for how long a worker has been "working", and all those older than that age will be removed, and the job they are working on moved to the error queue (where you can then use queue.retryAndRemoveFailed) to re-enqueue the job.

+

If you know the name of a worker that should be removed, you can also call await queue.forceCleanWorker(workerName) directly, and that will also remove the worker and move any job it was working on into the error queue. This method will still proceed for workers which are only partially in redis, indicting a previous connection failure. In this case, the job which the worker was working on is irrecoverably lost.

+

You may want to use node-resque to schedule jobs every minute/hour/day, like a distributed CRON system. There are a number of excellent node packages to help you with this, like node-schedule and node-cron. Node-resque makes it possible for you to use the package of your choice to schedule jobs with.

+

Assuming you are running node-resque across multiple machines, you will need to ensure that only one of your processes is actually scheduling the jobs. To help you with this, you can inspect which of the scheduler processes is currently acting as leader, and flag only the master scheduler process to run the schedule. A full example can be found at /examples/scheduledJobs.ts, but the relevant section is:

+
const NodeResque = require("node-resque");
const schedule = require("node-schedule");
const queue = new NodeResque.Queue({ connection: connectionDetails }, jobs);
const scheduler = new NodeResque.Scheduler({ connection: connectionDetails });
await scheduler.connect();
scheduler.start();

schedule.scheduleJob("10,20,30,40,50 * * * * *", async () => {
// do this job every 10 seconds, CRON style
// we want to ensure that only one instance of this job is scheduled in our environment at once,
// no matter how many schedulers we have running
if (scheduler.leader) {
console.log(">>> enqueuing a job");
await queue.enqueue("time", "ticktock", new Date().toString());
}
}); +
+ +

Just like ruby's resque, you can write worker plugins. They look like this. The 4 hooks you have are beforeEnqueue, afterEnqueue, beforePerform, and afterPerform. Plugins are classes which extend NodeResque.Plugin

+
const { Plugin } = require("node-resque");

class MyPlugin extends Plugin {
constructor(...args) {
// @ts-ignore
super(...args);
this.name = "MyPlugin";
}

beforeEnqueue() {
// console.log("** beforeEnqueue")
return true; // should the job be enqueued?
}

afterEnqueue() {
// console.log("** afterEnqueue")
}

beforePerform() {
// console.log("** beforePerform")
return true; // should the job be run?
}

afterPerform() {
// console.log("** afterPerform")
}
} +
+ +

And then your plugin can be invoked within a job like this:

+
const jobs = {
add: {
plugins: [MyPlugin],
pluginOptions: {
MyPlugin: { thing: "stuff" },
},
perform: (a, b) => {
let answer = a + b;
return answer;
},
},
}; +
+ +

notes

+
    +
  • You need to return true or false on the before hooks. true indicates that the action should continue, and false prevents it. This is called toRun.
  • +
  • If you are writing a plugin to deal with errors which may occur during your resque job, you can inspect and modify this.worker.error in your plugin. If this.worker.error is null, no error will be logged in the resque error queue.
  • +
  • There are a few included plugins, all in the src/plugins/* directory. You can write your own and include it like this:
  • +
+
const jobs = {
add: {
plugins: [require("Myplugin").Myplugin],
pluginOptions: {
MyPlugin: { thing: "stuff" },
},
perform: (a, b) => {
let answer = a + b;
return answer;
},
},
}; +
+ +

The plugins which are included with this package are:

+
    +
  • DelayQueueLock +
      +
    • If a job with the same name, queue, and args is already in the delayed queue(s), do not enqueue it again
    • +
    +
  • +
  • JobLock +
      +
    • If a job with the same name, queue, and args is already running, put this job back in the queue and try later
    • +
    +
  • +
  • QueueLock +
      +
    • If a job with the same name, queue, and args is already in the queue, do not enqueue it again
    • +
    +
  • +
  • Retry +
      +
    • If a job fails, retry it N times before finally placing it into the failed queue
    • +
    +
  • +
+

node-resque provides a wrapper around the Worker class which will auto-scale the number of resque workers. This will process more than one job at a time as long as there is idle CPU within the event loop. For example, if you have a slow job that sends email via SMTP (with low overhead), we can process many jobs at a time, but if you have a math-heavy operation, we'll stick to 1. The MultiWorker handles this by spawning more and more node-resque workers and managing the pool.

+
const NodeResque = require("node-resque");

const connectionDetails = {
pkg: "ioredis",
host: "127.0.0.1",
password: "",
};

const multiWorker = new NodeResque.MultiWorker(
{
connection: connectionDetails,
queues: ["slowQueue"],
minTaskProcessors: 1,
maxTaskProcessors: 100,
checkTimeout: 1000,
maxEventLoopDelay: 10,
},
jobs,
);

// normal worker emitters
multiWorker.on("start", (workerId) => {
console.log("worker[" + workerId + "] started");
});
multiWorker.on("end", (workerId) => {
console.log("worker[" + workerId + "] ended");
});
multiWorker.on("cleaning_worker", (workerId, worker, pid) => {
console.log("cleaning old worker " + worker);
});
multiWorker.on("poll", (workerId, queue) => {
console.log("worker[" + workerId + "] polling " + queue);
});
multiWorker.on("ping", (workerId, time) => {
console.log("worker[" + workerId + "] check in @ " + time);
});
multiWorker.on("job", (workerId, queue, job) => {
console.log(
"worker[" + workerId + "] working job " + queue + " " + JSON.stringify(job),
);
});
multiWorker.on("reEnqueue", (workerId, queue, job, plugin) => {
console.log(
"worker[" +
workerId +
"] reEnqueue job (" +
plugin +
") " +
queue +
" " +
JSON.stringify(job),
);
});
multiWorker.on("success", (workerId, queue, job, result) => {
console.log(
"worker[" +
workerId +
"] job success " +
queue +
" " +
JSON.stringify(job) +
" >> " +
result,
);
});
multiWorker.on("failure", (workerId, queue, job, failure) => {
console.log(
"worker[" +
workerId +
"] job failure " +
queue +
" " +
JSON.stringify(job) +
" >> " +
failure,
);
});
multiWorker.on("error", (workerId, queue, job, error) => {
console.log(
"worker[" +
workerId +
"] error " +
queue +
" " +
JSON.stringify(job) +
" >> " +
error,
);
});
multiWorker.on("pause", (workerId) => {
console.log("worker[" + workerId + "] paused");
});
multiWorker.on("multiWorkerAction", (verb, delay) => {
console.log(
"*** checked for worker status: " +
verb +
" (event loop delay: " +
delay +
"ms)",
);
});

multiWorker.start(); +
+ +

The Options available for the multiWorker are:

+
    +
  • connection: The redis configuration options (same as worker)
  • +
  • queues: Array of ordered queue names (or *) (same as worker)
  • +
  • minTaskProcessors: The minimum number of workers to spawn under this multiWorker, even if there is no work to do. You need at least one, or no work will ever be processed or checked
  • +
  • maxTaskProcessors: The maximum number of workers to spawn under this multiWorker, even if the queues are long and there is available CPU (the event loop isn't entirely blocked) to this node process.
  • +
  • checkTimeout: How often to check if the event loop is blocked (in ms) (for adding or removing multiWorker children),
  • +
  • maxEventLoopDelay: How long the event loop has to be delayed before considering it blocked (in ms),
  • +
+

This package was featured heavily in this presentation I gave about background jobs + node.js. It contains more examples!

+ +
diff --git a/interfaces/ConnectionOptions.html b/interfaces/ConnectionOptions.html new file mode 100644 index 00000000..4caa0d5f --- /dev/null +++ b/interfaces/ConnectionOptions.html @@ -0,0 +1,10 @@ +ConnectionOptions | node-resque

Interface ConnectionOptions

interface ConnectionOptions {
    database?: number;
    host?: string;
    looping?: boolean;
    namespace?: string | string[];
    options?: any;
    pkg?: string;
    port?: number;
    redis?: Cluster | Redis;
    scanCount?: number;
}

Properties

database?: number
host?: string
looping?: boolean
namespace?: string | string[]
options?: any
pkg?: string
port?: number
redis?: Cluster | Redis
scanCount?: number
diff --git a/interfaces/ErrorPayload.html b/interfaces/ErrorPayload.html new file mode 100644 index 00000000..e34cc38b --- /dev/null +++ b/interfaces/ErrorPayload.html @@ -0,0 +1,8 @@ +ErrorPayload | node-resque

Interface ErrorPayload

interface ErrorPayload {
    backtrace: string[];
    error: string;
    exception: string;
    failed_at: string | number;
    payload: {
        args: any[];
        class: string;
    };
    queue: string;
    worker: string;
}

Properties

backtrace: string[]
error: string
exception: string
failed_at: string | number
payload: {
    args: any[];
    class: string;
}
queue: string
worker: string
diff --git a/interfaces/Job.html b/interfaces/Job.html new file mode 100644 index 00000000..663fcb93 --- /dev/null +++ b/interfaces/Job.html @@ -0,0 +1,4 @@ +Job | node-resque

Interface Job<TResult>

interface Job<TResult> {
    perform: ((...args: any[]) => Promise<TResult>);
    pluginOptions?: {
        [pluginName: string]: {
            [key: string]: any;
        };
    };
    plugins?: any[];
}

Type Parameters

  • TResult

Properties

perform: ((...args: any[]) => Promise<TResult>)
pluginOptions?: {
    [pluginName: string]: {
        [key: string]: any;
    };
}
plugins?: any[]
diff --git a/interfaces/Jobs.html b/interfaces/Jobs.html new file mode 100644 index 00000000..f90a496c --- /dev/null +++ b/interfaces/Jobs.html @@ -0,0 +1 @@ +Jobs | node-resque

Interface Jobs

Indexable

  • [jobName: string]: Job<any>
diff --git a/modules.html b/modules.html new file mode 100644 index 00000000..f0e13568 --- /dev/null +++ b/modules.html @@ -0,0 +1,15 @@ +node-resque
diff --git a/types/ParsedFailedJobPayload.html b/types/ParsedFailedJobPayload.html new file mode 100644 index 00000000..fa811b45 --- /dev/null +++ b/types/ParsedFailedJobPayload.html @@ -0,0 +1 @@ +ParsedFailedJobPayload | node-resque

Type Alias ParsedFailedJobPayload

ParsedFailedJobPayload: {
    backtrace: string[];
    error: string;
    exception: string;
    failed_at: string;
    payload: ParsedJob;
    queue: string;
    worker: string;
}
diff --git a/types/ParsedJob.html b/types/ParsedJob.html new file mode 100644 index 00000000..5c4c0dd8 --- /dev/null +++ b/types/ParsedJob.html @@ -0,0 +1 @@ +ParsedJob | node-resque

Type Alias ParsedJob

ParsedJob: {
    args: any[];
    class: string;
    pluginOptions?: {
        [key: string]: any;
    };
    queue: string;
}
diff --git a/types/ParsedWorkerPayload.html b/types/ParsedWorkerPayload.html new file mode 100644 index 00000000..b7547540 --- /dev/null +++ b/types/ParsedWorkerPayload.html @@ -0,0 +1 @@ +ParsedWorkerPayload | node-resque

Type Alias ParsedWorkerPayload

ParsedWorkerPayload: {
    payload: ParsedJob;
    queue: string;
    run_at: string;
    worker: string;
}
diff --git a/variables/Plugins.html b/variables/Plugins.html new file mode 100644 index 00000000..cd4b02f2 --- /dev/null +++ b/variables/Plugins.html @@ -0,0 +1 @@ +Plugins | node-resque

Variable Plugins

Plugins: {
    DelayQueueLock: typeof DelayQueueLock;
    JobLock: typeof JobLock;
    Noop: typeof Noop;
    QueueLock: typeof QueueLock;
    Retry: typeof Retry;
}