Code Monkey home page Code Monkey logo

modak-rate-limiter's Introduction

modak-rate-limiter

This is the solution for the take-home test required as a part of the interview process for Modak.

Building and Running the Project

Once you check out the code from GitHub, the project can be run using from the project source:

go mod tidy

go build -o notifications src/api/main.go

./notifications

Example Request/Responses

Send notification for user

Request:

curl --location --request POST 'localhost:8080/notifications' \
--header 'Content-Type: application/json' \
--data-raw '{
    "user_id": "user_123",
    "type": "news",
    "message": "message to send"
}'
Successful Response :

Response with HTTP Status: 202

Error Responses:
{
    "error": "Forbidden",
    "message": "news's notification type for user_123 user reached it's limit!",
    "status": 403
}

Sample Data

The project builds with the following sample rate limiting rules in the DB:

  • Status: not more than 1 per 10 seconds for each recipient
  • News: not more than 3 per 30 seconds for each recipient
  • Marketing: not more than 4 per minute for each recipient

These can be edited in the applications/services.go file.

NOTE: The endpoints to manage rules were left out of the project scope.

modak-rate-limiter's People

Contributors

martinseco avatar

Watchers

 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.