Skip to content

Conversation

@frhuelsz
Copy link
Contributor

@frhuelsz frhuelsz commented Dec 14, 2025

🔍 Description

Completes #397.

This PR adds the base infrastructure and behavior of the gRPC server.

Depends on

An attempt to make a mostly accurate arch diagram from all this. I will add a doc with this in the future.

flowchart TD

subgraph harpoon [Harpoon Crate]
  service[TridentService]
end

subgraph Trident
  real_main[main]
  logfwd["Log Forwarder"]
  real_main-->|creates|logfwd
  subgraph Server Module
    main[server_main]
    listener[Unix Socket Listener]
    tracker[Activity Tracker]
    timer[Shutdown Timer]
    tracker-->|starts/cancels|timer
    timer-->|stops|tonic
    middleware[Tracker Middleware]
    subgraph grpc ["gRPC Server (tonic)"]
      tonic["Tonic gRPC Server"]
      middleware[Tracker Middleware]
      tonic-->|uses|middleware
      subgraph server[Harpoon Server]
        rpcs["RPC Methods"]
        rpcs-->|create| resp[Response<br/>Stream Channel]
        rpcs-->|spawn|logtask["Log Fwing Task"]
        logtask-->|sends logs|resp
        connLock[Connection RWLock]
        subgraph mgr[Servicing Manager]
          srvLock[Servicing RW Lock]
          srvCaller[Servicing Callers]
          srvCaller<-->|try lock|srvLock
          srvBlock["Servicing Task (Blocking)"]
          srvCaller<-->|start|srvBlock
        end
        rpcs<-->|try lock|connLock
        rpcs-->|invoke|srvCaller
        srvCaller-->|sends result|resp
      end
      tonic-->|invokes|rpcs
    end
    listener-->|used by|tonic
    service-->|implemented by|server
    main-->|creates| listener
    main-->|creates| tracker
    tracker-->|creates| middleware
    middleware-->|notify conn<br/>start/end| tracker
    main-->|starts| grpc
    srvCaller-->|notifies servicing<br/>start/end|tracker
  end
  logfwd-->|sends to|logtask
  real_main-->|invokes|main
  subgraph TridentCore
    servicing["Servicing action"]
  end

  srvBlock<-->|"runs (NOT IMPL YET)"|servicing
end
Loading

@frhuelsz frhuelsz linked an issue Dec 14, 2025 that may be closed by this pull request
@frhuelsz frhuelsz marked this pull request as ready for review December 17, 2025 19:31
@frhuelsz frhuelsz requested a review from a team as a code owner December 17, 2025 19:31
Copilot AI review requested due to automatic review settings December 17, 2025 19:31
Copy link
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 adds foundational gRPC server infrastructure to support servicing operations in Trident, including activity tracking, connection management, log forwarding, and systemd socket activation support.

Key changes:

  • Implements TridentHarpoonServer with servicing request handling and lock-based concurrency control
  • Adds ActivityTracker to monitor connections and servicing operations with automatic shutdown on inactivity
  • Introduces systemd socket activation support with Unix domain socket handling

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
crates/trident/src/server/tridentserver/servicingmgr.rs Manages servicing locks and spawns blocking servicing tasks with activity tracking
crates/trident/src/server/tridentserver/mod.rs Implements gRPC TridentService with stub methods, request handlers, and log forwarding
crates/trident/src/server/support/stream.rs Provides StreamWithLock wrapper for managing gRPC streams with associated lock guards
crates/trident/src/server/support/fds.rs Handles systemd socket activation and Unix socket file descriptor management
crates/trident/src/server/mod.rs Main server entry point with listener setup and signal handling
crates/trident/src/server/activitytracker/tracker.rs Tracks active connections and servicing with configurable inactivity timeout
crates/trident/src/server/activitytracker/timer.rs Simple timer implementation with cancellation support for inactivity tracking
crates/trident/src/server/activitytracker/middleware.rs Tonic middleware for automatic connection tracking via request/response lifecycle
crates/trident/src/lib.rs Conditionally includes server module for testing
crates/trident/Cargo.toml Adds gRPC dependencies (tonic, hyper, tokio-stream) and updates nix to 0.30.1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 17, 2025 22:46
Copy link
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

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 17, 2025 23:28
Copy link
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

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 20, 2025 08:51
frhuelsz and others added 3 commits December 20, 2025 00:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 20, 2025 18:17
Copy link
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

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 21, 2025 00:09
Copy link
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

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings December 23, 2025 19:33
Copy link
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

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.

ayaegashi
ayaegashi previously approved these changes Dec 23, 2025
Copy link
Contributor

@ayaegashi ayaegashi left a comment

Choose a reason for hiding this comment

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

a couple nits, but otherwise LGTM

@frhuelsz frhuelsz merged commit 92b0a60 into main Dec 23, 2025
16 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.

RFC 0379: gRPC API: Server Implementation

3 participants