Skip to content

[Swift] Swift gRPC Integration for Fory #3370

Description

@chaokunyang

This issue is reserved for gsoc, do not take over it currently.

Feature Request

Swift gRPC Integration in Apache Fory

Problem Statement

Fory Swift currently lacks:

  • Generated Swift transport bindings for services.
  • A Fory-backed codec for grpc-swift.
  • Official examples, integration tests, and comprehensive documentation for Swift gRPC.

Expected Outcomes

  • Generate Swift gRPC transport code from service definitions.
  • Support unary, client-streaming, server-streaming, and bidirectional-streaming RPCs.
  • Provide a grpc-swift codec backed by Fory serialization and deserialization.
  • Provide deterministic, safe decode behavior, including zero-copy when valid and copy fallback when required.
  • Add integration tests and runnable examples.
  • Provide comprehensive Swift gRPC integration documentation.

Detailed Scope

1) Service gRPC Code Generation

  • Generate service.swift for service protocols and method signatures.
  • Generate service_grpc.swift for grpc-swift client/server bindings.
  • Ensure generated signatures align with existing Swift model types.

2) grpc-swift Codec Integration

  • Implement codec encode and decode using Fory Swift runtime.
  • Map request and response types to generated service APIs.
  • Provide clear error mapping for invalid payloads and type mismatches.

3) Decode Path Behavior

  • Add zero-copy decode path when ownership and lifetime constraints are safe.
  • Add copy fallback path when zero-copy cannot be guaranteed.
  • Keep behavior deterministic and memory-safe.

4) Tests

Compiler and integration tests should cover:

  • Generated file names and key service signatures.
  • Unary, client-streaming, server-streaming, and bidi-streaming coverage.
  • Codec round-trip and error-path behavior.
  • Zero-copy path and fallback path validation.

5) Examples and Comprehensive Documentation

  • Add runnable Swift gRPC server and client examples using generated code and codec.
  • Update compiler and Swift docs for gRPC generation and integration usage.
  • Document supported grpc-swift version(s), Swift toolchain version(s), and compatibility constraints.
  • Add a clear end-to-end quickstart: IDL -> codegen -> build -> run server -> run client.
  • Document generated files and API shape (service.swift, service_grpc.swift) with method mapping by RPC mode.
  • Document codec behavior, error mapping, and zero-copy vs fallback rules and safety constraints.
  • Add troubleshooting guidance for common setup/runtime errors and how to diagnose them.
  • Provide a minimal performance guide: allocation/copy considerations and recommended usage patterns.

Acceptance Criteria

  1. Swift service gRPC code generation produces usable service.swift and service_grpc.swift.
  2. Generated code supports unary, client-streaming, server-streaming, and bidi-streaming APIs.
  3. Fory-backed grpc-swift codec passes round-trip and error-path tests.
  4. Zero-copy decode path exists with tested fallback behavior.
  5. Swift gRPC examples run successfully.
  6. Comprehensive documentation is added, including quickstart, API/generated-code guide, compatibility/version notes, codec/error behavior, and troubleshooting.

Skills Required

  • Swift
  • grpc-swift
  • Compiler and code generation
  • Serialization internals
  • Async and streaming APIs
  • Testing and performance profiling
  • Technical documentation

Difficulty

Medium

Project Size

Preferred: 175hours

Potential Mentors

  • Chaokun Yang
  • Weipeng Wang

Source Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions