Skip to content

Add server-based logic for rppgrpc#612

Merged
victimsnino merged 23 commits into
v2from
update_grpc
Aug 11, 2024
Merged

Add server-based logic for rppgrpc#612
victimsnino merged 23 commits into
v2from
update_grpc

Conversation

@victimsnino
Copy link
Copy Markdown
Owner

@victimsnino victimsnino commented Jul 30, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced handling of asynchronous gRPC server functionalities with improved data encapsulation for writing operations.
    • Introduced new structures for managing concurrency in client and server components.
    • Added a simplified subscription method for observables, focusing on completion events.
  • Bug Fixes

    • Improved thread safety and data handling in bidirectional streaming operations.
  • Tests

    • Added a comprehensive suite of unit tests for asynchronous gRPC server capabilities, ensuring expected behaviors across various scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 30, 2024

Walkthrough

Walkthrough

This update enhances the rppgrpc library through a comprehensive refactoring of client and server reactor classes, improving clarity, maintainability, and thread safety. By introducing base_writer and base_reader, message management is centralized, simplifying control flow. New class declarations for server-side operations broaden the library's capabilities, while the streamlined subscription methods improve usability in reactive programming. Overall, these changes significantly elevate the framework's robustness and functionality.

Changes

Files Change Summary
src/extensions/rppgrpc/rppgrpc/client_reactor.hpp,
src/extensions/rppgrpc/rppgrpc/server_reactor.hpp
Refactored reactor classes to utilize default constructors, centralizing message handling in base_writer and base_reader, enhancing organization and thread safety.
src/extensions/rppgrpc/rppgrpc/fwd.hpp Added new class declarations for server_bidi_reactor, server_write_reactor, and server_read_reactor, enriching server-side gRPC functionality.
src/rpp/rpp/observables/observable.hpp,
src/rpp/rpp/operators/subscribe.hpp
Introduced new overloads of subscribe methods to streamline subscriptions to observable emissions, focusing on completion events.
src/examples/rppgrpc/doxygen/server_reactor.cpp Implemented a gRPC server leveraging reactive programming principles, defining methods for various gRPC communication patterns to facilitate asynchronous processing.
src/tests/CMakeLists.txt Simplified CMake configuration by linking tests to a dedicated proto target, enhancing clarity and maintainability.
src/tests/rppgrpc/test_async_server.cpp Introduced unit tests for asynchronous gRPC server functionality, focusing on bidirectional streaming and employing mocking to verify expected behaviors.
src/tests/rppgrpc/test_async_client.cpp Encapsulated the service class in an unnamed namespace for modularity, and removed the wait function to simplify expectations handling.
src/tests/utils/rpp_trompeloil.hpp Added a new inline wait function to allow execution pause until specified expectations are met, enhancing test functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant ClientReactor
    participant ServerReactor

    Client->>ClientReactor: Initiates bidirectional stream
    ClientReactor->>ServerReactor: Sends request
    ServerReactor->>Server: Process request
    Server->>ServerReactor: Returns response
    ServerReactor->>ClientReactor: Sends response
    ClientReactor->>Client: Delivers response
    Client->>ServerReactor: Closes stream
    ServerReactor->>Server: Finalizes connection
Loading

🐰 Hop along the code so bright,
Refactors bring a joyful light.
Streams now flow, no tangled thread,
With tests to cheer, we forge ahead!
A rabbit's dance in code's sweet flow,
Happy changes make our skills grow! 🥕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e46c0fd and fdd268e.

Files selected for processing (4)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (8 hunks)
  • src/extensions/rppgrpc/rppgrpc/rppgrpc.hpp (1 hunks)
  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (1 hunks)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Additional comments not posted (20)
src/extensions/rppgrpc/rppgrpc/rppgrpc.hpp (1)

15-15: Verify the impact of including server_reactor.hpp.

Uncommenting this inclusion makes the definitions and declarations in server_reactor.hpp accessible in this file. Ensure that this change does not introduce any conflicts or unexpected behaviors in the dependent modules.

Verification successful

Verification successful for the inclusion of server_reactor.hpp.

The inclusion of server_reactor.hpp in rppgrpc.hpp does not introduce any conflicts or unexpected behaviors in the codebase. The only usages of server_reactor components are in server.cpp, and there are no additional files that include rppgrpc.hpp.

  • No conflicts or dependencies related to server_reactor.hpp were found.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of including `server_reactor.hpp`.

# Test: Check for any compilation errors or warnings introduced by this change.
# Expect: No errors or warnings should be present.

# Compile the project and capture any errors or warnings.
# Note: This script assumes a Makefile or similar build system is present.
make 2>&1 | tee compile_output.txt

# Search for errors or warnings in the compile output.
grep -E "error|warning" compile_output.txt

Length of output: 199


Script:

#!/bin/bash
# Description: Verify the impact of including `server_reactor.hpp`.

# Search for the inclusion of `server_reactor.hpp` in the codebase.
rg '#include <rppgrpc/server_reactor.hpp>'

# Search for any usage of components from `server_reactor.hpp` in the codebase.
rg 'server_reactor'

# Check for any potential conflicts or dependencies related to `server_reactor.hpp`.
rg 'conflict|dependency' --glob '*.hpp' --glob '*.cpp'

Length of output: 681


Script:

#!/bin/bash
# Description: Verify the impact of including `server_reactor.hpp`.

# Search for files that include `rppgrpc.hpp`.
rg '#include <rppgrpc/rppgrpc/rppgrpc.hpp>'

# Search for any further usage of `server_reactor` components in the codebase.
rg 'server_reactor'

Length of output: 544

src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (5)

25-31: LGTM! The server_write_data structure improves thread safety and data management.

The encapsulation of the mutex and response queue enhances the organization and maintainability of the code.


33-66: LGTM! The server_write_observer_strategy structure effectively manages observer behavior and synchronization.

The use of the mutex and the methods for handling messages, errors, and completion are well-implemented.


