返回 Skill 列表
extension
分类: 开发与工程无需 API Key

librpc

librpc - 微服务的gRPC框架。RpcServer和RpcClient提供了基础类。loadProto加载protobuf定义。createClientFactory构建类型化的服务客户端。hmacAuth提供认证支持。createTracer启用分布式追踪。用于服务间通信、构建gRPC服务以及创建服务客户端。

person作者: jakexiaohubgithub

librpc Skill

When to Use

  • Building gRPC service implementations
  • Creating clients for inter-service calls
  • Adding authentication to gRPC endpoints
  • Implementing distributed tracing across services

Key Concepts

RpcServer: Base server class for gRPC services with middleware support.

RpcClient: Base client class with connection management and error handling.

createClientFactory: Factory that creates typed service clients with optional logging and tracing.

Usage Patterns

Pattern 1: Create service server

import { RpcServer, createService } from "@copilot-ld/librpc";

const service = createService(MyServiceImpl, proto);
const server = new RpcServer([service], config);
await server.start();

Pattern 2: Create service client

import { createClientFactory } from "@copilot-ld/librpc";

const factory = createClientFactory(logger, tracer);
const agentClient = factory.createAgentClient("localhost", 50051);
const response = await agentClient.request(message);

Integration

Used by all services for gRPC communication. Works with libtype for message types.