Code Monkey home page Code Monkey logo

clockwork's Introduction

Clockwork-Scheduler

Clockwork-Scheduler is a general purpose distributed job scheduler. It offers you horizontally scalable scheduler with atleast once delivery guarantees. Currently supported task delivery mechanism is kafka, at task execution time the schedule data is pushed to the given kafka topic.

It uses kafka for task buffering ordering, shard calculation and delivery. Currently DynamoDB is the only supported database.

Architecture

Find more on blog here

architecture

Getting Started

Prerequisites

java > 8
kafka > 0.11
DynamoDB

Setup

  • Create a dynamodb table called partitionExecutions with partitionKey partitionId(String) and no sort key.

  • Create a dynamodb table called schedules with partitionKey partitionId(String) and scheduleTime(Number).

  • (Optional) if you will be using cancel api then create a GSI on table called scheduleKey-index.

  • Set environment variables KAFKA_BROKERS, KAFKA_CONSUMER_GROUP, AWS_REGION AWS_ACCESS_KEY, AWS_SECRET_KEY, SCHEDULE_DB and PARTITION_EXEC_DB.

You can modify custom settings here src/main/resources/application.properties.

Run

mvn package and java -jar {package.jar}

Usage

Create schedulePOST /schedule

{
	"clientId": "client1",
	"scheduleKey": "order1-create",
	"orderingKey": "order1",
	"taskData": "payload",
	"delivery": {
		"topic": "orderTopic"
	},
	"scheduleTime": 1553629195570
}

clientId: field to identify clients in multi client deployment
scheduleId: unique key for schedule (clientId + scheduleId should be unique
orderingKey: (to guarantee ordering among schedule) all schedule with same ordering key will be delivered in order taskData: payload you want to receive when schedule fires topic: kafka topic in which you want to receive event scheduleTime: schedule time in epoch

TODO

  • Support REST callback
  • Support Cassandra store

Advanced

Kafka

To customise kafka connection settings eg. authentication use modify config/KafkaConfig

Logging

All private methods are logged by default by aspect logger in /aspect, You can disable logging on particular method by adding @NoLogging to it or remove PublicMethodLogging to remove all logging

Metrics

Micrometer is used to push execution and creation metrics to elasticsearch to publish dashboards configure management.metrics.export.elastic.* properties to set it up

Executor

backoffsleeptime.sec time to sleep if nothing to execute after number(5) of retries

clockwork's People

Contributors

mtwstudios avatar uttpal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.