Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cb24719
feat: added shared base utilities
ayush00git May 22, 2026
4692f8e
Merge branch 'main' into feat/grpc-go
ayush00git May 24, 2026
18ff0a8
feat: build package imports for generated_services()
ayush00git May 24, 2026
a60ca0e
Merge branch 'main' into feat/grpc-go
ayush00git May 26, 2026
056e30c
Merge branch 'main' into feat/grpc-go
ayush00git May 27, 2026
b6389fb
feat: generates client api interface for service
ayush00git May 27, 2026
ea12a23
feat: add client struct and init constructor
ayush00git May 27, 2026
407c684
Merge branch 'main' into feat/grpc-go
ayush00git May 29, 2026
a8ca325
feat: added server streaming client method generator
ayush00git May 29, 2026
296b94c
feat: added client/bidi client method patterns
ayush00git May 29, 2026
d597d66
feat: added stream type interface, struct and methods
ayush00git May 29, 2026
8695386
feat: add generate server api interface
ayush00git May 29, 2026
c7e0dde
feat: add unimplemented server for forward compatibility
ayush00git May 29, 2026
bb8af19
feat: added server registrar and stream types
ayush00git May 30, 2026
f5480fb
Merge branch 'main' into feat/grpc-go
ayush00git May 31, 2026
d2e84e2
Merge branch 'main' into feat/grpc-go
ayush00git May 31, 2026
e498a52
feat: add service desc generations
ayush00git May 31, 2026
51f4f85
feat: wire up server/client generations to generate file
ayush00git May 31, 2026
11be2ce
feat: GoGenerator inherits from the GoServiceGeneratorMixin
ayush00git May 31, 2026
3bca344
fix: .fory -> .fdl
ayush00git May 31, 2026
e544e50
Merge branch 'main' into feat/grpc-go
ayush00git May 31, 2026
839e9df
add service generate file def to GoGenerator class
ayush00git May 31, 2026
5a53129
passed fory instance to enforce codecv2
ayush00git May 31, 2026
75f96bb
Merge branch 'main' into feat/grpc-go
ayush00git Jun 1, 2026
34c7537
pkg: added new forygrpc codec
ayush00git Jun 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/fory_compiler/generators/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Dict, List, Optional, Set, Tuple, Union as TypingUnion

from fory_compiler.generators.base import BaseGenerator, GeneratedFile
from fory_compiler.generators.services.go import GoServiceGeneratorMixin
from fory_compiler.frontend.utils import parse_idl_file
from fory_compiler.ir.ast import (
Message,
Expand All @@ -38,7 +39,7 @@
from fory_compiler.ir.types import PrimitiveKind


class GoGenerator(BaseGenerator):
class GoGenerator(GoServiceGeneratorMixin, BaseGenerator):
"""Generates Go structs with fory tags."""

language_name = "go"
Expand Down Expand Up @@ -206,6 +207,9 @@ def generate(self) -> List[GeneratedFile]:
# Generate a single Go file with all types
files.append(self.generate_file())

# Generate gRPC service stubs
files.extend(self.generate_services())

return files

def get_package_name(self) -> str:
Expand Down
52 changes: 52 additions & 0 deletions compiler/fory_compiler/generators/services/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"Shared utilities for gRPC service stub generators."

from enum import Enum
from typing import List, Dict
from fory_compiler.ir.ast import RpcMethod

class StreamingMode(Enum):
UNARY = 1
CLIENT_STREAMING = 2
SERVER_STREAMING = 3
BIDIRECTIONAL = 4


def streaming_mode(method: RpcMethod) -> StreamingMode:
"""Defines the type of rpc streaming patterns."""
if not method.client_streaming and not method.server_streaming:
return StreamingMode.UNARY
elif method.client_streaming and not method.server_streaming:
return StreamingMode.CLIENT_STREAMING
elif not method.client_streaming and method.server_streaming:
return StreamingMode.SERVER_STREAMING
else:
return StreamingMode.BIDIRECTIONAL


class ImportTracker:
"""Accumulates cross-package Go imports for generated service stubs."""
def __init__(self):
self._imports: Dict[str, str] = {}

def add(self, alias: str, import_path: str) -> None:
self._imports[alias] = import_path

def go_imports(self) -> List[str]:
return sorted(self._imports.values())
Loading
Loading