All Projects → nickelser → Zhong

nickelser / Zhong

Licence: other
Reliable, distributed cron.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Zhong

Cachemanager
CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
Stars: ✭ 2,049 (+629.18%)
Mutual labels:  redis, memcached
Scrapbook
PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.
Stars: ✭ 279 (-0.71%)
Mutual labels:  redis, memcached
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (-41.28%)
Mutual labels:  redis, memcached
Sequelize Transparent Cache
Simple to use and universal cache layer for Sequelize
Stars: ✭ 137 (-51.25%)
Mutual labels:  redis, memcached
Flipper
🐬 Beautiful, performant feature flags for Ruby.
Stars: ✭ 2,732 (+872.24%)
Mutual labels:  redis, memcached
Cachego
Golang Cache component - Multiple drivers
Stars: ✭ 148 (-47.33%)
Mutual labels:  redis, memcached
Ninja Mutex
Mutex implementation for PHP
Stars: ✭ 180 (-35.94%)
Mutual labels:  redis, memcached
Dogpile.cache
dogpile.cache is a Python caching API which provides a generic interface to caching backends of any variety
Stars: ✭ 106 (-62.28%)
Mutual labels:  redis, memcached
Lnmp
LEMP stack/LAMP stack/LNMP stack installation scripts for CentOS/Redhat Debian and Ubuntu
Stars: ✭ 2,488 (+785.41%)
Mutual labels:  redis, memcached
Zend Diagnostics
Universal set of diagnostic tests for PHP applications.
Stars: ✭ 192 (-31.67%)
Mutual labels:  redis, memcached
Zhttp
基于swoole的异步轻量级web框架,内部封装协程异步非阻塞全套mysql、redis、mongo、memcached连接池,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用
Stars: ✭ 131 (-53.38%)
Mutual labels:  redis, memcached
Go Todo
微信小程序 todo后端,采用GoFrame框架搭建,包含微信认证、token管理、发送微信模板消息等
Stars: ✭ 60 (-78.65%)
Mutual labels:  cron, redis
Overlord
Overlord是哔哩哔哩基于Go语言编写的memcache和redis&cluster的代理及集群管理功能,致力于提供自动化高可用的缓存服务解决方案。
Stars: ✭ 1,884 (+570.46%)
Mutual labels:  redis, memcached
Oneinstack
OneinStack - A PHP/JAVA Deployment Tool
Stars: ✭ 1,983 (+605.69%)
Mutual labels:  redis, memcached
Mdserver Mac
mdserver (mac version, secondary development)
Stars: ✭ 121 (-56.94%)
Mutual labels:  redis, memcached
Ansible Role Redis
Ansible Role - Redis
Stars: ✭ 176 (-37.37%)
Mutual labels:  redis, memcached
Butterfly
🔥 蝴蝶--【简单】【稳定】【好用】的 Python web 框架🦋 除 Python 2.7,无其他依赖; 🦋 butterfly 是一个 RPC 风格 web 框架,同时也是微服务框架,自带消息队列通信机制实现分布式
Stars: ✭ 82 (-70.82%)
Mutual labels:  redis, memcached
Fastapi Plugins
FastAPI framework plugins
Stars: ✭ 104 (-62.99%)
Mutual labels:  redis, memcached
Phpfastcache
A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
Stars: ✭ 2,171 (+672.6%)
Mutual labels:  redis, memcached
Zapi
基于swoole的异步轻量级api框架,内部封装全套mysql、redis、mongo、memcached异步客户端,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用。现已支持异步mysql、异步redis、异步http请求.
Stars: ✭ 245 (-12.81%)
Mutual labels:  redis, memcached

Zhong Build Status Code Climate Gem Version

Useful, reliable distributed cron. Tired of your cron-like scheduler running key jobs twice? Would you like to be able to run your cron server on multiple machines and have it "just work"? Have we got the gem for you.

Zhong uses Redis to acquire exclusive locks on jobs, as well as recording when they last ran. This means that you can rest easy at night, knowing that your customers are getting their monthly Goat Fancy magazine subscriptions and you are rolling around in your piles of money without a care in the world.

🍊 Battle-tested at Instacart

Installation

Add this line to your application’s Gemfile:

gem 'zhong'

Usage

Zhong schedule

Create a definition file, let's call it zhong.rb:

Zhong.redis = Redis.new(url: ENV["ZHONG_REDIS_URL"])

Zhong.schedule do
  category "stuff" do
    every 5.seconds, "foo" do
      puts "foo"
    end

    every(1.minute, "running biz at 26th and 27th minute", at: ["**:26", "**:27"]) { puts "biz" }
    every(1.week, "running baz on mon and wed", at: ["mon 22:45", "wed 23:13"]) { puts "baz" }
    every(10.seconds, "boom every 10 seconds") { raise "fail" }
  end

  category "clutter" do
    every(1.second, "compute", if: -> (t) { t.wday == 3 && rand < 0.5 }) do
      puts "something happened on wednesday, maybe"
    end
  end

  # note: callbacks that explicitly false will cause event to not run
  on(:before_tick) do
    puts "ding"
    true
  end

  on(:after_tick) do
    puts "dong"
  end

  on(:before_run) do |job, time|
    puts "running #{job}"
    true # can conditionally run a specific job
  end

  on(:after_run) do |job, time, ran|
    puts "#{job} ran?: #{ran}"
  end

  on(:before_disable) do |job|
    puts "#{job} is going to be disabled"
  end

  on(:after_disable) do |job|
    puts "#{job} disabled"
  end

  on(:before_enable) do |job|
    puts "#{job} is going to be enabled"
  end

  on(:after_enable) do |job|
    puts "#{job} enabled"
  end

  error_handler do |e, job|
    puts "dang, #{job} messed up: #{e}"
  end
end

This file only describes what should be the schedule. Nothing will be executed until we actually run

Zhong.start

after describing the Zhong schedule.

Zhong cron process

You can run the cron process that will execute your code from the definitions in the zhong.rb file by running:

zhong zhong.rb

Web UI

Zhong comes with a web application that can display jobs, their last run and enable/disable them.

This is a Sinatra application that requires at least v2.0.0. You can add to your Gemfile

gem 'sinatra', "~>2.0"

It can be protected by HTTP basic authentication by setting the following environment variables:

  • ZHONG_WEB_USERNAME: the username
  • ZHONG_WEB_PASSWORD: the password

You'll need to load the Zhong schedule to be able to see jobs in the web UI, typically by requiring your zhong.rb definition file.

Rails

Load the Zhong schedule by creating an initializer at config/initializers/zhong.rb, with the following content:

require "#{Rails.root}/zhong.rb"

Add the following to your config/routes.rb:

require 'zhong/web'

Rails.application.routes.draw do
  # Other routes here...

  mount Zhong::Web, at: "/zhong"
end

History

View the changelog.

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].