logo
Public
0
0
WeChat Login
feat: 新增arpc代码生成器及quick扩展模块

arpc 使用说明

arpc 用于根据 .service 文件生成 ARPC 的客户端/服务端包装代码。

安装

go install github.com/lesismal/arpc/cmd/arpc@latest

语法

package myservice import "github.com/your/module/types" service HelloService { Hello(string) (string, error) Add(*string, int) (*string, error) go AsyncProcess(types.Request) (types.Response, error) Notify(types.Event) }

生成

arpc -out ./gen -package myservice -test hello.service

生成规则

  • 路由名固定为 /<Service>.<Method>
  • 有参数的请求会封装成 ServiceMethodRequest 结构体并通过 Context.Bind 解析。
  • 返回值只允许 (T, error) 或无返回值。
  • go 前缀表示服务端异步处理(注册时设置 async=true)。