hit-box / hitbox

A high-performance caching framework suitable for single-machine and for distributed applications in Rust
MIT License
73 stars 6 forks source link

feat/container #51

Closed topenkoff closed 1 year ago

topenkoff commented 2 years ago

Hey guys. I think, that Cacheable derive attributes, collected in one place, makes derive more scalable, easier for future support and hitbox namespace will allow you to more accurately determine the necessary attributes. Also it makes errors more understandable.

#[derive(Message, Cacheable, Serialize)]
#[hitbox(cache_ttl="str")]
#[rtype(result = "u64")]
struct GetNumber {
    number: u8,
}
error: Expected hitbox cache_ttl attribute should be u32
  --> src/main.rs:24:20
   |
24 | #[hitbox(cache_ttl="str")]
   |                    ^^^^^

Instead of

#[derive(Message, Cacheable, Serialize)]
#[cache_ttl("str")]
#[rtype(result = "u64")]
struct GetNumber {
    number: u8,
}
error: proc-macro derive panicked
  --> src/main.rs:23:19
   |
23 | #[derive(Message, Cacheable, Serialize)]
   |                   ^^^^^^^^^
   |
   = help: message: Parameter for macro cache_ttl should be u32

What do you think about it?

codecov[bot] commented 1 year ago

Codecov Report

Merging #51 (8dbd549) into tokio-backend (b06e7ad) will decrease coverage by 2.66%. The diff coverage is 0.00%.

@@                Coverage Diff                @@
##           tokio-backend      #51      +/-   ##
=================================================
- Coverage          69.12%   66.46%   -2.66%     
=================================================
  Files                 47       47              
  Lines                826      847      +21     
=================================================
- Hits                 571      563       -8     
- Misses               255      284      +29     
Impacted Files Coverage Δ
hitbox-derive/src/cacheable_macro.rs 0.00% <0.00%> (ø)
hitbox-derive/src/container.rs 0.00% <0.00%> (ø)
hitbox-derive/src/lib.rs 0.00% <0.00%> (ø)
hitbox/src/response.rs 0.00% <ø> (ø)
hitbox/src/states/finish/base.rs 50.00% <0.00%> (-16.67%) :arrow_down:
hitbox/src/states/cache_updated/base.rs 50.00% <0.00%> (-16.67%) :arrow_down:
hitbox/src/states/upstream_polled/error.rs 50.00% <0.00%> (-16.67%) :arrow_down:
hitbox/src/states/cache_policy/non_cacheable.rs 83.33% <0.00%> (-16.67%) :arrow_down:
...box/src/states/upstream_polled/error_with_stale.rs 50.00% <0.00%> (-16.67%) :arrow_down:
hitbox/src/states/cache_polled/actual.rs 81.81% <0.00%> (-9.10%) :arrow_down:
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.