Skip to content

Locally committed handlers are set like other Endpoint properties#7487

Merged
eddyashton merged 11 commits intomicrosoft:mainfrom
eddyashton:locally_committed_is_not_so_special
Nov 28, 2025
Merged

Locally committed handlers are set like other Endpoint properties#7487
eddyashton merged 11 commits intomicrosoft:mainfrom
eddyashton:locally_committed_is_not_so_special

Conversation

@eddyashton
Copy link
Copy Markdown
Member

Breaking change, so warrants discussion, but I think this is better.

Previously:

make_endpoint_with_local_commit_handler(
  "/foo/bar",
  HTTP_POST,
  handler_fn,
  
  LOCALLY_COMMITTED_HANDLER_FN,
  
  auth_methods)
    .set_a(A)
    .set_b(B)
    .install();

Now:

make_endpoint(
  "/foo/bar",
  HTTP_POST,
  handler_fn,
  auth_methods)
    .set_a(A)
    .set_b(B)
  
    .set_locally_committed_function(LOCALLY_COMMITTED_HANDLER_FN)
  
    .install();

Branching at the top-level make_ function causes unnecessary duplication. We already had make_ and make_read_only_ variants, with the requirement that any implementer overrode both consistently and correctly. I'm looking at adding a similar-looking globally_committed_function option to each endpoint as well, but putting that at the same level would multiply the number of make_ functions.

I think that's totally unnecessary - we deliberately avoid this proliferation of make_ functions by having these set_ functions on the resulting Endpoint, so that only the (usually small number of) endpoints which care about the special behaviour have to consider it. I think the size of the internal diff supports this - the actual functionality is identical, populating the locally_committed_func field, but we delete a lot of surrounding boilerplate.

@eddyashton eddyashton requested a review from a team as a code owner November 26, 2025 14:51
Copilot AI review requested due to automatic review settings November 26, 2025 14:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the API for setting local commit handlers on endpoints by introducing a new .set_locally_committed_function() setter method, replacing the previous make_endpoint_with_local_commit_handler() and make_read_only_endpoint_with_local_commit_handler() factory functions. This change reduces code duplication and makes the API more consistent with how other endpoint properties are configured.

Key changes:

  • Added set_locally_committed_function() method to the Endpoint class for setting local commit handlers
  • Removed make_[read_only_]endpoint_with_local_commit_handler() factory methods from EndpointRegistry
  • Updated the sample logging application to use the new API pattern with fluent chaining

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/ccf/endpoint.h Adds declaration for new set_locally_committed_function() setter method
src/endpoints/endpoint.cpp Implements set_locally_committed_function() following the existing setter pattern
include/ccf/endpoint_registry.h Removes deprecated make_*_with_local_commit_handler() factory method declarations
src/endpoints/endpoint_registry.cpp Removes implementations of the deprecated factory methods
samples/apps/logging/logging.cpp Refactors to use new API with .set_locally_committed_function() in fluent chain
CHANGELOG.md Documents the breaking API change with migration instructions

Comment thread CHANGELOG.md Outdated
eddyashton and others added 4 commits November 26, 2025 14:57
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@eddyashton eddyashton merged commit 89e1302 into microsoft:main Nov 28, 2025
17 checks passed
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