Giter Club home page Giter Club logo

user-quotas's Introduction

Consume quotas API.

This project is an example of how to implement rate limit in different databases.

Technologies

In this project I am using:
Spring boot application. Mysql server. H2 database to represent elastic search database. Maven

Patterns implements

To cover this rule:

During the day 9:00 - 17:00 (UTC) we use MySql as a source
During the night 17:01 - 8:59 we use Elastic
I implemented AbstractRoutingDataSource pattern from spring boot.

To cover rate limit rule:

I implemented AOP approach, creating QuotaLimit annotation.
In my opinion, this is the fastest way to scale up this rule accross multiples controllers and methods.

Starting the Application

Run the UserQuotasApplication class start dock-compose up -d to run mysql instance.

Testing

This project includes both unit tests and integration tests.

just execute it using maven or ide. obs: make sure to have mysql instance running.

API Documentation

The API documentation is generated using OpenAPI 3.0 and can be accessed at http://localhost:8080/swagger-ui.html and http://localhost:8080/v3/api-docs.

H2 Console

In order to see and interact with your db, access the h2 console in your browser. After running the application, go to:

http://localhost:8080/h2-console

Enter the information for the url, username, and password in the application.properties:

url: jdbc:h2:mem:test
username: sa 
password: password

Improvements

this project doesn't sync databases.

Possibles approachs to do it:
Create a scheduler to run based on cron job to sync all databases.
Create a event first approach to insert on all intances.
Use a middleware to sync databases.

user-quotas's People

Contributors

edu1006 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.