← スキル䞀芧に戻る
eco2-team

grpc-service

by eco2-team

🌱 읎윔에윔(Eco²) BE

⭐ 0🍎 0📅 2026幎1月25日
GitHubで芋るManusで実行

SKILL.md


name: grpc-service description: gRPC 서비슀 통합 가읎드. Port/Adapter 팹턮, Proto 정의, Async Client 구현 시 ì°žì¡°. "grpc", "proto", "subagent", "character", "location", "rpc" 킀워드로 튞늬거.

gRPC Service Integration Guide

Eco² gRPC 통합 아킀텍처

┌─────────────────────────────────────────────────────────────────────────┐
│                    gRPC Integration (Clean Architecture)                 │
├──────────────────────────────────────────────────────────────────────────
│                                                                          │
│  Application Layer (Ports)                                               │
│  ├─ CharacterClientPort (Protocol)                                       │
│  ├─ LocationClientPort (Protocol)                                        │
│  └─ DTOs: CharacterDTO, LocationDTO                                     │
│                         │                                                │
│                         â–Œ                                                │
│  Infrastructure Layer (Adapters)                                         │
│  ├─ CharacterGrpcClient ──→ character-api:50051                         │
│  └─ LocationGrpcClient ──→ location-api:50051                           │
│                         │                                                │
│                         â–Œ                                                │
│  Proto Files (Contract)                                                  │
│  ├─ character.proto → character_pb2.py, character_pb2_grpc.py           │
│  └─ location.proto → location_pb2.py, location_pb2_grpc.py              │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

왜 gRPC읞가? (vs HTTP/Celery)

AspectHTTPCelerygRPC
Latency~10ms~50ms+~1-3ms
Type Safety런타임없음컎파음타임
Asyncio제한적믞지원넀읎티람
Streaming복잡믞지원Ʞ볞 지원
LangGraph 통합OKawait 불가최적

Reference Files

Quick Start

1. Port 정의 (Application Layer)

# application/ports/character_client.py
from abc import ABC, abstractmethod
from dataclasses import dataclass

@dataclass(frozen=True)
class CharacterDTO:
    """캐늭터 정볎 DTO"""
    name: str
    character_type: str
    dialog: str
    match_label: str

class CharacterClientPort(ABC):
    """캐늭터 서비슀 큎띌읎얞튞 Port"""

    @abstractmethod
    async def get_character_by_waste_category(
        self,
        waste_category: str,
    ) -> CharacterDTO | None:
        """폐Ʞ묌 칎테고늬로 캐늭터 조회"""
        ...

    @abstractmethod
    async def get_catalog(self) -> list[CharacterDTO]:
        """전첎 캐늭터 목록 조회"""
        ...

2. gRPC Client 구현 (Infrastructure Layer)

# infrastructure/integrations/character/grpc_client.py
import grpc.aio
from .proto import character_pb2, character_pb2_grpc

class CharacterGrpcClient(CharacterClientPort):
    """gRPC êž°ë°˜ 캐늭터 큎띌읎얞튞"""

    def __init__(self, host: str = "character-api", port: int = 50051):
        self._host = host
        self._port = port
        self._channel: grpc.aio.Channel | None = None
        self._stub: character_pb2_grpc.CharacterServiceStub | None = None

    async def _get_stub(self) -> character_pb2_grpc.CharacterServiceStub:
        """Lazy 연결 (첫 혞출 시 채널 생성)"""
        if self._stub is None:
            self._channel = grpc.aio.insecure_channel(
                f"{self._host}:{self._port}"
            )
            self._stub = character_pb2_grpc.CharacterServiceStub(self._channel)
        return self._stub

    async def get_character_by_waste_category(
        self,
        waste_category: str,
    ) -> CharacterDTO | None:
        try:
            stub = await self._get_stub()
            request = character_pb2.GetByMatchRequest(
                match_label=waste_category
            )
            response = await stub.GetCharacterByMatch(request)

            if not response.found:
                return None

            return CharacterDTO(
                name=response.name,
                character_type=response.character_type,
                dialog=response.dialog,
                match_label=response.match_label,
            )
        except grpc.aio.AioRpcError as e:
            logger.error("gRPC error", code=e.code().name, details=e.details())
            return None

    async def close(self) -> None:
        """채널 종료"""
        if self._channel:
            await self._channel.close()
            self._channel = None
            self._stub = None

3. LangGraph 녾드 통합

# infrastructure/orchestration/langgraph/nodes/character_node.py

def create_character_node(
    character_client: CharacterClientPort,
    llm: LLMClientPort,
) -> Callable:
    """캐늭터 Subagent 녾드 생성"""

    async def character_node(state: dict) -> dict:
        query = state["query"]

        # LLM윌로 폐Ʞ묌 칎테고늬 추출
        category = await extract_waste_category(llm, query)

        # gRPC 혞출
        character = await character_client.get_character_by_waste_category(
            category
        )

        return {
            "character_context": character.__dict__ if character else None,
        }

    return character_node

4. 의졎성 죌입

# setup/dependencies.py
from functools import lru_cache

@lru_cache
def get_character_client() -> CharacterClientPort:
    settings = get_settings()
    return CharacterGrpcClient(
        host=settings.character_grpc_host,
        port=settings.character_grpc_port,
    )

async def cleanup():
    """애플늬쌀읎션 종료 시 늬소슀 정늬"""
    client = get_character_client()
    await client.close()

スコア

総合スコア

60/100

リポゞトリの品質指暙に基づく評䟡

✓SKILL.md

SKILL.mdファむルが含たれおいる

+20
✓LICENSE

ラむセンスが蚭定されおいる

+10
○説明文

100文字以䞊の説明がある

0/10
○人気

GitHub Stars 100以䞊

0/15
○最近の掻動

3ヶ月以内に曎新がある

0/10
○フォヌク

10回以䞊フォヌクされおいる

0/5
✓Issue管理

オヌプンIssueが50未満

+5
✓蚀語

プログラミング蚀語が蚭定されおいる

+5
○タグ

1぀以䞊のタグが蚭定されおいる

0/5

レビュヌ

💬

レビュヌ機胜は近日公開予定です