Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQLite support #9

Merged
merged 27 commits into from
Jan 9, 2024
Merged

Add SQLite support #9

merged 27 commits into from
Jan 9, 2024

Conversation

julik
Copy link
Contributor

@julik julik commented Jan 3, 2024

Allow Pecorino throttles and leaky buckets to be defined using SQLite. Note that it is not the SQLite "time" value that we use, but the Ruby value - it has a finer resolution and is easier to work with, and should be harmless since SQLite is in-process anyway.

The same could potentially be done with SQLite date and time functions, but I found them very hard to work with for getting time intervals - and the best resolution I could obtain was milliseconds, whereas Pecorino benefits from time resolution being finer than that.

The change moves the DB statements used into separate modules, one per DB. Since we only got 2 now I opted for inheritance in tests - to avoid duplication. Once we get a third one in we might switch to using a module.

Closes #4

lib/pecorino.rb Outdated Show resolved Hide resolved
@julik
Copy link
Contributor Author

julik commented Jan 4, 2024 via email

@julik julik marked this pull request as ready for review January 8, 2024 14:19
@julik julik requested a review from skatkov January 8, 2024 14:19
@julik
Copy link
Contributor Author

julik commented Jan 8, 2024

There is a bit I don't like that much - that we create one adapter object per method call - but we can optimise this later

although I must admit I don't like them all that much
lib/pecorino/leaky_bucket.rb Outdated Show resolved Hide resolved
lib/pecorino.rb Show resolved Hide resolved
@julik julik merged commit fe5d72c into main Jan 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SQLite support
2 participants