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

feat: add StringAdapter to file adapter module #343

Closed
wants to merge 1 commit into from

Conversation

sanbei101
Copy link

This pull request introduces a new StringAdapter to handle policy strings directly, along with necessary integrations and updates to the existing codebase. The most important changes include the addition of the StringAdapter struct and its implementation, updates to the adapter module to include the new adapter, and modifications to the main library file to use the new adapter.

Introduction of StringAdapter:

  • src/adapter/file_adapter.rs: Added the StringAdapter struct with methods to load, save, and clear policies from a string, and implemented the Adapter trait for it.

Module updates:

Library updates:

  • src/lib.rs: Modified to conditionally export StringAdapter along with other adapters.

pub use adapter::{Adapter, Filter, MemoryAdapter, NullAdapter};
#[cfg(not(target_arch = "wasm32"))]
pub use adapter::{FileAdapter, StringAdapter};

#[cfg(feature = "cached")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is missing

pub use adapter::{Adapter, Filter, MemoryAdapter, NullAdapter};
#[cfg(not(target_arch = "wasm32"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this? and location?

@@ -290,3 +290,160 @@ fn load_filtered_policy_line(
false
}
}

pub struct StringAdapter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New file: string_adapter.rs

@sanbei101 sanbei101 closed this Oct 6, 2024
@hsluoyz hsluoyz reopened this Oct 6, 2024
@hsluoyz hsluoyz closed this Oct 6, 2024
Copy link

github-actions bot commented Oct 6, 2024

Benchmark for c5a05d3

Click to view benchmark
Test PR Benchmark Master Benchmark %
b_benchmark_rbac_model_large 10.2±0.08ms 10.2±0.06ms 0.00%
benchmark priority model 4.4±0.04µs 4.3±0.04µs +2.33%
benchmark_abac_model 2.6±0.05µs 2.5±0.04µs +4.00%
benchmark_basic_model 4.0±0.06µs 3.8±0.06µs +5.26%
benchmark_key_match 7.4±0.12µs 7.3±0.17µs +1.37%
benchmark_raw 0.0±0.00ns 0.0±0.00ns NaN%
benchmark_rbac_model 6.4±0.17µs 6.2±0.08µs +3.23%
benchmark_rbac_model_medium 853.6±21.86µs 889.0±4.78µs -3.98%
benchmark_rbac_model_with_domains 6.1±0.11µs 5.9±0.12µs +3.39%
benchmark_rbac_with_deny 8.7±0.13µs 8.6±0.13µs +1.16%
benchmark_rbac_with_resource_roles 4.6±0.06µs 4.5±0.05µs +2.22%
benchmark_role_manager_large 4.6±0.02ms 4.6±0.01ms 0.00%
benchmark_role_manager_medium 311.9±2.52µs 304.3±4.89µs +2.50%
benchmark_role_manager_small 92.9±1.70µs 91.1±1.09µs +1.98%

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.

2 participants