79-82: LGTM! The constructor and subscription logic are clean and well-implemented.

The initialization of the reactor and the subscription to the observer strategy are correctly set up.


96-139: LGTM! The OnReadDone, OnWriteDone, OnDone, and OnCancel methods are well-implemented.

The methods correctly handle the respective operations and utilize the observer strategy effectively.


150-155: LGTM! The server_write_data and m_observer member variables are correctly initialized and used.

The member variables are well-integrated into the class and enhance the management of write operations and message observation.

src/tests/rppgrpc/test_async_server.cpp (7)

31-44: LGTM! The Async server test case setup is correct.

The gRPC server and mock service are properly initialized and registered.


47-72: LGTM! The writer immediate finish scenario is correctly tested.

The test case ensures that the writer completes immediately and the server handles the completion correctly.


74-79: LGTM! The writer cancels scenario is correctly tested.

The test case ensures that the writer cancels the operation and the server handles the cancellation correctly.


81-86: LGTM! The server cancels scenario is correctly tested.

The test case ensures that the server cancels the operation and the writer handles the cancellation correctly.


88-112: LGTM! The writer writes scenario is correctly tested.

The test case ensures that the writer sends multiple messages and the server handles the messages correctly.


114-138: LGTM! The writer reads scenario is correctly tested.

The test case ensures that the writer reads multiple messages and the server handles the messages correctly.


141-143: LGTM! The Async server teardown is correct.

The gRPC server is properly shut down and resources are released.

src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (7)

25-31: Encapsulation of write-related state is well-implemented.

The client_write_data struct encapsulates write-related state, improving code organization and thread safety.


33-66: Centralization of write operation logic is well-implemented.

The client_write_observer_strategy struct centralizes the logic for managing write operations, improving maintainability and synchronization.


86-90: Subscription to client_write_observer_strategy improves code organization.

The update to subscribe to client_write_observer_strategy in the client_bidi_reactor constructor centralizes write operation handling, improving code organization.


127-134: Update to use m_write_data improves consistency and thread safety.

The update to use m_write_data for managing write state in the OnWriteDone method improves code consistency and thread safety.


179-183: Subscription to client_write_observer_strategy improves code organization.

The update to subscribe to client_write_observer_strategy in the client_write_reactor constructor centralizes write operation handling, improving code organization.


209-216: Update to use m_write_data improves consistency and thread safety.

The update to use m_write_data for managing write state in the OnWriteDone method improves code consistency and thread safety.


161-161: Encapsulation of write-related state is well-implemented.

The addition of m_write_data to both client_bidi_reactor and client_write_reactor encapsulates write-related state, improving code organization and thread safety.

Also applies to: 241-241

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fdd268e and ce9bf15.

Files selected for processing (3)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (7 hunks)
  • src/extensions/rppgrpc/rppgrpc/details/base.hpp (1 hunks)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
  • src/tests/rppgrpc/test_async_server.cpp
Additional comments not posted (12)
src/extensions/rppgrpc/rppgrpc/details/base.hpp (12)

28-31: LGTM! Constructor initializes observable subscription correctly.

The constructor subscribes to an observable from m_subject using the observer_strategy. This ensures that the class is ready to handle incoming data.


33-33: LGTM! Destructor is correctly implemented.

The destructor is defaulted and marked noexcept, which is appropriate for this class.


35-37: LGTM! Method correctly provides access to the observer.

The get_observer method returns an observer from m_subject, which is necessary for the class's functionality.


41-41: LGTM! Pure virtual function ensures derived class implementation.

The start_write method is correctly declared as a pure virtual function, ensuring derived classes implement the required functionality.


42-42: LGTM! Pure virtual function ensures derived class implementation.

The finish_writes method is correctly declared as a pure virtual function, ensuring derived classes implement the required functionality.


44-47: LGTM! Method correctly handles completion of the observable sequence.

The handle_on_done method disposes of the subject's disposable, ensuring proper cleanup.


49-62: LGTM! Method correctly manages the write queue and handles completion of writes.

The handle_write_done method uses a lock guard to manage the write queue and calls start_write or finish_writes as needed, ensuring thread safety and proper handling of writes.


68-75: LGTM! Method correctly handles incoming messages and manages the write queue.

The on_next method uses a lock guard to manage the write queue and calls start_write if the queue was previously empty, ensuring thread safety and proper handling of incoming messages.


77-84: LGTM! Method correctly handles errors and manages the write queue.

The on_error method uses a lock guard to set the finished flag and calls finish_writes if the write queue is empty, ensuring thread safety and proper handling of errors.


85-92: LGTM! Method correctly handles completion of the observable sequence and manages the write queue.

The on_completed method uses a lock guard to set the finished flag and calls finish_writes if the write queue is empty, ensuring thread safety and proper handling of the completion of the observable sequence.


94-94: LGTM! Method correctly indicates that the observer is not disposed.

The is_disposed method returns false, which is appropriate for this observer strategy.


95-95: LGTM! Method correctly implemented as a no-op.

The set_upstream method is a no-op, which is appropriate for this observer strategy.

Copy link
Copy Markdown
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ce9bf15 and 3dbcdb8.

Files selected for processing (2)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (5 hunks)
  • src/extensions/rppgrpc/rppgrpc/details/base.hpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
Additional comments not posted (7)
src/extensions/rppgrpc/rppgrpc/details/base.hpp (7)

28-31: Ensure exception safety in the constructor.

The constructor subscribes to the observable. Ensure that any exceptions thrown during subscription are handled appropriately to prevent resource leaks.


44-47: Handle potential exceptions in handle_on_done.

Ensure that any exceptions thrown during dispose are handled to maintain stability.


49-62: Ensure thread safety and exception handling in handle_write_done.

The method uses a lock guard for thread safety, but ensure that any exceptions thrown during start_write or finish_writes are handled appropriately.


64-96: Review the observer_strategy struct for thread safety and exception handling.

