Skip to content

Conversation

@pmdevers
Copy link
Owner

@pmdevers pmdevers commented Jun 25, 2025

Summary by CodeRabbit

  • New Features

    • Added configuration options for RocksDB storage, allowing customization of data path and serializer.
    • Introduced support for using a JSON-based serializer with customizable options for RocksDB storage.
  • Refactor

    • Updated RocksDB integration to use a flexible options object instead of a simple path string.
    • Improved in-memory store to reuse stream store instances for better performance and thread safety.
    • Refactored Kafka producer factory to better manage configuration metadata.
  • Tests

    • Updated tests to use the new RocksDB options configuration.

Patrick Evers added 3 commits June 25, 2025 11:37
Introduces RocksDBOptions to encapsulate configuration settings, including the data path and serializer.

Adds extension methods to streamline RocksDB integration and JSON serialization configuration, allowing users to customize JSON serialization behavior through options.

Updates RocksDBStreamStoreFactory to use the configured serializer for data storage.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

This update introduces a new RocksDBOptions configuration class, refactors the RocksDB integration to use this options object instead of a string path, and adds a flexible JSON serializer configuration for RocksDB storage. The in-memory stream store factory now caches and reuses store instances by type. Test setup is updated to use the new options pattern. Additionally, KafkaProducerFactory constructor is refactored to encapsulate config creation and expose metadata.

Changes

File(s) Change Summary
src/MinimalKafka.RocksDB/ByteSerializer.cs Constructor now accepts JsonSerializerOptions; methods use provided options for serialization.
src/MinimalKafka.RocksDB/KafkaBuilderExtensions.cs UseRocksDB now takes an options delegate; adds UseJsonSerializer for serializer configuration.
src/MinimalKafka.RocksDB/RocksDBOptions.cs Introduces new RocksDBOptions class with DataPath and Serializer properties.
src/MinimalKafka.RocksDB/RocksDBStoreManager.cs RocksDBStreamStoreFactory now uses RocksDBOptions for config and serializer, not just a path string.
src/MinimalKafka/KafkaProducerFactory.cs Adds public Metadata property; refactors config logic into BuildConfig() method.
src/MinimalKafka/Stream/Storage/InMemoryStore.cs InMemoryStreamStoreFactory now caches and reuses store instances by type.
test/MinimalKafka.RocksDB.Tests/StreamStore_Tests.cs Updates RocksDB setup to use options delegate for setting data path in tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant KafkaBuilder
    participant RocksDBOptions
    participant RocksDBStreamStoreFactory

    User->>KafkaBuilder: UseRocksDB(options => { ... })
    KafkaBuilder->>RocksDBOptions: Configure DataPath, Serializer, etc.
    KafkaBuilder->>RocksDBStreamStoreFactory: Initialize with RocksDBOptions
    RocksDBStreamStoreFactory->>RocksDBOptions: Access DataPath and Serializer
Loading

Possibly related PRs

  • Check if configuration is present #88: Refactors KafkaProducerFactory<TKey, TValue> constructor and configuration handling, related due to similar changes in producer factory logic and metadata management.

Poem

In burrows deep where options grow,
RocksDB now learns to know
Its path, its bytes, its way to store,
With serializers at its core.
Caching streams, a clever feat—
This code hop makes storage neat!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3aeba7 and a7996d7.

📒 Files selected for processing (1)
  • src/MinimalKafka/Stream/Storage/InMemoryStore.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Build
🔇 Additional comments (1)
src/MinimalKafka/Stream/Storage/InMemoryStore.cs (1)

2-2: LGTM! Required import for thread-safe collection.

The using statement is correctly added to support the ConcurrentBag implementation.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 6

🧹 Nitpick comments (2)
src/MinimalKafka.RocksDB/RocksDBStoreManager.cs (1)

1-1: Remove unused using statements.

The using Confluent.Kafka; and using System.Text.Json; directives don't appear to be used in this file. Consider removing them to keep the imports clean.

-using Confluent.Kafka;
 using RocksDbSharp;
 using System.Collections.Concurrent;
-using System.Text.Json;

Also applies to: 4-4

src/MinimalKafka.RocksDB/KafkaBuilderExtensions.cs (1)

32-51: Consider improving the UseJsonSerializer method documentation.

The XML documentation could be more specific about what happens when the options delegate is null and provide a clearer example of usage.

 /// <summary>
 /// Configures the specified <see cref="RocksDBOptions"/> to use a JSON-based serializer.
 /// </summary>
