feat: protoファイルを読み込み、gRPC通信のフィールド名を補完#242
Open
taka2233 wants to merge 22 commits intoDeNA:masterfrom
Open
Conversation
…istry, and ProtocRunner classes
…encoder instance creation
…ress in encoder instance creation and enhance gRPC handling with descriptor file management
…ent and add GUIOptionProtoCompileDialog for .proto file handling
…PacketAttackController to include server information
…ement, replacing the previous ProtoCompileDialog
…log and enhance ProtocRunner for consistent file naming
…odeGRPC and EncodeGRPCStreaming for improved gRPC body handling and remove DescriptorSetLoader references
…h GrpcServiceRegistry for improved gRPC body handling in EncodeGRPC and EncodeGRPCStreaming
…treaming by implementing schema-aware body decoding and encoding, while maintaining compatibility with existing functionality
…ng for better readability
…d methods for improved functionality in svc_a and svc_b
…instead of at encoder creation
…rviceRegistry and GrpcServiceRegistryStore
…Resolver for improved schema-aware encoding and decoding in EncodeGRPC and EncodeGRPCStreaming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
gRPC 通信を
.protoファイルに基づいてデコード/エンコードする機能を追加しています。gRPC エンコーダは、フィールド番号ベースのデコードしていましたが、ユーザーが
.protoファイルを読み込むことで フィールド名つきの JSON 形式での表示するようにしました。動作の流れ
.protoファイルを選択 →protocで.descを生成.descを読み込む/package.Service/Method) からリクエスト/レスポンスの型を解決し、フィールド名を補完してJSONに変換する.descが未設定 or 解決できない場合は、従来のジェネリック protobuf デコードにフォールバックUI
gRPCエンコーダー選択時に
Import Proto Fileのボタンを表示gRPCエンコーダー選択時にImport Proto Fileのボタンを表示
.protoファイルのImportと、descファイルの生成
gRPCのフィールド名を補完
ファイル差分
1. 補完ロジック
GrpcServiceRegistry.kt.descから gRPC path → input/output Descriptor のマッピングを構築GrpcServiceRegistryStore.kt.descファイルのキャッシュ管理 + authority → Server →.descの解決チェーンGrpcSchemaResolver.ktEncodeGRPC.javaEncodeGRPCStreaming.java2. 永続化
Server.javadescriptor_pathカラム追加Servers.javaALTER TABLEマイグレーション3. GUI / protoc 実行
GUIOptionServerDialog.javaGUIOptionGrpcDescriptorDialog.kt.proto選択 →.desc生成 → サービス一覧表示の統合ダイアログProtocRunner.ktprotocの実行ラッパーProtoFileSet.kt.protoファイルの重複排除・include パス計算NativeFileChooser.java4. テスト
GrpcServiceRegistryTest.ktGrpcServiceRegistryStoreTest.kt.descのロード/キャッシュ、--include_imports無しの検出、authority パース、ListenPort フォールバックProtoFileSetTest.kt.protoの重複排除、include パス計算5. その他
build.gradle:protobuf-java-util依存追加(JsonFormatに必要)src/test/resources/packetproxy/grpc/proto/: テスト用.proto/.descfixture前提条件
PATHにprotocが含まれている必要があります(.desc生成時のみ).descは~/.packetproxy/grpc_desc/以下に{project}_{serverId}.descとして保存されます制約
.descのホットリロードは未対応(Server 設定画面から再生成が必要)テスト
./gradlew test --tests "packetproxy.grpc.*"パス確認済み.protoをインポートし、.descが生成されることを確認.desc未設定時に従来のジェネリック表示にフォールバックすることを確認