The struct handles on_next, on_error, and on_completed events. Ensure that all operations within these methods are thread-safe and exceptions are properly managed.


110-111: Ensure exception safety in the constructor and destructor.

The default constructor and destructor should ensure that resources are properly managed and exceptions are handled.


121-126: Ensure thread safety and exception handling in handle_read_done.

The method calls on_next and start_read. Ensure that these operations are thread-safe and exceptions are properly managed.


128-134: Handle potential exceptions in handle_on_done.

Ensure that any exceptions thrown during on_error or on_completed are handled to maintain stability.

Copy link
Copy Markdown
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3dbcdb8 and 781427a.

Files selected for processing (3)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (5 hunks)
  • src/extensions/rppgrpc/rppgrpc/details/base.hpp (1 hunks)
  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
Additional comments not posted (17)
src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (11)

22-25: Template and inheritance structure update.

The class template parameters and inheritance structure have been updated to directly use Request and Response types. This change simplifies the template and enhances clarity.


40-43: Override start_write method.

The start_write method is overridden to start writing the response. Ensure that this method is correctly utilized and does not introduce any issues.


45-48: Override start_read method.

The start_read method is overridden to start reading the request. Ensure that this method is correctly utilized and does not introduce any issues.


50-53: Override finish_writes method.

The finish_writes method is overridden to finish writing with the given status. Ensure that this method is correctly utilized and does not introduce any issues.


54-60: Update OnReadDone method.

The OnReadDone method is updated to handle the read completion using the base reader class method. Ensure that this update is correct and does not introduce any issues.


62-68: Update OnWriteDone method.

The OnWriteDone method is updated to handle the write completion using the base writer class method. Ensure that this update is correct and does not introduce any issues.


73-76: Update OnDone method.

The OnDone method is updated to handle the completion using the base writer and reader class methods. Ensure that this update is correct and does not introduce any issues.


81-84: Update OnCancel method.

The OnCancel method is updated to handle the cancellation using the base writer and reader class methods. Ensure that this update is correct and does not introduce any issues.


16-16: Ensure correct inclusion of headers.

The new header rppgrpc/details/base.hpp is included. Ensure that this header is necessary and correctly referenced.

Verification successful

The inclusion of rppgrpc/details/base.hpp is correct and necessary.

The base_writer and base_reader classes defined in this header are used in server_reactor.hpp.

  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity and correct reference of the new header.

# Test: Check for references to `base_writer` and `base_reader` in the codebase. Expect: References to these classes.
rg --type cpp 'base_writer|base_reader'

Length of output: 4721


30-33: Constructor update.

The constructor now initializes the base class and starts sending initial metadata without the previous observer subscription logic. Ensure that the new initialization logic is correct and does not introduce any issues.

Verification successful

Constructor update verified.

The new initialization logic in the server_bidi_reactor constructor is correctly tested in test_async_server.cpp. The test ensures that the observable subscription and bidirectional call functionalities are intact, indicating that the new logic does not introduce any issues.

  • src/tests/rppgrpc/test_async_server.cpp:
    • Validates the initialization and usage of server_bidi_reactor.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new initialization logic in the constructor.

# Test: Check for references to `server_bidi_reactor` initialization. Expect: Correct usage of the new constructor.
rg --type cpp 'server_bidi_reactor'

Length of output: 386


Script:

#!/bin/bash
# Description: Check the context around the constructor reference in test_async_server.cpp to understand how the new initialization logic is being tested.

# Retrieve 10 lines before and after the reference to the constructor in the test file.
rg --type cpp 'server_bidi_reactor' -A 10 -B 10 src/tests/rppgrpc/test_async_server.cpp

Length of output: 1025


36-37: Expose base class methods.

The methods get_observer and get_observable from the base classes are now exposed. Ensure that these methods are correctly utilized in the codebase.

Verification successful

The methods get_observer and get_observable are correctly utilized in the codebase. The implementations and their usage align with their intended functionality in reactive programming.

  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
  • src/rpp/rpp/subjects/replay_subject.hpp
  • src/rpp/rpp/subjects/publish_subject.hpp
  • src/rpp/rpp/subjects/behavior_subject.hpp
  • src/rpp/rpp/observers/mock_observer.hpp
  • src/rpp/rpp/operators/details/forwarding_subject.hpp
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct utilization of the exposed methods `get_observer` and `get_observable`.

# Test: Check for references to `get_observer` and `get_observable` methods. Expect: Correct usage of these methods.
rg --type cpp 'get_observer|get_observable'

Length of output: 41162


Script:

#!/bin/bash
# Description: Verify the correct utilization of the exposed methods `get_observer` and `get_observable`.

# Find the implementation of `get_observer` and `get_observable` in the relevant files.
ast-grep --lang cpp --pattern 'auto get_observer() const { $$$ }' 
ast-grep --lang cpp --pattern 'auto get_observable() const { $$$ }'

Length of output: 137


Script:

#!/bin/bash
# Description: Verify the correct utilization of the exposed methods `get_observer` and `get_observable`.

# Find the implementation of `get_observer` and `get_observable` in the relevant files.
rg --type cpp 'auto get_observer' -A 5
rg --type cpp 'auto get_observable' -A 5

Length of output: 6848

src/extensions/rppgrpc/rppgrpc/details/base.hpp (6)

30-33: Initialize observer subscription.

The constructor initializes the observer subscription. Ensure that this initialization is correct and does not introduce any issues.


46-49: Dispose of the observer.

The handle_on_done method disposes of the observer. Ensure that this disposal is correct and does not introduce any issues.


51-64: Handle write completion.

The handle_write_done method manages the deque for write operations and handles write completion. Ensure that this method is correctly implemented and does not introduce any issues.


66-98: Observer strategy for write operations.

The observer_strategy struct manages the write operations using the observer pattern. Ensure that this strategy is correctly implemented and does not introduce any issues.


