Skip to content

Conversation

@haileyesus2433
Copy link
Contributor

@haileyesus2433 haileyesus2433 commented Jan 22, 2026

Prepare


Description

introduce DataApi trait and enhance DataStore functionality

Target issue

closes #13043

Implementation Details

  • Added DataApi trait to define a consistent interface for data store operations, including methods for pushing, retrieving, and managing data.
  • Implemented DataStoreStats struct to provide insights into the data store's state and usage.
  • Updated DataStore to implement the DataApi trait, enhancing its functionality with new methods for data management.
  • Enhanced documentation for the data module, including examples and descriptions of new components.

Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with docs: to indicate documentation changes or if the below checklist is not selected.

  • I confirm that there is no impact on the docs due to the code changes in this PR.

Summary by CodeRabbit

  • New Features
    • Introduced a public Data API for managing data with standard operations: storing, retrieving, removing, clearing, and listing entries with optional TTL (time-to-live) support.
    • Added data store statistics functionality to retrieve metrics including entry count, capacity limits, and metrics status.

✏️ Tip: You can customize this high-level summary in your review settings.

- Added `DataApi` trait to define a consistent interface for data store operations, including methods for pushing, retrieving, and managing data.
- Implemented `DataStoreStats` struct to provide insights into the data store's state and usage.
- Updated `DataStore` to implement the `DataApi` trait, enhancing its functionality with new methods for data management.
- Enhanced documentation for the data module, including examples and descriptions of new components.

Signed-off-by: haileyesus2433 <haileyesusbe@gmail.com>
@haileyesus2433 haileyesus2433 added this to the 1.16.0 milestone Jan 22, 2026
@haileyesus2433 haileyesus2433 self-assigned this Jan 22, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The PR introduces a new DataApi trait defining core DataStore operations (push_data, get_data, get_data_entry, remove_data, clear_data, list_data, get_stats) along with a DataStoreStats struct. The trait is implemented for DataStore and publicly exposed through module re-exports and the crate root level.

Changes

Cohort / File(s) Summary
API Definition
jans-cedarling/cedarling/src/data/api.rs
New public trait DataApi with seven methods for data access operations (push, get, remove, clear, list, stats). New public struct DataStoreStats capturing entry count, max entries, max entry size, and metrics status. Includes comprehensive method-level documentation.
Module Re-exports
jans-cedarling/cedarling/src/data/mod.rs
jans-cedarling/cedarling/src/lib.rs
Added module documentation and api module exposure. Re-exported DataApi, DataStoreStats, DataStore, DataStoreConfig, ConfigValidationError, DataEntry, CedarType, and DataError at module level and crate root, broadening the public surface.
Trait Implementation & Tests
jans-cedarling/cedarling/src/data/store.rs
Implemented DataApi trait for DataStore with all seven methods delegating to existing internal operations. Added private helper list_entries() to return all entries with metadata. Includes integration tests covering basic operations, TTL handling, and edge cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • olehbozhok
  • dagregi
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main changes: introducing DataApi trait and enhancing DataStore functionality.
Description check ✅ Passed The description follows the template structure with target issue, implementation details, and test/documentation checklist completed; all required sections are present and adequately filled.
Linked Issues check ✅ Passed The PR implements core DataApi trait methods (push_data, get_data, remove_data, clear_data, list_data, get_stats), DataStoreStats struct, and adds comprehensive tests covering TTL handling and error scenarios, meeting all specified coding requirements [#13043].
Out of Scope Changes check ✅ Passed All code changes are directly aligned with implementing the DataApi trait and enhancing DataStore functionality as specified in issue #13043; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mo-auto
Copy link
Member

mo-auto commented Jan 22, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@haileyesus2433
Copy link
Contributor Author

@coderabbitai please review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

@haileyesus2433: I'll review the changes in this PR.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@jans-cedarling/cedarling/src/data/store.rs`:
- Around line 878-1050: Replace direct assert_eq comparisons of
serde_json::Value or Option<Value> in the tests with test_utils::assert_eq to
get improved diffs; specifically update assertions in test_data_api_push_and_get
(the comparison of result to Some(json!({...})) and the missing Option),
test_data_api_get_entry (entry.value comparison to json!("test_value")), and any
other assertions comparing Value/Option<Value> in these tests to use
test_utils::assert_eq instead of assert_eq, keeping the same expected values and
operands but invoking test_utils::assert_eq for better output.
- Around line 264-268: list_entries currently returns every DataEntry from
storage.iter() without considering TTL; update the implementation in
list_entries (cedarling::data::store::list_entries) to filter out expired items
before collecting, e.g., only collect entries where the entry is not expired by
using the existing expiration check (call entry.is_expired() if present) or
compare the entry's expiration timestamp/ttl field against the current time, so
read paths honor the same auto_clear_expired semantics as write paths.

Signed-off-by: haileyesus2433 <haileyesusbe@gmail.com>
@moabu moabu modified the milestones: 1.16.0, 1.17.0 Jan 22, 2026
olehbozhok

This comment was marked as outdated.

///
/// # Examples
///
/// ```ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't mark this doc-code as ignored. It should compile.

If this trait is public in example, it should use Cedarling but not the internal implementation DataStore, which will be private.

You may add implementation to Cedarling in cedarling/src/lib.rs as it was made for LogStorage.

Copy link
Contributor

Choose a reason for hiding this comment

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

And if DataApi is supposed to be public, it should be reimported as public in cedarling/src/lib.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 653c1b7

//!
//! # Example
//!
//! ```ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

We already discussed that better to avoid ignore, and if it is not possible, we need to remove that doc-code. Because it is hard to support without automatic checking if it is compiling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 653c1b7

…methods

- Added `DataStore` as a member of the `Cedarling` struct to manage data storage.
- Implemented the `DataApi` trait for `Cedarling`, providing methods for data manipulation including push, get, remove, and list operations.
- Enhanced initialization of `Cedarling` to include a default `DataStoreConfig`.

Signed-off-by: haileyesus2433 <haileyesusbe@gmail.com>

// implements DataApi for Cedarling
// provides public interface for pushing and retrieving data
impl DataApi for Cedarling {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the DataStore implement DataApi when Cedarling is already implementing it why not call the methods in DataStore directly here instead? Something like self.data.push(key, value, ttl) I may have missed something though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no u didn't miss anything ur right, am currently refactoring it because i also have to update the tests thats why i will push the fix in a moment but thanks for pointing it out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 9634d72

- Updated `Cedarling` to use direct method calls from `DataStore`, simplifying the implementation of the `DataApi` trait.
- Refactored `DataStore` methods to improve clarity and maintainability, including making `list_entries` public.
- Enhanced `get_stats` method to directly return statistics from the `DataStore` configuration.

Signed-off-by: haileyesus2433 <haileyesusbe@gmail.com>
Copy link
Contributor

@olehbozhok olehbozhok left a comment

Choose a reason for hiding this comment

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

LGTM


// Initialize data store with default configuration
// TODO: Add DataStoreConfig to BootstrapConfig
let data = Arc::new(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think eventually we will move builing DataStore to the service factory

@olehbozhok
Copy link
Contributor

olehbozhok commented Jan 23, 2026

I also think that the folder name data is not really descriptive. Better to have something like context_data_api.

@haileyesus2433
Copy link
Contributor Author

I also think that the folder name data is not really descriptive. Better to have something like context_data_api.

ok i will update it

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.

6 participants