Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(core): add branch service #18379

Merged
merged 6 commits into from
Nov 7, 2023
Merged

feat(core): add branch service #18379

merged 6 commits into from
Nov 7, 2023

Conversation

testinginprod
Copy link
Contributor

@testinginprod testinginprod commented Nov 6, 2023

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features
    • Introduced a new "branch" service that allows isolated execution of functions. If a function returns an error, changes are rolled back. If it returns nil, changes are committed. This enhances error handling and code execution safety.

Copy link
Contributor

coderabbitai bot commented Nov 6, 2023

Walkthrough

A new package named branch has been introduced in the core system. This package includes a Service interface with an Execute method. This method runs a function in an isolated context, managing its execution based on the function's return status.

Changes

File Change
core/CHANGELOG.md Added a new branch service in the unreleased version.
core/branch/branch.go Introduced a new package branch with a Service interface. The Execute method in the interface runs a function in an isolated context and manages its execution based on the function's return status.

Poem

🍂 As the leaves fall this November day, 🍁

A new branch in our code finds its way. 🌳

With an Execute method so neat, 🖥️

Errors and success it shall meet. 🎉

In the world of code, it's a small feat, 🌍

But for us, it's a milestone sweet. 🍬

So let's celebrate this day with cheer, 🥳

For our codebase has something new to revere! 🙌


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@testinginprod testinginprod marked this pull request as ready for review November 6, 2023 17:52
@testinginprod testinginprod requested a review from a team as a code owner November 6, 2023 17:52
@github-prbot github-prbot requested review from a team, tac0turtle and atheeshp and removed request for a team November 6, 2023 17:52
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fb9dadc and 32d8862.
Files selected for processing (2)
  • core/CHANGELOG.md (1 hunks)
  • core/branch/branch.go (1 hunks)
Additional comments: 2
core/CHANGELOG.md (1)
  • 36-39: The changelog entry for the new branch service is correctly placed under the "Unreleased" section. Ensure that the issue number and the link are correct.
core/branch/branch.go (1)
  • 1-18: The interface definition looks good. It's clear and well-documented. However, ensure that the implementation of this interface correctly handles the rollback and commit operations as described in the comments. Also, ensure that the context passed to the function f is indeed a child of the context passed to the Execute function.

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

This conceptually looks right. We may want to work on the naming. I'm not sure branch is intuitive enough.

core/branch/branch.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 32d8862 and 644cb17.
Files selected for processing (1)
  • core/branch/branch.go (1 hunks)
Additional comments: 2
core/branch/branch.go (2)
  • 1-19: The branch package and Service interface are well defined. The Execute method is clear in its purpose and usage. The comments provide a good explanation of the functionality. Ensure that the implementation of this interface correctly handles the context and error propagation.

  • 7-7: In response to the previous comment, the isolation refers to the execution of the function f in a separate context that is a child of the context passed to Execute. Any changes made during the execution of f can be rolled back if f returns an error, ensuring that the parent context remains unaffected. This is useful for operations that need to be atomic, where all changes should be committed only if all operations succeed.

@testinginprod
Copy link
Contributor Author

This conceptually looks right. We may want to work on the naming. I'm not sure branch is intuitive enough.

I think we can merge, I will open an issue about this that we can mark as release blocker for core.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 644cb17 and 1f05dd5.
Files selected for processing (1)
  • core/branch/branch.go (1 hunks)
Additional comments: 1
core/branch/branch.go (1)
  • 1-19: The Service interface and its Execute method are well documented. The comments provide a clear understanding of the purpose and usage of the interface and method. The code is clean and follows Go best practices. However, ensure that the implementation of this interface correctly handles the rollback and commit scenarios as described in the comments.

@testinginprod testinginprod added this pull request to the merge queue Nov 7, 2023
Merged via the queue into main with commit d52a7c4 Nov 7, 2023
58 of 60 checks passed
@testinginprod testinginprod deleted the tip/core/branching branch November 7, 2023 12:01
@testinginprod testinginprod mentioned this pull request Dec 19, 2023
44 tasks
@coderabbitai coderabbitai bot mentioned this pull request May 3, 2024
12 tasks
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.

3 participants