Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add headers specification in CMakeLists.txt and remove spdlog in public headers #46

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

sitaowang1998
Copy link
Collaborator

@sitaowang1998 sitaowang1998 commented Jan 7, 2025

Description

As title. Move more functions from FunctionManager.hpp to FunctionManager.cpp to remove dependencies on spdlog.

Validation performed

  • GitHub workflows pass
  • Unit tests pass
  • Integration tests pass

Summary by CodeRabbit

Release Notes

  • Build System

    • Updated CMake configuration to use FILE_SET for managing header files in spider_core and spider_client libraries.
    • Improved header file organization and build system handling.
  • New Features

    • Added response_get_result_buffers function to process message pack buffers with error handling.
  • Code Improvements

    • Refactored include paths in test files to use absolute paths.
    • Removed inline implementation of response_get_result_buffers function.

These changes enhance the project's build process and code structure while maintaining existing functionality.

Copy link

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces changes to the build system configuration and source code in the Spider project. The modifications primarily focus on updating the CMake configuration for header file management, adding a new function for processing message pack buffers, and standardizing header file include paths. The changes enhance the organization of header files, improve error handling in the new function, and streamline the way header files are referenced across multiple files in the project.

Changes

File Change Summary
src/spider/CMakeLists.txt Replaced target_sources with FILE_SET for spider_core and spider_client libraries, utilizing new CMake feature for header management.
src/spider/worker/FunctionManager.cpp Added response_get_result_buffers function with error handling for msgpack buffer processing.
src/spider/worker/FunctionManager.hpp Removed spdlog include, changed response_get_result_buffers from inline function definition to declaration.
tests/worker/worker-test.cpp Updated header include paths from relative to absolute.
tests/worker/worker-test.hpp Updated header include paths from relative to absolute.

Possibly Related PRs


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>, please review it.
    • 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 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 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 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. (Beta)
  • @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

@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

🧹 Nitpick comments (1)
src/spider/worker/FunctionManager.cpp (1)

64-100: Consider pre-allocating result_buffers vector.

The implementation is well-structured with proper error handling and logging. However, we could optimize memory allocations by pre-allocating the result_buffers vector since we know its size from object.via.array.size.

-        std::vector<msgpack::sbuffer> result_buffers;
+        std::vector<msgpack::sbuffer> result_buffers;
+        result_buffers.reserve(object.via.array.size - 1);
🧰 Tools
🪛 cppcheck (2.10-2)

[performance] 97-97: Variable 'id' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dcef9ae and 1277194.

📒 Files selected for processing (5)
  • src/spider/CMakeLists.txt (2 hunks)
  • src/spider/worker/FunctionManager.cpp (2 hunks)
  • src/spider/worker/FunctionManager.hpp (1 hunks)
  • tests/worker/worker-test.cpp (1 hunks)
  • tests/worker/worker-test.hpp (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/worker/worker-test.hpp
  • tests/worker/worker-test.cpp
🧰 Additional context used
🪛 cppcheck (2.10-2)
src/spider/worker/FunctionManager.cpp

[performance] 97-97: Variable 'id' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: non-storage-unit-tests
  • GitHub Check: lint
🔇 Additional comments (4)
src/spider/worker/FunctionManager.cpp (1)

8-8: LGTM! Appropriate placement of spdlog include.

The addition of spdlog include in the source file aligns with the PR objective of removing spdlog from public headers while maintaining logging functionality.

src/spider/worker/FunctionManager.hpp (1)

164-165: LGTM! Appropriate separation of declaration and implementation.

Moving the implementation to the source file while maintaining the declaration in the header is a good practice that aligns with the PR objective of cleaning up header dependencies.

src/spider/CMakeLists.txt (2)

35-42: LGTM! Modern CMake usage with FILE_SET.

The change to use CMake's FILE_SET feature is a good modernization that improves header organization and installation.


160-167: LGTM! Consistent FILE_SET usage across targets.

The parallel update to spider_client's header specification maintains consistency in the build system configuration.

Copy link

@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

🧹 Nitpick comments (1)
src/spider/worker/FunctionManager.cpp (1)

67-103: Consider enhancing error messages with more context

The error handling is thorough, but the error messages could be more descriptive by including the actual array size when reporting "Wrong type" error.

Apply this diff to improve the error message:

-            spdlog::error("Cannot split result into buffers: Wrong type");
+            spdlog::error("Cannot split result into buffers: Wrong type or size (expected >= 2, got {})", 
+                    object.via.array.size);
🧰 Tools
🪛 cppcheck (2.10-2)

[performance] 97-97: Variable 'id' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1277194 and 0aba334.

📒 Files selected for processing (2)
  • src/spider/worker/FunctionManager.cpp (2 hunks)
  • src/spider/worker/FunctionManager.hpp (1 hunks)
🧰 Additional context used
🪛 cppcheck (2.10-2)
src/spider/worker/FunctionManager.cpp

[performance] 97-97: Variable 'id' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: non-storage-unit-tests
  • GitHub Check: lint
🔇 Additional comments (4)
src/spider/worker/FunctionManager.cpp (2)

3-11: Well-organized include directives!

The includes are properly organized and grouped by their categories (standard library, third-party, and project headers).


Line range hint 1-103: Implementation successfully moved from header to source file

The changes effectively achieve the PR objective of moving the implementation to the source file while maintaining consistent coding patterns and error handling.

🧰 Tools
🪛 cppcheck (2.10-2)

[performance] 97-97: Variable 'id' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

src/spider/worker/FunctionManager.hpp (2)

163-164: Header changes align with PR objectives

Successfully removed the spdlog dependency from the public header while maintaining a clean interface.


Line range hint 1-164: Well-maintained header organization

The header file maintains a clean public interface while properly organizing template implementations and declarations.

@sitaowang1998 sitaowang1998 merged commit 74116cb into y-scope:main Jan 7, 2025
4 checks passed
@sitaowang1998 sitaowang1998 deleted the cmake branch January 7, 2025 22:31
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