1.0.29 • Published 2 years ago

nv-remote-recur v1.0.29

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

nv-remote-recur

  • recur task using redis for ctx backup
  • for test redis performance

install

  • npm install nv-remote-recur

usage

  const RRecur = require("nv-remote-recur")
  var cfg = {
      password:'redis',
      db :15,
      port:6379,
      host:'127.0.0.1',
      family:4
  }
  var recur = new RRecur(cfg)
  await recur.init()

example

        var init_ctx = RRecur.creat_v8ser_ctx({arr:[]},1000);


        async function handle(ctx) => {
              console.log(ctx)
              if(ctx.arr.length<5) {
                  ctx.arr.push(new Date);
                  ctx.dly_ = ctx.dly_ +1000;
              } else {
                  ctx._settle()
              }
        } 

        var [id,rid] = await recur.add(handle,init_ctx)
        
        await recur.get(id)  
        await recur.get(id)
        await recur.get(id)         // if ctx._settle() executed  will get nothing

list all pending task, this is slow, only for TEST

METHODS

Ctx

RRecur

      async .add(
             handle            : Function | Lambda,    
             ctx 
      ) -> [
          id#0  :  Int@(#0    <   2**48), 
          rid#1 :  Int@(#1+#0 === 2**48)
      ]
      
      
      async .del(id:Number)

LICENSE

  • ISC