Skip to content

Cursor grpc#26

Merged
p14n merged 8 commits intomainfrom
cursor-grpc
Mar 13, 2025
Merged

Cursor grpc#26
p14n merged 8 commits intomainfrom
cursor-grpc

Conversation

@p14n
Copy link
Copy Markdown
Owner

@p14n p14n commented Mar 12, 2025

No description provided.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 12, 2025

Reviewer's Guide by Sourcery

This pull request introduces gRPC support for fetching events. It includes the necessary gRPC dependencies, protobuf definitions, server and client implementations, and an interface for the catchup server. It also implements the CatchupServerInterface in CatchupServer.

Sequence diagram for fetching events via gRPC

sequenceDiagram
    participant Client
    participant CatchupGrpcClient
    participant CatchupGrpcServer
    participant CatchupServer

    Client->>CatchupGrpcClient: fetchEvents(startAfter, end, maxResults)
    CatchupGrpcClient->>CatchupGrpcServer: fetchEvents(FetchEventsRequest)
    CatchupGrpcServer->>CatchupServer: fetchEvents(startAfter, end, maxResults)
    CatchupServer-->>CatchupGrpcServer: List<Event>
    CatchupGrpcServer-->>CatchupGrpcClient: FetchEventsResponse
    CatchupGrpcClient-->>Client: List<Event>
Loading

Class diagram for CatchupGrpcServer

classDiagram
    class CatchupGrpcServer {
        -int port
        -Server server
        +CatchupGrpcServer(int port, CatchupServerInterface catchupServer)
        +void start()
        +void stop()
        +void blockUntilShutdown()
    }
    class CatchupServiceImpl {
        -CatchupServerInterface catchupServer
        +CatchupServiceImpl(CatchupServerInterface catchupServer)
        +void fetchEvents(FetchEventsRequest request, StreamObserver~FetchEventsResponse~ responseObserver)
        -Event convertToGrpcEvent(Event event)
    }
    CatchupGrpcServer -- CatchupServiceImpl : uses
    CatchupServiceImpl -- CatchupServerInterface : uses
Loading

Class diagram for CatchupGrpcClient

classDiagram
    class CatchupGrpcClient {
        -ManagedChannel channel
        -CatchupServiceBlockingStub blockingStub
        -String topic
        +CatchupGrpcClient(String host, int port, String topic)
        +List~Event~ fetchEvents(long startAfter, long end, int maxResults)
        -Event convertFromGrpcEvent(Event grpcEvent)
        +void close()
    }
    CatchupGrpcClient -- CatchupServiceBlockingStub : uses
    CatchupGrpcClient ..|> CatchupServerInterface : implements
Loading

File-Level Changes

Change Details Files
Configures gRPC dependencies and protobuf plugin for gRPC code generation.
  • Added gRPC dependencies.
  • Added protobuf plugin configuration.
  • Configured source sets to include generated gRPC code.
build.gradle
Introduces a gRPC server for fetching events.
  • Created a gRPC service definition using protobuf.
  • Implemented a gRPC server to expose the event fetching functionality.
  • Implemented a gRPC client to consume the event fetching functionality.
  • Added an interface for the catchup server.
src/main/java/com/p14n/postevent/catchup/grpc/CatchupGrpcServer.java
src/main/java/com/p14n/postevent/catchup/grpc/CatchupGrpcClient.java
src/main/java/com/p14n/postevent/catchup/CatchupServerInterface.java
src/main/proto/catchup.proto
Implements the CatchupServerInterface in CatchupServer.
  • Implemented the CatchupServerInterface in CatchupServer.
src/main/java/com/p14n/postevent/catchup/CatchupServer.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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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
Copy Markdown
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 adding a health check endpoint to the gRPC server for monitoring purposes.
  • It might be useful to add some logging or metrics around gRPC request latency.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

grpcEvent.getDataschema(),
grpcEvent.getSubject(),
grpcEvent.getData().toByteArray(),
time.toInstant(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Potential NullPointerException in time conversion.

If grpcEvent.getTime() returns an empty string, the variable 'time' remains null, and calling 'time.toInstant()' will throw a NullPointerException. Consider adding a null check or handling the absence of time appropriately.

@p14n p14n merged commit 5c29414 into main Mar 13, 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