npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-remote-retry

v1.0.19

Published

nv-remote-retry ===================== - retry task using redis

Downloads

4

Readme

nv-remote-retry

  • retry task using redis

install

  • npm install nv-remote-retry

usage

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

example

    var handle = async (lefted_times,a,b,c)=> {
           console.log(lefted_times, new Date())
           console.log(a,b,c)
           let rand = Math.random();
           if(rand>0.8) {
                 console.log("success: ",rand)
                 return([true,rand])
           } else {
                console.log("fail: ",rand)
                return([false,rand])
           }
    }        
    
    
    var arg_ary = [
         new Map([[100,200]]),
         new Set([300,400]),
        {a:500,b:[600,700]}
    ]


    var [id,rid] = await retry.add_retry_task(handle,arg_ary,5,6000);                 
    //retry max 5 times  for every  6 second
    //  will RETURN a id-pair       

succ

    > retry.list_all5 2022-11-05T07:57:12.126Z
    Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
    fail:  0.4219821578177563
    > 4 2022-11-05T07:57:18.161Z
    Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
    fail:  0.10755268101657967

    > 3 2022-11-05T07:57:24.201Z
    Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
    success:  0.9279835941851622

fail

        > var [id,rid]  = await retry.add_retry_task(handle,arg_ary,5,6000);
        > 5 2022-11-05T07:58:19.844Z
        Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
        fail:  0.19502970946958698

        > 4 2022-11-05T07:58:25.885Z
        Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
        fail:  0.6033240882938884

        > 3 2022-11-05T07:58:31.925Z
        Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
        fail:  0.238829682926065

        > 2 2022-11-05T07:58:37.965Z
        Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
        fail:  0.6222257875394948

        > 1 2022-11-05T07:58:44.003Z
        Map(1) { 100 => 200 } Set(2) { 300, 400 } { a: 500, b: [ 600, 700 ] }
        fail:  0.5639765495604092

        >

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

                var arg_ary = [
                     new Map([[100,200]]),
                     new Set([300,400]),
                    {a:500,b:[600,700]}
                ]

                var [id,rid]  = await retry.add_retry_task(handle,arg_ary,5,20000);

                var arg_ary = [
                     1, new Date(), new Error("eeeee")
                ]
               var [id,rid]  = await retry.add_retry_task(handle,arg_ary,5,20000);


        > await retry.list_all()
        [
          [
            Map(1) { 100 => 200 },
            Set(2) { 300, 400 },
            { a: 500, b: [Array] }
          ],
          [
            1,
            2022-11-05T08:03:34.354Z,
            Error: eeeee
                at REPL37:2:29
                at Script.runInThisContext (node:vm:129:12)
                at REPLServer.defaultEval (node:repl:571:29)
                at bound (node:domain:421:15)
                at REPLServer.runBound [as eval] (node:domain:432:12)
                at REPLServer.onLine (node:repl:898:10)
                at REPLServer.emit (node:events:539:35)
                at REPLServer.emit (node:domain:475:12)
                at [_onLine] [as _onLine] (node:internal/readline/interface:424:12)
                at [_line] [as _line] (node:internal/readline/interface:885:18)
          ]
        ]

METHODS

      async .add_retry_task(
             handle            : Function | Lambda,    
             args_ary          : Array<any@StructureClonable> ,
                                  // handle(lefted_retry_times,...args_ary)                           
             max_retry_times    : Int32 ,
             retry_interval     : Int32@('unit IS "ms")
      ) -> [
          id#0  :  Int@(#0    <   2**48), 
          rid#1 :  Int@(#1+#0 === 2**48)
      ]
      
      
      async .cancel_retry_task(id:Number)

LICENSE

  • ISC