123-128: Handle read completion.

The handle_read_done method manages the read operations and handles read completion. Ensure that this method is correctly implemented and does not introduce any issues.


130-136: Handle completion.

The handle_on_done method manages the completion of read operations. Ensure that this method is correctly implemented and does not introduce any issues.

Comment thread src/extensions/rppgrpc/rppgrpc/details/base.hpp
Comment thread src/extensions/rppgrpc/rppgrpc/details/base.hpp
Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 781427a and c6ee2b7.

Files selected for processing (1)
  • src/tests/CMakeLists.txt (2 hunks)
Additional comments not posted (2)
src/tests/CMakeLists.txt (2)

28-28: LGTM! Simplifies linking process.

The change to link the test target to rppgrpc_tests_proto improves clarity and maintainability by eliminating the need for a dynamically named proto target.


59-59: LGTM! Conditional proto target creation.

The change to create the rppgrpc_tests_proto target within the RPP_BUILD_GRPC_CODE conditional block ensures that the proto target is only created when necessary, improving build efficiency.

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c6ee2b7 and 074fbf2.

Files selected for processing (2)
  • src/rpp/rpp/operators/publish.hpp (1 hunks)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/tests/rppgrpc/test_async_server.cpp
Additional comments not posted (1)
src/rpp/rpp/operators/publish.hpp (1)

4-4: LGTM! Verify the presence of publish_subject.hpp.

The inclusion of publish_subject.hpp appears to be correct and necessary for the functionality of the publish function.

Ensure that the publish_subject.hpp file exists and is correctly implemented.

Verification successful

Verified!

The inclusion of publish_subject.hpp in publish.hpp is correct and necessary for the functionality of the publish function. The publish_subject.hpp file is present and correctly implemented.

  • The file src/rpp/rpp/subjects/publish_subject.hpp contains the necessary implementations for publish_subject and serialized_publish_subject.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of `publish_subject.hpp`.

# Test: Search for the `publish_subject.hpp` file. Expect: File should be present.
fd publish_subject.hpp

Length of output: 65


Script:

#!/bin/bash
# Description: Inspect the contents of `publish_subject.hpp` to ensure it is correctly implemented.

# Display the contents of the `publish_subject.hpp` file.
cat src/rpp/rpp/subjects/publish_subject.hpp

Length of output: 4072

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 074fbf2 and cf4c640.

Files selected for processing (2)
  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (1 hunks)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/tests/rppgrpc/test_async_server.cpp
Additional comments not posted (20)
src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (20)

30-33: Constructor initialization is correct.

The constructor initializes the base class and starts sending initial metadata. It also handles the initial read done event correctly.


40-43: Method start_write is correctly implemented.

The method correctly starts a write operation using the base class.


45-48: Method start_read is correctly implemented.

The method correctly starts a read operation using the base class.


50-53: Method finish_writes is correctly implemented.

The method correctly finishes the write operation using the base class.


54-60: Method OnReadDone handles read completion correctly.

The method checks if the read operation was successful and handles the read done event using the base reader class.


62-69: Method OnWriteDone handles write completion correctly.

The method checks if the write operation was successful and handles the write done event using the base writer class.


71-77: Method OnDone handles the completion of the reactor correctly.

The method handles the on done event using the base writer and reader classes and deletes the reactor instance.


79-85: Method OnCancel handles the cancellation of the reactor correctly.

The method handles the on cancel event using the base writer and reader classes and finishes the reactor with a cancelled status.


96-99: Constructor initialization is correct.

The constructor initializes the base class and starts sending initial metadata.


105-108: Method start_write is correctly implemented.

The method correctly starts a write operation using the base class.


110-110: Method start_read is a no-op as expected.

The method does nothing, which is expected for a write reactor.


112-115: Method finish_writes is correctly implemented.

The method correctly finishes the write operation using the base class.


117-125: Method OnWriteDone handles write completion correctly.

The method checks if the write operation was successful and handles the write done event using the base writer class.


127-133: Method OnDone handles the completion of the reactor correctly.

The method handles the on done event using the base writer and reader classes and deletes the reactor instance.


135-140: Method OnCancel handles the cancellation of the reactor correctly.

The method handles the on cancel event using the base writer and reader classes and finishes the reactor with a cancelled status.


152-155: Constructor initialization is correct.

The constructor initializes the base class, starts sending initial metadata, and handles the initial read done event correctly.


161-164: Method start_read is correctly implemented.

The method correctly starts a read operation using the base class.


166-175: Method OnReadDone handles read completion correctly.

The method checks if the read operation was successful and handles the read done event using the base reader class.


177-182: Method OnDone handles the completion of the reactor correctly.

The method handles the on done event using the base reader class and deletes the reactor instance.


184-187: Method OnCancel handles the cancellation of the reactor correctly.

The method handles the on cancel event using the base reader class.

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cf4c640 and 1e32271.

Files selected for processing (1)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/tests/rppgrpc/test_async_server.cpp

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1e32271 and 6de781b.

