Skip to content

Maven publish#49

Merged
p14n merged 5 commits intomainfrom
human-maven-publish
Apr 27, 2025
Merged

Maven publish#49
p14n merged 5 commits intomainfrom
human-maven-publish

Conversation

@p14n
Copy link
Owner

@p14n p14n commented Apr 27, 2025

Summary by Sourcery

Prepare the library for release by adding Maven publishing configuration and improving internal documentation.

Build:

  • Add the maven-publish plugin and configure coordinates, POM details, and signing for publishing to Maven Central.
  • Update library version to 1.0.0-SNAPSHOT.

CI:

  • Introduce a GitHub Actions workflow (publish.yml) to automate publishing to Maven Central upon release creation.

Documentation:

  • Update README with the correct library version and project status.

Tests:

  • Rename integration test files to align with package structure changes.

Chores:

  • Rename gRPC-related packages from *.grpc to *.remote.
  • Add comprehensive Javadoc comments to public classes, methods, and interfaces.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 27, 2025

Reviewer's Guide by Sourcery

This pull request focuses on significantly improving the documentation of the postevent library by adding comprehensive Javadoc comments to almost all classes and interfaces. It also updates the build configuration to support publishing the library to Maven Central and renames the gRPC-related packages for better organization.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Add extensive Javadoc documentation to classes and interfaces across the library.
  • Added detailed Javadoc explaining the purpose, key features, and usage of various classes and interfaces.
  • Added Javadoc for methods, constructors, and fields.
  • Included code examples in Javadoc where appropriate.
  • Added private constructors to utility classes to prevent instantiation.
library/src/main/java/com/p14n/postevent/catchup/CatchupService.java
library/src/main/java/com/p14n/postevent/broker/DefaultMessageBroker.java
library/src/main/java/com/p14n/postevent/db/DatabaseSetup.java
library/src/main/java/com/p14n/postevent/telemetry/OpenTelemetryFunctions.java
library/src/main/java/com/p14n/postevent/RemotePersistentConsumer.java
library/src/main/java/com/p14n/postevent/LocalPersistentConsumer.java
library/src/main/java/com/p14n/postevent/data/Event.java
library/src/main/java/com/p14n/postevent/debezium/DebeziumServer.java
library/src/main/java/com/p14n/postevent/catchup/PersistentBroker.java
library/src/main/java/com/p14n/postevent/data/PostEventConfig.java
library/src/main/java/com/p14n/postevent/catchup/remote/CatchupGrpcClient.java
library/src/main/java/com/p14n/postevent/catchup/remote/CatchupGrpcServer.java
library/src/main/java/com/p14n/postevent/db/SQL.java
library/src/main/java/com/p14n/postevent/ConsumerServer.java
library/src/main/java/com/p14n/postevent/data/ConfigData.java
library/src/main/java/com/p14n/postevent/broker/TransactionalBroker.java
library/src/main/java/com/p14n/postevent/catchup/CatchupServer.java
library/src/main/java/com/p14n/postevent/broker/remote/MessageBrokerGrpcServer.java
library/src/main/java/com/p14n/postevent/LocalConsumer.java
library/src/main/java/com/p14n/postevent/broker/remote/MessageBrokerGrpcClient.java
library/src/main/java/com/p14n/postevent/processor/OrderedProcessor.java
library/src/main/java/com/p14n/postevent/telemetry/BrokerMetrics.java
library/src/main/java/com/p14n/postevent/broker/DefaultExecutor.java
library/src/main/java/com/p14n/postevent/catchup/UnprocessedSubmitter.java
library/src/main/java/com/p14n/postevent/telemetry/MapTextMapGetter.java
library/src/main/java/com/p14n/postevent/catchup/CatchupServerInterface.java
library/src/main/java/com/p14n/postevent/broker/AsyncExecutor.java
library/src/main/java/com/p14n/postevent/README.md
library/src/main/java/com/p14n/postevent/broker/SystemEvent.java
library/src/main/java/com/p14n/postevent/catchup/OneAtATimeBehaviour.java
library/src/main/java/com/p14n/postevent/broker/TransactionalEvent.java
library/src/main/java/com/p14n/postevent/broker/EventMessageBroker.java
library/src/main/java/com/p14n/postevent/broker/SystemEventBroker.java
library/src/main/java/com/p14n/postevent/data/Traceable.java
library/src/main/java/com/p14n/postevent/data/UnprocessedEventFinder.java
Configure Maven publishing for the library.
  • Added the com.vanniktech.maven.publish plugin to build.gradle.
  • Configured publishing to Maven Central with signing and POM metadata.
  • Added a GitHub Actions workflow to publish on release creation.
  • Updated version and README snippets to reflect snapshot version.
library/build.gradle
.github/workflows/publish.yml
library/src/main/java/com/p14n/postevent/README.md
Rename gRPC packages for improved organization.
  • Renamed the grpc package to remote for client and server implementations.
  • Updated import statements and references accordingly.
library/src/main/java/com/p14n/postevent/catchup/remote/CatchupGrpcClient.java
library/src/main/java/com/p14n/postevent/catchup/remote/CatchupGrpcServer.java
library/src/test/java/com/p14n/postevent/broker/remote/MessageBrokerGrpcIntegrationTest.java
library/src/test/java/com/p14n/postevent/catchup/remote/CatchupGrpcIntegrationTest.java
library/src/main/java/com/p14n/postevent/broker/remote/MessageBrokerGrpcServer.java
library/src/main/java/com/p14n/postevent/broker/remote/MessageBrokerGrpcClient.java
Update configuration handling for topics and add poll interval.
  • Changed PostEventConfig and ConfigData to use a Set<String> for topics instead of a single String.
  • Added a pollInterval parameter to PostEventConfig and ConfigData.
  • Updated Debezium configuration and LocalConsumer to use the set of topics and poll interval.
