Commit Graph

31 Commits

Author SHA1 Message Date
Flori 69b7c2445c Ratelimiter overhaul (#144)
* Rename limits and limit to have better names

* Remove empty lines

* Remove handle_request (moved to requestlimiter)

* Start working on new ratelimiter

* Make limits Option, add "limited?" to constructor

* Add missing logic to send_request

* Rename Limits

* Create Ratelimits and Limit Struct

* Define Limit

* Import Ratelimits

* Define get_rate_limits

* Remove unused import

* + check_rate_limits & limits_config_to_ratelimits

* Remove Absolute Limits
These limits are not meant to be tracked anyways.

* add ratelimits is_exhausted

* Add error handling and send request checking

* change limits to option ratelimits

* Add strum

* Change Ratelimits to Hashmap

* Remove ratelimits in favor of hashmap

* Change code from struct to hashmap

* start working on update rate limits

* Remove wrong import

* Rename ChorusLibError to ChorusError

* Documented the chorus errors

* Made error documentation docstring

* Make ReceivedErrorCodeError have error string

* Remove unneeded import

* Match changes in errors.rs

* Improve update_rate_limits and can_send_request

* add ratelimits.to_hash_map()

* use instances' client instead of new client

* add LimitsConfiguration to instance

* improve update_limits, change a method name

* Fix un-updated errors

* Get LimitConfiguration in a sane way

* Move common.rs into ratelimiter::ChorusRequest

* Delete common.rs

* Make instance.rs use overhauled errors

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* update ratelimiter implementation across all files

* Fix remaining errors post-refactor

* Changed Enum case to be correct

* Use result

* Re-add missing body to request

* Remove unneeded late initalization

* Change visibility from pub to pub(crate)
I feel like these core methods don't need to be exposed as public API.

* Remove unnecessary import

* Fix clippy warnings

* Add docstring

* Change Error names across all files

* Update Cargo.toml

Strum is not needed

* Update ratelimits.rs

* Update ratelimits.rs

* Bug/discord instance info unavailable (#146)

* Change text to be more ambigous

* Use default Configuration instead of erroring out

* Emit warning log if instance config cant be gotten

* Remove import

* Update src/instance.rs

Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>

* Add missing closing bracket

* Put limits and limits_configuration as one struct

* Derive Hash

* remove import

* rename limits and limits_configuration

* Save clone call

* Change LimitsConfiguration to RateLimits
`LimitsConfiguration` is in no way related to whether the instance has API rate limits enabled or not. Therefore, it has been replaced with what it should have been all along.

* Add ensure_limit_in_map(), add `window` to `Limit`

* Remove unneeded var

* Remove import

* Clean up unneeded things
Dead code warnings have been supressed, but flagged as FIXME so they don't get forgotten. Anyone using tools like TODO Tree in VSCode can still see that they are there, however, they will not be shown as warnings anymore

* Remove nested submodule `limit`

* Add doc comments

* Add more doc comments

* Add some log messages to some methods

---------

Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-09 18:38:02 +02:00
Vincent Junge f98180cd03 ChorusResult type alias 2023-06-21 21:39:22 +02:00
Flori Weber 6542a7a362 Add reqwest::Client to chorus::Instance. 2023-06-20 22:41:31 +02:00
Vincent Junge 9c7031abde UrlBundle remove getters 2023-06-20 12:29:52 +02:00
Vincent Junge 208eeac536 Fix various Clippy lints 2023-06-19 12:35:07 +02:00
Flori Weber f641dbb14f Reformat entire project, optimize imports 2023-06-11 13:52:31 +02:00
bitfl0wer 972100af65 Change UserMeta: User instead of Option<User>
I do not know why I have made it optional in the first place. hm
2023-06-10 00:35:51 +02:00
bitfl0wer b0a19faa48 Change InstanceServerError to ChorusLibError
The name InstanceServerError was chosen without thinking about it too much, very early in development. The new name suits this custom Error type way better, in my opinion.
2023-06-08 22:16:23 +02:00
bitfl0wer 5b324db391 Finish refactor 2023-05-26 12:50:16 +02:00
bitfl0wer f74b9c4c0d start porting over new types folder 2023-05-25 23:09:18 +02:00
bitfl0wer 8a1c1f0a41 Replace &mut Instance with Rc<RefCell<Instance>>
Replace &mut Instance with Rc<RefCell<Instance>> on the User struct to represent the 1:n relation of Instance:User
2023-05-20 23:10:25 +02:00
kozabrada123 a3969e8cb6 Small changes for merging 2023-05-13 16:43:29 +02:00
kozabrada123 6dfaa6e91f Attempted reimpl 2023-05-11 22:47:31 +02:00
kozabrada123 6ce7396275 Merge branch 'feature/gateway-observer' into main 2023-05-09 18:35:53 +00:00
bitfl0wer 6a94d34bb5 Remove unneccessary imports 2023-05-07 12:39:56 +02:00
bitfl0wer 240882ffdf Remove lifetime from Instance (see below)
Originally, it was planned, that the Instance object would store Users. I have identified, that this was not needed, as it goes beyond the scope of a library; Users of this library are expected to keep track of users themselves. The removal of this user storage also prevented further overcomplications.
2023-05-07 12:39:04 +02:00
kozabrada123 a4fdf18106 Fixed instance lifetime parameter 2023-05-05 22:46:00 +02:00
kozabrada123 22bfe1be07 Readd gateway to instance 2023-05-05 22:04:57 +02:00
bitfl0wer 5edc92524c Add lifetime to Instance 2023-05-03 16:37:10 +02:00
bitfl0wer 3b8891b2dd Improve readability 2023-04-25 17:41:14 +02:00
bitfl0wer 6f2dac6695 Split up schemas.rs 2023-04-25 17:32:30 +02:00
bitfl0wer 88b715ee6c Merge remote-tracking branch 'origin/main' into improvement/update-rate-limiter-implementation 2023-04-24 19:50:36 +02:00
bitfl0wer 30742380b9 Change HashMap<> to Limits 2023-04-24 19:49:26 +02:00
bitfl0wer 82770c0400 Create internal User and API UserObject 2023-04-23 21:32:48 +02:00
bitfl0wer 752c885c10 Remove boilerplate errors 2023-04-21 23:20:23 +02:00
bitfl0wer b577161733 add users hashmap 2023-04-19 23:32:02 +02:00
bitfl0wer 6a8260c4bb make progress on instance object creation 2023-04-19 20:41:33 +02:00
bitfl0wer d4ea4bd096 remove token check, add username impl 2023-04-17 22:38:21 +02:00
bitfl0wer f12d5ed8f6 add Token struct and impl 2023-04-17 21:31:15 +02:00
bitfl0wer 3be962146b add gateway object 2023-04-16 23:03:12 +02:00
bitfl0wer f6fce684c1 Rename client to instance 2023-04-16 22:16:22 +02:00