Files selected for processing (1)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/tests/rppgrpc/test_async_server.cpp

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 4, 2024

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-gcc

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 303.25 ns 2.16 ns 2.16 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 305.85 ns 2.16 ns 2.16 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 697.11 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 1030.41 ns 3.42 ns 3.42 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2257.82 ns 113.74 ns 125.92 ns 0.90
defer from array of 1 - defer + create + subscribe + immediate 735.11 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2172.68 ns 59.19 ns 59.19 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3030.62 ns 32.42 ns 32.40 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 27237.36 ns 26905.10 ns 28119.03 ns 0.96
from array of 1000 - create + as_blocking + subscribe + new_thread 40422.48 ns 50907.80 ns 52336.14 ns 0.97
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3570.07 ns 139.77 ns 143.34 ns 0.98

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1084.59 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 833.56 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1050.99 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 917.50 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1238.16 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 928.20 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1121.02 ns 17.90 ns 17.90 ns 1.00
immediate_just(1,2,3)+element_at(1)+subscribe 854.62 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 273.59 ns 2.16 ns 2.16 ns 1.00
current_thread scheduler create worker + schedule 373.87 ns 5.56 ns 5.56 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 846.43 ns 56.40 ns 56.46 ns 1.00

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 854.07 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 930.68 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2436.56 ns 177.66 ns 151.76 ns 1.17
immediate_just+buffer(2)+subscribe 1535.71 ns 13.59 ns 24.35 ns 0.56
immediate_just+window(2)+subscribe + subscsribe inner 2456.58 ns 1086.03 ns 1065.26 ns 1.02

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 832.02 ns - - 0.00
immediate_just+take_while(true)+subscribe 912.29 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1977.74 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3429.62 ns 189.56 ns 174.92 ns 1.08
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3622.70 ns 179.17 ns 171.34 ns 1.05
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 145.14 ns 124.22 ns 1.17
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3599.99 ns 946.39 ns 909.13 ns 1.04
immediate_just(1) + zip(immediate_just(2)) + subscribe 2122.66 ns 214.15 ns 212.07 ns 1.01

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 34.57 ns 14.73 ns 14.72 ns 1.00
subscribe 100 observers to publish_subject 199929.00 ns 15258.01 ns 14914.44 ns 1.02
100 on_next to 100 observers to publish_subject 32627.34 ns 17114.41 ns 18816.75 ns 0.91

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1451.84 ns 12.66 ns 12.66 ns 1.00
basic sample with immediate scheduler 1394.79 ns 5.55 ns 5.55 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 919.05 ns 0.31 ns 0.31 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2090.52 ns 969.20 ns 975.50 ns 0.99

ci-macos

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 984.55 ns 3.93 ns 3.90 ns 1.01
Subscribe empty callbacks to empty observable via pipe operator 981.95 ns 3.95 ns 3.90 ns 1.01

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1921.08 ns 0.23 ns 0.23 ns 1.00
from array of 1 - create + subscribe + current_thread 2441.40 ns 34.49 ns 34.45 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 5395.24 ns 330.55 ns 333.32 ns 0.99
defer from array of 1 - defer + create + subscribe + immediate 1971.42 ns 0.23 ns 0.23 ns 1.00
interval - interval + take(3) + subscribe + immediate 4921.37 ns 113.78 ns 114.83 ns 0.99
interval - interval + take(3) + subscribe + current_thread 6036.20 ns 96.00 ns 94.64 ns 1.01
from array of 1 - create + as_blocking + subscribe + new_thread 90247.20 ns 79537.00 ns 79948.33 ns 0.99
from array of 1000 - create + as_blocking + subscribe + new_thread 96641.10 ns 88251.92 ns 84225.07 ns 1.05
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 7935.51 ns 392.71 ns 378.42 ns 1.04

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 2871.41 ns 0.23 ns 0.23 ns 1.00
immediate_just+filter(true)+subscribe 2102.19 ns 0.23 ns 0.23 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 2742.58 ns 0.23 ns 0.23 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 2069.28 ns 0.47 ns 0.47 ns 1.00
immediate_just(1,2)+first()+subscribe 3184.45 ns 0.23 ns 0.23 ns 1.00
immediate_just(1,2)+last()+subscribe 2382.16 ns 0.23 ns 0.23 ns 1.00
immediate_just+take_last(1)+subscribe 3020.56 ns 70.87 ns 70.22 ns 1.01
immediate_just(1,2,3)+element_at(1)+subscribe 2115.96 ns 0.23 ns 0.23 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 857.36 ns 4.14 ns 4.16 ns 1.00
current_thread scheduler create worker + schedule 1187.22 ns 39.92 ns 39.85 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 1993.41 ns 208.59 ns 203.80 ns 1.02

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 2128.36 ns 4.20 ns 4.20 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 2386.02 ns 0.48 ns 0.47 ns 1.02
immediate_just+flat_map(immediate_just(v*2))+subscribe 5403.57 ns 418.67 ns 401.56 ns 1.04
immediate_just+buffer(2)+subscribe 2491.44 ns 70.35 ns 69.84 ns 1.01
immediate_just+window(2)+subscribe + subscsribe inner 5289.83 ns 2398.45 ns 2372.94 ns 1.01

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 2098.69 ns - - 0.00
immediate_just+take_while(true)+subscribe 2110.55 ns 0.23 ns 0.23 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 4863.65 ns 4.90 ns 5.13 ns 0.95

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 7456.34 ns 440.05 ns 440.31 ns 1.00
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 8421.06 ns 475.67 ns 440.38 ns 1.08
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 460.39 ns 458.54 ns 1.00
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 7979.12 ns 1910.87 ns 1907.85 ns 1.00
immediate_just(1) + zip(immediate_just(2)) + subscribe 5145.81 ns 840.48 ns 839.44 ns 1.00

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 73.92 ns 50.07 ns 49.28 ns 1.02
subscribe 100 observers to publish_subject 346700.00 ns 40742.84 ns 40719.71 ns 1.00
100 on_next to 100 observers to publish_subject 48780.65 ns 17063.46 ns 17216.52 ns 0.99

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 2765.50 ns 64.87 ns 65.05 ns 1.00
basic sample with immediate scheduler 2759.23 ns 21.97 ns 19.29 ns 1.14

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 2386.96 ns 0.23 ns 0.23 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 6802.32 ns 4119.52 ns 4075.34 ns 1.01

