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

retry-log

v1.0.4

Published

Process events in a log. Retry them a number of times. Then file them into failed.log or fixed.log

Downloads

17

Readme

retry-log

Process events in a log. Retry them a number of times. Then file them into failed.log or fixed.log

var processLog = require('retry-log')
var retryJob = require('your magic function that performs work')

var log = "./problems.log"

retry(log,function(data,cb){
  retryJob(data,cb)
},function(){
  console.log('all done processing')
})

API

  • retry(options,handler,done)
    • returns undefined
    • options
      • string, log file name
      • object
        • tries: 3, the number of times each job should be tried.
        • log: required. the log file to process
        • failedLog: the log file to write failed tasks
        • fixedLog: the log file to write fixed tasks
        • pid: optional, the pid of the process that writes the source log file.
        • rotateSignal: SIGHUP. if pid is provided this signal is delivered to the process. It is expected that it get a new handle to the log file because it will be moved and unlinked as part of managing the retries.

Files

this manages marshalling events in a log file to either a failed log or a fixed log

the log file.

  • the log file must contain newline delimited json
  • this module reserves 2 keys on this object. "tries" and "attempts"
    • "tries" is a number that incrments with each attempt
    • "attempts" is an array of {error:,data:} objects with the results of each attempt.

log life cycle

  • create job id (monotonic-timestamp)
  • rename log file to logname+".data_"+jobId
  • if pid is provided, signal pid and blindly trust that it releases the file descriptor
  • create a read stream with fs-readstream-many which is exactly the same ascat $logname.data_*
  • as each line is processed based on the result write to one of 3 logs.
    • if the job passes the line is appended to fixed.log
    • if the job fails and there are no more chances the line is appended to failed.log
    • if the job failed but still has more chances. the line gets added to logname+".tmp_"+jobId
  • after all jobs are complete if any lines have been written to the new retry log move logname+".tmp_"+jobId to logname+".data_"+jobId+"_result"
  • unlink all other logname+".data_* logs that were processed