library/src/main/java/com/p14n/postevent/data/PostEventConfig.java
library/src/main/java/com/p14n/postevent/data/ConfigData.java
library/src/main/java/com/p14n/postevent/debezium/DebeziumServer.java
library/src/main/java/com/p14n/postevent/LocalConsumer.java
Apply minor code and comment refinements.
  • Corrected logging message formatting.
  • Updated comments for clarity.
  • Removed commented-out code.
  • Corrected exception type in CatchupGrpcClient close method.
  • Corrected metric scope name in ConsumerServer.
  • Corrected SystemEvent topic field Javadoc.
library/src/main/java/com/p14n/postevent/catchup/CatchupService.java
library/src/main/java/com/p14n/postevent/broker/DefaultMessageBroker.java
library/src/main/java/com/p14n/postevent/db/DatabaseSetup.java
library/src/main/java/com/p14n/postevent/telemetry/OpenTelemetryFunctions.java
library/src/main/java/com/p14n/postevent/RemotePersistentConsumer.java
library/src/main/java/com/p14n/postevent/LocalPersistentConsumer.java
library/src/main/java/com/p14n/postevent/debezium/DebeziumServer.java
library/src/main/java/com/p14n/postevent/catchup/PersistentBroker.java
library/src/main/java/com/p14n/postevent/catchup/remote/CatchupGrpcClient.java
library/src/main/java/com/p14n/postevent/ConsumerServer.java
library/src/main/java/com/p14n/postevent/broker/TransactionalBroker.java
library/src/main/java/com/p14n/postevent/data/UnprocessedEventFinder.java
library/src/main/java/com/p14n/postevent/broker/MessageBrokerGrpcClient.java
library/src/main/java/com/p14n/postevent/broker/SystemEvent.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @p14n - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider updating the Javadoc exclusion path in build.gradle from **/grpc/** to reflect the package rename to remote, or remove it if no longer needed.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

.build());
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Review the commented-out subscriber cleanup logic.

If removal of the topic from the 'subscribed' set is intended upon error, consider uncommenting it; otherwise, remove the dead code to keep the implementation clear.

* @param topic the topic to associate with this event
* @return this event instance with the topic set
*/
public SystemEvent withTopic(String topic) {
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Avoid mutating enum instances in the withTopic method.

Since enum values are constants in Java, modifying the 'topic' field directly can lead to unexpected behavior and thread-safety issues. Consider returning a new data structure or using an immutable pattern to associate topics with events.

[![Build Status](https://github.com/p14n/postevent/workflows/Test%20PR/badge.svg)](https://github.com/p14n/postevent/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Latest Release](https://img.shields.io/github/v/release/yourusername/postevent)](https://github.com/yourusername/postevent/releases)
[![Latest Release](https://img.shields.io/github/v/release/p14n/postevent)](https://github.com/yourusername/p14n/releases)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (typo): Incorrect link URL for "Latest Release" badge.

The link points to .../yourusername/p14n/releases but should likely point to .../p14n/postevent/releases to match the badge source repository and the project's standard repository URL.

Suggested change
[![Latest Release](https://img.shields.io/github/v/release/p14n/postevent)](https://github.com/yourusername/p14n/releases)
[![Latest Release](https://img.shields.io/github/v/release/p14n/postevent)](https://github.com/p14n/postevent/releases)

for (MessageSubscriber<TransactionalEvent> subscriber : topicSubscribers.get(topic)) {
try (Connection c = ds.getConnection()) {

processWithTelemetry(openTelemetry, tracer, message, "ordered_process", () -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider extracting the inner telemetry-wrapped logic into a helper method to simplify the nested lambda structure.

Consider extracting the inner telemetry-wrapped logic into helper methods to reduce nested lambda complexity. For example, you can refactor the inner processing logic into a separate method:

private boolean processMessage(
    MessageSubscriber<TransactionalEvent> subscriber,
    String topic,
    Connection connection,
    Event event
) {
    return processWithTelemetry(openTelemetry, tracer, event, "message_transaction", () -> {
        try {
            subscriber.onMessage(new TransactionalEvent(connection, event));
            metrics.recordReceived(topic);
            return true;
        } catch (Exception e) {
            try {
                subscriber.onError(e);
            } catch (Exception ignored) {
            }
            return false;
        }
    });
}

Then update the publish method to use a single telemetry wrapper for the OrderedProcessor:

@Override
public void publish(String topic, Event message) {
    if (!canProcess(topic, message)) {
        return;
    }

    metrics.recordPublished(topic);

    for (MessageSubscriber<TransactionalEvent> subscriber : topicSubscribers.get(topic)) {
        try (Connection c = ds.getConnection()) {
            processWithTelemetry(openTelemetry, tracer, message, "ordered_process", () -> {
                var op = new OrderedProcessor(systemEventBroker, (connection, event) ->
                    processMessage(subscriber, topic, connection, event)
                );
                op.process(c, message);
                return null;
            });
        } catch (Exception e) {
            try {
                subscriber.onError(e);
            } catch (Exception ignored) {
                // If error handling fails, we ignore it to protect other subscribers
            }
        }
    }
}

This approach maintains all functionality while reducing nested lambda complexity by isolating the inner logic into its own helper method.

p14n and others added 2 commits April 27, 2025 21:44
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@p14n p14n merged commit 5aafa23 into main Apr 27, 2025
1 check 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.

1 participant