ci-ubuntu-clang

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 278.45 ns 1.59 ns 1.58 ns 1.01
Subscribe empty callbacks to empty observable via pipe operator 270.22 ns 1.59 ns 1.56 ns 1.02

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 560.26 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 784.30 ns 4.01 ns 4.01 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2354.91 ns 134.75 ns 134.67 ns 1.00
defer from array of 1 - defer + create + subscribe + immediate 775.76 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2202.41 ns 58.27 ns 58.27 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3213.23 ns 30.86 ns 30.88 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 30304.86 ns 28067.39 ns 28828.75 ns 0.97
from array of 1000 - create + as_blocking + subscribe + new_thread 36838.43 ns 36504.00 ns 38425.07 ns 0.95
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3682.67 ns 157.35 ns 157.38 ns 1.00

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1139.20 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 845.91 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1083.51 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 862.42 ns 0.62 ns 0.62 ns 1.00
immediate_just(1,2)+first()+subscribe 1377.33 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 1008.53 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1185.61 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2,3)+element_at(1)+subscribe 858.56 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 276.72 ns 1.54 ns 1.56 ns 0.99
current_thread scheduler create worker + schedule 385.32 ns 4.49 ns 4.02 ns 1.12
current_thread scheduler create worker + schedule + recursive schedule 841.82 ns 55.85 ns 55.59 ns 1.00

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 854.56 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 993.44 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2243.42 ns 136.33 ns 136.38 ns 1.00
immediate_just+buffer(2)+subscribe 1504.22 ns 13.98 ns 13.58 ns 1.03
immediate_just+window(2)+subscribe + subscsribe inner 2418.30 ns 915.82 ns 933.05 ns 0.98

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 829.61 ns - - 0.00
immediate_just+take_while(true)+subscribe 840.58 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1983.25 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3253.32 ns 157.64 ns 158.43 ns 1.00
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3684.50 ns 150.76 ns 145.78 ns 1.03
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 144.24 ns 142.33 ns 1.01
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3405.12 ns 841.59 ns 842.95 ns 1.00
immediate_just(1) + zip(immediate_just(2)) + subscribe 2173.60 ns 201.70 ns 198.37 ns 1.02

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 54.74 ns 20.56 ns 17.69 ns 1.16
subscribe 100 observers to publish_subject 209769.40 ns 16057.73 ns 16022.19 ns 1.00
100 on_next to 100 observers to publish_subject 35675.27 ns 17907.27 ns 20623.71 ns 0.87

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1324.47 ns 11.11 ns 11.11 ns 1.00
basic sample with immediate scheduler 1281.19 ns 5.86 ns 5.86 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 990.26 ns 0.31 ns 0.31 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2152.41 ns 1231.02 ns 1224.81 ns 1.01

ci-windows

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 562.79 ns 4.94 ns 4.05 ns 1.22
Subscribe empty callbacks to empty observable via pipe operator 578.25 ns 4.94 ns 4.01 ns 1.23

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1155.68 ns 5.55 ns 5.63 ns 0.99
from array of 1 - create + subscribe + current_thread 1425.11 ns 15.75 ns 15.74 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 3733.45 ns 172.47 ns 174.77 ns 0.99
defer from array of 1 - defer + create + subscribe + immediate 1196.58 ns 5.24 ns 5.24 ns 1.00
interval - interval + take(3) + subscribe + immediate 3234.70 ns 133.32 ns 133.46 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3414.33 ns 52.11 ns 52.75 ns 0.99
from array of 1 - create + as_blocking + subscribe + new_thread 117910.00 ns 111300.00 ns 115255.56 ns 0.97
from array of 1000 - create + as_blocking + subscribe + new_thread 134537.50 ns 134377.78 ns 132122.22 ns 1.02
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 5326.37 ns 209.14 ns 210.39 ns 0.99

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1804.38 ns 12.87 ns 12.88 ns 1.00
immediate_just+filter(true)+subscribe 1311.79 ns 12.38 ns 11.68 ns 1.06
immediate_just(1,2)+skip(1)+subscribe 1702.92 ns 13.37 ns 13.38 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1616.51 ns 15.95 ns 15.82 ns 1.01
immediate_just(1,2)+first()+subscribe 2035.56 ns 12.95 ns 12.64 ns 1.02
immediate_just(1,2)+last()+subscribe 1773.61 ns 13.80 ns 14.08 ns 0.98
immediate_just+take_last(1)+subscribe 2000.69 ns 59.31 ns 59.81 ns 0.99
immediate_just(1,2,3)+element_at(1)+subscribe 1319.45 ns 13.79 ns 13.78 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 476.29 ns 6.18 ns 6.17 ns 1.00
current_thread scheduler create worker + schedule 649.15 ns 13.73 ns 13.68 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 1356.18 ns 106.07 ns 104.92 ns 1.01

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 1315.71 ns 12.33 ns 11.33 ns 1.09
immediate_just+scan(10, std::plus)+subscribe 1413.71 ns 21.59 ns 21.29 ns 1.01
immediate_just+flat_map(immediate_just(v*2))+subscribe 3445.45 ns 202.18 ns 202.69 ns 1.00
immediate_just+buffer(2)+subscribe 2619.69 ns 59.74 ns 59.72 ns 1.00
immediate_just+window(2)+subscribe + subscsribe inner 3978.29 ns 1310.17 ns 1309.73 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 1620.31 ns 11.46 ns 11.46 ns 1.00
immediate_just+take_while(true)+subscribe 1309.73 ns 12.40 ns 11.74 ns 1.06

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 3116.76 ns 7.71 ns 7.71 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5097.54 ns 225.24 ns 226.63 ns 0.99
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 5431.38 ns 209.18 ns 209.81 ns 1.00
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 198.51 ns 198.15 ns 1.00
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 5363.85 ns 969.01 ns 949.54 ns 1.02
immediate_just(1) + zip(immediate_just(2)) + subscribe 3535.74 ns 523.08 ns 518.78 ns 1.01

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 36.50 ns 20.36 ns 20.36 ns 1.00
subscribe 100 observers to publish_subject 264075.00 ns 26902.56 ns 29132.43 ns 0.92
100 on_next to 100 observers to publish_subject 51595.65 ns 32708.57 ns 33103.33 ns 0.99

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1850.88 ns 57.04 ns 56.55 ns 1.01
basic sample with immediate scheduler 1860.51 ns 36.75 ns 36.75 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 1451.99 ns 19.99 ns 20.00 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2158.12 ns 342.30 ns 343.06 ns 1.00

