Skip to content

Replace Scala server with C/C++ server #1262

@scholarsmate

Description

@scholarsmate

Replace Scala server with C/C++ server

Summary

The current gRPC server is implemented in Scala (Pekko), which adds a JVM runtime dependency and a third build/test/package system. We want to replace the Scala middleware with a cross-platform C/C++ gRPC server that directly bridges to the core native library, reducing complexity and deployment friction.

Motivation

  • Reduce language/toolchain count (Scala/JVM stack removal).
  • Eliminate JRE requirement on target systems.
  • Simplify packaging and distribution (single native server per platform).
  • Improve operational consistency with the native core library.

Goals

  • Provide a fully functional C/C++ gRPC server implementing all RPCs in proto/omega_edit.proto.
  • Preserve existing behavior and API compatibility with clients.
  • Support cross-platform builds (Linux/macOS/Windows).
  • Replace Tika-based file type detection with Apache-2.0 compatible libraries.
  • Maintain current event streaming semantics for sessions and viewports.

Non-Goals

  • Redesign of the gRPC API.
  • Changes to core library public APIs.
  • Client protocol changes.
  • New feature work unrelated to the server migration.

Dependencies and Licensing

All new dependencies must be compatible with Apache-2.0.

Proposed replacements:

  • Content type detection: libmagic (BSD-2-Clause) using the magic database.
  • Language detection: cld3 (Apache-2.0).
  • Encoding/BOM: continue using existing core BOM detection.

Proposed Implementation Plan

  1. Scaffold C/C++ gRPC server

    • Create server/cpp module with CMake build.
    • Generate gRPC stubs from proto/omega_edit.proto.
    • Add CI build target for the new server.
  2. Implement RPC handlers

    • Map all service methods to the native core APIs:
      • Sessions, changes, viewports, search, counts, metadata.
  3. Event streaming

    • Use session and viewport callbacks from core (omega_session_event_cbk_t, omega_viewport_event_cbk_t).
    • Implement subscription management and backpressure-safe queues.
  4. Replace Tika functionality

    • Add C++ wrappers for file type and language detection.
    • Integrate in GetContentType and GetLanguage handlers.
  5. Packaging and distribution

    • Produce platform-specific native server binaries.
    • Update packages/server to bundle the native server instead of the Scala server.
  6. Parity validation

    • Run existing client tests against both servers.
    • Add explicit gRPC parity test suite if needed.

Acceptance Criteria

  • All gRPC endpoints pass existing test suites.
  • Node client can use the new server without code changes.
  • CI builds the native server on Linux/macOS/Windows.
  • No JVM runtime dependency for the server package.
  • All dependencies verified Apache-2.0 compatible.

Risks

  • Feature parity with the Scala server event stream semantics.
  • Threading/concurrency differences between Scala and C++.
  • Packaging complexity for gRPC C++ runtime on Windows.

Notes

  • Keep Scala server temporarily for parity comparison until C++ server is production-ready.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions