Skip to content

feat(gpRc): update FDL lexer/parser to support service and rpc definitions#3308

Open
ayush00git wants to merge 13 commits intoapache:mainfrom
ayush00git:feat/fdl-parser
Open

feat(gpRc): update FDL lexer/parser to support service and rpc definitions#3308
ayush00git wants to merge 13 commits intoapache:mainfrom
ayush00git:feat/fdl-parser

Conversation

@ayush00git
Copy link
Contributor

@ayush00git ayush00git commented Feb 7, 2026

Why?

Using fory with gRPCs forced using the protobuffs for the services and methods of a class. Users needed to define separate files for generating stubs. Which turns their focus on using protobuff completely, ignoring the fory's performance.

What does this PR do?

Adds the parser for rpc methods and services to allow users use FDL with gRPC.

Added Keywords

service
rpc
returns
stream

Changes Made

1. compiler/fory_compiler/ir/ast.py

Added RpcMethod and Service Data classes.

@dataclass
class Service:
    """A service definition."""

    name: str
    methods: List[RpcMethod] = field(default_factory=list)
    options: dict = field(default_factory=dict)
    line: int = 0
    column: int = 0
    location: Optional[SourceLocation] = None

    def __repr__(self) -> str:
        opts_str = f", options={len(self.options)}" if self.options else ""
        return f"Service({self.name}, methods={len(self.methods)}{opts_str})"

2. compiler/fory_compiler/frontend/fdl/lexer.py

  • Added the SERVICE RPC RETURNS STREAM to the TokenType enum
  • Registered Keywords in Lexer.Keywords

3. compiler/fory_compiler/frontend/fdl/parser.py

  • Added the parse_service and parse_rpc_method method.

Related issues

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
    This PR extends the FDL language with support for service definitions using service rpc returns and stream keywords. This allows users to define gRPC services directly in their FDL schemas.
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

N/A

@ayush00git
Copy link
Contributor Author

Hey @chaokunyang
Give it a review and let me know the desired changes. Meanwhile i'm working on the #3269

@chaokunyang
Copy link
Collaborator

chaokunyang commented Feb 7, 2026

You also need to update protobuf and flatbuffers idl parser and add tests

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.

[Compiler][gRPC][FDL] Parse service/rpc/stream in FDL frontend

2 participants