Copy link
Copy Markdown
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6de781b and 0fada07.

Files selected for processing (3)
  • src/tests/rppgrpc/test_async_client.cpp (1 hunks)
  • src/tests/rppgrpc/test_async_server.cpp (1 hunks)
  • src/tests/utils/rpp_trompeloil.hpp (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/tests/rppgrpc/test_async_server.cpp
Additional comments not posted (3)
src/tests/utils/rpp_trompeloil.hpp (1)

11-11: Inclusion of <thread> header is appropriate.

The inclusion of <thread> is necessary for using std::this_thread::sleep_for in the wait function.

src/tests/rppgrpc/test_async_client.cpp (2)

18-26: Encapsulation of service class within an unnamed namespace is appropriate.

This change limits the visibility of the service class to the current translation unit, avoiding name clashes and improving modularity.


Line range hint 73-79: Verify the new mechanism for handling expectations in tests.

The removal of the wait function suggests a shift in the testing strategy. Ensure that the new mechanism for handling expectations is properly integrated and tested.

Comment thread src/tests/utils/rpp_trompeloil.hpp
Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0fada07 and aa44888.

Files selected for processing (2)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (2 hunks)
  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
Additional comments not posted (9)
src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (9)

81-87: Verify deletion logic in OnDone.

The reactor deletes itself in OnDone. Ensure that this is safe and that no further operations are attempted on the reactor after deletion.


89-95: Verify deletion logic in OnCancel.

The reactor deletes itself in OnCancel. Ensure that this is safe and that no further operations are attempted on the reactor after deletion.


40-43: Ensure proper initialization and metadata handling.

The constructor initializes the base class and starts sending initial metadata. Ensure that this is the desired behavior and that metadata is correctly handled in all scenarios.

Verification successful

Initialization and metadata handling in server_bidi_reactor are correctly implemented and tested.

The constructor of server_bidi_reactor initializes the base class and handles metadata as expected. Its usage in src/tests/rppgrpc/test_async_server.cpp indicates that this behavior is tested, ensuring reliability. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization and metadata handling in `server_bidi_reactor`.

# Test: Search for the constructor usage. Expect: Proper initialization and metadata handling.
rg --type cpp -A 5 $'server_bidi_reactor::server_bidi_reactor'

Length of output: 61


Script:

#!/bin/bash
# Description: Search for the `server_bidi_reactor` class definition and any inline constructor definitions or usages.

# Find the definition of the `server_bidi_reactor` class.
rg --type cpp -A 10 'class server_bidi_reactor'

# Search for any instantiations or inline definitions of `server_bidi_reactor`.
rg --type cpp 'server_bidi_reactor<'

Length of output: 1184


209-212: Verify handling of OnCancel.

The method handles cancellation by signaling an error. Ensure that this is the intended behavior and that it aligns with the overall logic.

Verification successful

Handling of OnCancel is intentional and consistent.

The OnCancel method in server_read_reactor.hpp consistently signals an error by invoking handle_on_done with an exception. This behavior aligns with the intended design of the class, which is marked as final, ensuring no further overrides. The handling of cancellation appears deliberate and consistent across the class.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of cancellation in `OnCancel`.

# Test: Search for the `OnCancel` method usage. Expect: Proper handling of cancellation.
rg --type cpp -A 5 $'server_read_reactor::OnCancel'

Length of output: 50


Script:

#!/bin/bash
# Description: Search for the `OnCancel` method definition and usage within the codebase.

# Find the definition of the `OnCancel` method in the codebase.
rg --type cpp -A 10 'void OnCancel() override'

# Search for any class definitions related to `server_read_reactor`.
rg --type cpp 'class server_read_reactor'

# Search for any derived classes that might override `OnCancel`.
rg --type cpp 'OnCancel' -A 5

Length of output: 2303


191-196: Ensure proper handling of read completion in OnReadDone.

The method finishes with grpc::Status::OK if the read is not successful. Verify that this is the intended behavior and that it aligns with the overall logic.

Verification successful

Proper handling of read completion in OnReadDone is confirmed.

The server_read_reactor class uses gRPC's lifecycle management. The OnReadDone method's logic to finish with grpc::Status::OK when ok is false aligns with a graceful handling of read failures. This behavior is consistent with the class's design and integration with gRPC. No further changes are necessary.

  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp: Definition and lifecycle management of server_read_reactor.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of read completion in `OnReadDone`.

# Test: Search for the `OnReadDone` method usage. Expect: Proper handling of read completion.
rg --type cpp -A 5 $'server_read_reactor::OnReadDone'

Length of output: 52


Script:

#!/bin/bash
# Search for the definition and methods of the `server_read_reactor` class to understand its lifecycle and integration.
ast-grep --lang cpp --pattern $'class server_read_reactor : public grpc::ServerReadReactor<$_> {
  $$$
}'

Length of output: 106


Script:

#!/bin/bash
# Search for the `server_read_reactor` class across the codebase to locate its definition and related comments.
rg --type cpp -A 10 'server_read_reactor'

Length of output: 2421


202-206: Verify deletion logic in OnDone.

The reactor deletes itself in OnDone. Ensure that this is safe and that no further operations are attempted on the reactor after deletion.


148-151: Verify deletion logic in OnDone.

The reactor deletes itself in OnDone. Ensure that this is safe and that no further operations are attempted on the reactor after deletion.


153-158: Verify deletion logic in OnCancel.

The reactor deletes itself in OnCancel. Ensure that this is safe and that no further operations are attempted on the reactor after deletion.


135-140: Ensure proper handling of write completion in OnWriteDone.

The method finishes with grpc::Status::OK if the write is not successful. Verify that this is the intended behavior and that it aligns with the overall logic.

Verification successful

