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

@ncf/ext-later-rocksdb

v0.1.0

Published

延迟服务

Downloads

3

Readme

延迟服务场景

  • 解耦。可最终一致的处理步骤。如下单成功,延迟零秒发送短信通知。这样发送短信服务是否可用只要进入任务队列,就最终会执行,从而解耦提高处理反馈速度,提高服务可用性。
  • 如指定时长内没有支付,则自动关单
  • 当任务队列中的任务执行失败,自动继续延迟重试

延迟服务

  • 采用标准的 http 服务来接受延迟任务请求。
    • http 服务接口背后的实现,可以是基于 leveldb/rocksdb 的实现,也可以替换成任何实现。
    • NCF faas 做延迟调用的背后,只需要向 http 延迟服务发送标准 http 请求即可。
    • 这样的设计,NCF 服务无需引入特定协议的支持软件包,保持 NCF 的简单性。
    • 后面也可能引用 http2,来提升性能。甚至能延迟执行带请求 stream 的任务。
  • 延迟服务单进程
    • 可以通过 k8s 单 pod 来保证,同时支持自动失败重启
    • 延迟服务如果使用 leveldb/rocksdb 等嵌入式数据库,也只能单进程访问
  • 延迟队列的实现
    • 目前采用基于 rocksdb 实现,数据文件必须落到可靠存储上才能保证安全
    • 不采用基于 MQ 的实现,因为现有 MQ 并不针对延迟设计,性能上可能设计不足。另外进入 MQ 需要引入额外的服务或基础设施增加的运维的工作。
    • 但是 MQ 的一个好处是,一般有监控和管理的配套工具,API 的命令行的或者 web 页面的。
  • 在 kv 中的编码
    • key 为 js Date 时间戳数字 + 防止同一毫秒冲突的随机数
    • value 为 [path,request,retry,pushTime] tuple 格式,减少固定的 key 在每条消息中的重复浪费。

implementation

本 package 基于嵌入式 rocksdb 实现延迟任务队列。

使用

环境变量

  1. PORT 本服务监听端口,默认 7779
  2. NCF_HOST 如 127.0.0.1:8000,配置任务执行调用的 NCF 服务的地址