GithubHelp home page GithubHelp logo

web-hook-scheduler's Introduction

Description

Webhook scheduler service

Architecture

Service uses the queue approach (job/worker) to schedule the jobs.

schduler drawio

Service consists of three applications: ( see: https://github.com/martynk981/web-hook-scheduler/tree/main/apps )

  • web-hook-scheduler API to create jobs and to get the status of a job

    GET /timers/{jobId} returns job status:

    {
      "id": "2",
      "url": "http://localhost:9000",
      "timeLeft": 4,
      "status": "created" | "processed" | "failed"
    }

    POST /timers creates a new job in the queue. Payload:

    {
      "hours": 0,
      "minutes": 0,
      "seconds": 10,
      "url": "http://localhost:9000"
    }
  • web-hook-worker Standalone application which listens to the queue and runs jobs

  • web-hook-target Simple application to test the webhooks. Stores in the memory cache last calls for 10 minutes. GET /{id} - logs to the cache the id

    GET /log/access-log - returns all logged ids

    Appications web-hook-schedule and web-hook-worker can be scaled out and run as many instances as needed, the only thing which has to be set up is a load balancer before the web-hook-schedule API. Redis is used to store jobs MongoDb stores logs of the jobs, since once job is completed it is removed from the redis

Tech stack:

Running the app

  1. Create the redis and mongo server
$ docker-compose up -d
  1. Install dependencies
$ npm i
  1. Run the application stack (web-hook-scheduler, web-hook-worker, web-hook-target)
$ npm run start

It runs 3 applications:

Test

# e2e tests
$ npm run test:e2e

Test runs the next scenario:

  1. Schedules a new job delayed for 5 seconds with the target URL http://localhost:9000 (web-hook-target)
  2. Checks the status of the new job by the jobId returned at step 1.
  3. Waits for 6 seconds
  4. Checks if the status of the job is 'processed'
  5. Checks if the http://localhost:9000 (web-hook-target) was called with the jobId

TODO

  • Request validation
  • Open API spec
  • Unit test coverage
  • Error handling

web-hook-scheduler's People

Contributors

martynk981 avatar

Stargazers

Dimah Snisarenko avatar

Watchers

James Cloos 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.