-/// <remarks>This method sets the <see cref="RocksDBOptions.Serializer"/> property to a serializer that
-/// uses JSON serialization. Use the <paramref name="options"/> parameter to customize the behavior of the JSON
-/// serializer, such as formatting or type handling.</remarks>
+/// <remarks>
+/// This method sets the <see cref="RocksDBOptions.Serializer"/> property to a <see cref="ByteSerializer"/> 
+/// that uses JSON serialization with customizable options. If no options delegate is provided, 
+/// default JSON serialization settings are used.
+/// </remarks>
 /// <param name="rockDBOptions">The <see cref="RocksDBOptions"/> instance to configure.</param>
-/// <param name="options">An optional delegate to configure the <see cref="JsonSerializerOptions"/> used by the serializer. If not
-/// provided, default options are used.</param>
+/// <param name="options">An optional delegate to configure the <see cref="JsonSerializerOptions"/>. 
+/// If null, default JSON serialization options are used.</param>
 /// <returns>The configured <see cref="RocksDBOptions"/> instance.</returns>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a25e711 and 1afb1ce.

📒 Files selected for processing (7)
  • src/MinimalKafka.RocksDB/ByteSerializer.cs (1 hunks)
  • src/MinimalKafka.RocksDB/KafkaBuilderExtensions.cs (2 hunks)
  • src/MinimalKafka.RocksDB/RocksDBOptions.cs (1 hunks)
  • src/MinimalKafka.RocksDB/RocksDBStoreManager.cs (4 hunks)
  • src/MinimalKafka/KafkaProducerFactory.cs (2 hunks)
  • src/MinimalKafka/Stream/Storage/InMemoryStore.cs (1 hunks)
  • test/MinimalKafka.RocksDB.Tests/StreamStore_Tests.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze
🔇 Additional comments (9)
src/MinimalKafka.RocksDB/ByteSerializer.cs (2)

5-5: Clean implementation with primary constructor.

The use of primary constructor syntax for accepting JsonSerializerOptions is clean and modern. Good improvement for configurability.


12-12: Proper usage of injected serialization options.

The implementation correctly uses the provided JsonSerializerOptions in both serialization and deserialization methods, enabling customizable JSON behavior.

Also applies to: 20-20

test/MinimalKafka.RocksDB.Tests/StreamStore_Tests.cs (1)

20-23: Test updated to match new API pattern.

The test configuration correctly adapts to the new RocksDBOptions delegate pattern while maintaining the same test logic.

src/MinimalKafka.RocksDB/RocksDBOptions.cs (1)

21-21: Good default serializer configuration.

The default serializer initialization with JsonSerializerOptions.Default provides a sensible baseline that can be customized as needed.

src/MinimalKafka/KafkaProducerFactory.cs (3)

19-19: Good addition of metadata transparency.

Exposing the metadata through a public readonly property increases transparency and allows consumers to inspect the configuration metadata.


25-25: Clean separation of concerns.

Delegating configuration building to a separate method improves code organization and maintainability.


41-52: Well-structured configuration building method.

The BuildConfig() method properly encapsulates the configuration logic, handling both existing configurations and applying metadata-driven settings. The implementation is clear and follows good separation of concerns.

src/MinimalKafka.RocksDB/RocksDBStoreManager.cs (1)

24-24: LGTM: Configuration refactoring is well-implemented.

The changes correctly replace the hardcoded string path and serializer with configurable options from the RocksDBOptions object. This provides better flexibility and follows the dependency injection pattern.

Also applies to: 38-38, 65-65

src/MinimalKafka.RocksDB/KafkaBuilderExtensions.cs (1)

21-30: LGTM: Method refactoring improves configurability.

The refactoring from a simple string path to a configurable options delegate provides better flexibility and extensibility. The implementation correctly creates and configures the options object.

Patrick Evers added 2 commits June 25, 2025 12:41
Updates RocksDB integration to improve configuration and ensure proper initialization.

- Uses a new JsonSerializerOptions instance instead of the default one to allow for customized JSON serialization.
- Corrects default DataPath for RocksDB.
- Ensures RocksDBStreamStoreFactory is initialized correctly by validating the configuration and passing it consistently.
- Switches to ConcurrentBag for in-memory store to allow multiple threads to add stores.
Adds a lock to the `GetStreamStore` method to
prevent race conditions when creating and accessing
stores from multiple threads. This ensures that only
one store of a given type is created.
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