Write Completion Handling in OnWriteDone is Consistent

The OnWriteDone method's behavior of finishing with grpc::Status::OK when a write is unsuccessful aligns with the class's overall strategy for handling operations. This approach is consistent with other methods like OnReadDone and OnCancel, ensuring a stable state by gracefully handling errors. No changes are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of write completion in `OnWriteDone`.

# Test: Search for the `OnWriteDone` method usage. Expect: Proper handling of write completion.
rg --type cpp -A 5 $'server_write_reactor::OnWriteDone'

Length of output: 54


Script:

#!/bin/bash
# Search for the definition and methods of the `server_write_reactor` class to gather more context.
ast-grep --lang cpp --pattern $'class server_write_reactor : public grpc::ServerWriteReactor<$_> {
  $$$
}'

Length of output: 108


Script:

#!/bin/bash
# Broaden the search to locate the `server_write_reactor` class and its methods.
rg --type cpp -A 10 'class server_write_reactor'

Length of output: 960


Script:

#!/bin/bash
# Search for all methods within the `server_write_reactor` class to understand its complete logic.
rg --type cpp -A 10 'server_write_reactor::'

Length of output: 44


Script:

#!/bin/bash
# Directly search for method definitions in the server_reactor.hpp file to understand the server_write_reactor class.
rg --type cpp -A 10 'void' src/extensions/rppgrpc/rppgrpc/server_reactor.hpp

Length of output: 3215

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aa44888 and 6c7dd4c.

Files selected for processing (6)
  • src/examples/rppgrpc/doxygen/server_reactor.cpp (1 hunks)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp (2 hunks)
  • src/extensions/rppgrpc/rppgrpc/fwd.hpp (1 hunks)
  • src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (1 hunks)
  • src/rpp/rpp/observables/observable.hpp (1 hunks)
  • src/rpp/rpp/operators/subscribe.hpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/extensions/rppgrpc/rppgrpc/client_reactor.hpp
Additional comments not posted (11)
src/extensions/rppgrpc/rppgrpc/fwd.hpp (3)

31-32: New Class Declaration: server_bidi_reactor.

The server_bidi_reactor class is introduced with template parameters Request and Response. Ensure that these types adhere to the rpp::constraint::decayed_type constraint for proper type handling.


34-35: New Class Declaration: server_write_reactor.

The server_write_reactor class is introduced with a template parameter Request. Ensure that this type adheres to the rpp::constraint::decayed_type constraint for proper type handling.


37-38: New Class Declaration: server_read_reactor.

The server_read_reactor class is introduced with a template parameter Response. Ensure that this type adheres to the rpp::constraint::decayed_type constraint for proper type handling.

src/examples/rppgrpc/doxygen/server_reactor.cpp (3)

15-22: Example Implementation: ClientSide using server_read_reactor.

The ClientSide method correctly demonstrates the use of server_read_reactor. Ensure that the observable's subscription handles all necessary events and errors.


24-34: Example Implementation: Bidirectional using server_bidi_reactor.

The Bidirectional method demonstrates the use of server_bidi_reactor. Ensure that both observable and observer are used correctly to manage the bidirectional stream.


36-46: Example Implementation: ServerSide using server_write_reactor.

The ServerSide method demonstrates the use of server_write_reactor. Ensure that the observable's subscription is correctly set up to handle completion and errors.

src/extensions/rppgrpc/rppgrpc/server_reactor.hpp (3)

35-99: Implementation Review: server_bidi_reactor.

The server_bidi_reactor class is well-structured, utilizing base classes for handling read and write operations. Ensure that the error handling in OnReadDone, OnWriteDone, OnDone, and OnCancel is robust and that resources are properly managed with delete this.


112-167: Implementation Review: server_write_reactor.

The server_write_reactor class correctly implements the write-only server reactor pattern. Verify that the handling of OnWriteDone and OnCancel ensures proper completion and error signaling.


179-221: Implementation Review: server_read_reactor.

The server_read_reactor class implements the read-only server reactor pattern. Ensure that the OnReadDone and OnCancel methods handle stream completion and errors appropriately.

src/rpp/rpp/operators/subscribe.hpp (1)

327-331: Ensure the correctness of the new subscribe function.

The new subscribe function provides a streamlined way to handle only the completion of an observable. It uses default empty functions for OnNext and a rethrow error handler for OnError, which is appropriate for the intended use case. Ensure that this function is covered by tests to verify its behavior in different scenarios.

src/rpp/rpp/observables/observable.hpp (1)

208-212: Verify the functionality of the new subscribe overload.

The new overload for the subscribe method allows handling only the completion event. It uses default empty functions for OnNext and a rethrow error handler for OnError, which aligns with the intended use case. Ensure that this behavior is tested to confirm its functionality.

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c7dd4c and b091fa6.

Files selected for processing (1)
  • src/rpp/rpp/operators/subscribe.hpp (2 hunks)
Additional comments not posted (2)
src/rpp/rpp/operators/subscribe.hpp (2)

212-212: Improved type-checking in on_next_like concept.

The addition of the !rpp::constraint::on_completed<OnNext> constraint refines the type-checking capabilities, ensuring that only appropriate types are used with the subscription mechanism.


327-331: New subscribe overload enhances usability.

The new overload accepting only an OnCompleted parameter simplifies the subscription process when only completion handling is required.

Ensure that this new overload is used correctly in the codebase.

Copy link
Copy Markdown
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b091fa6 and c16c66a.

Files selected for processing (1)
  • src/examples/rppgrpc/doxygen/server_reactor.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/examples/rppgrpc/doxygen/server_reactor.cpp

@sonarqubecloud
Copy link
Copy Markdown

@victimsnino victimsnino marked this pull request as ready for review August 11, 2024 20:08
@victimsnino victimsnino merged commit b8b0ed5 into v2 Aug 11, 2024
@victimsnino victimsnino deleted the update_grpc branch August 11, 2024 20:08
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.

1 participant