rpctool

package
v0.0.0-...-1c978d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package rpctool 把 RPC 接口暴露为能力。

RPC 框架各异(kitex 泛化调用、gRPC 反射、thrift 等),本包不绑定任何 一种,只定义 Invoker 契约:接入方实现"service/method + JSON 请求 → JSON 响应"的泛化调用,用 source.Static 打包成源即可进目录:

caps := []capability.Capability{
    rpctool.New("order", rpctool.Method{...}, myKitexInvoker),
}
catalog.AddSource(ctx, source.Static("order-rpc", caps...), true, 0)

kitex:genericclient + generic.JSONThriftGeneric 天然满足该契约; gRPC:reflection + protojson 即可实现。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(namespace string, m Method, inv Invoker) capability.Capability

New 把一个 RPC 方法包装成能力,namespace 为所属 source 名。

Types

type Invoker

type Invoker interface {
	Invoke(ctx context.Context, service, method, reqJSON string) (respJSON string, err error)
}

Invoker 是 RPC 泛化调用的最小契约。

type Method

type Method struct {
	Service     string
	Method      string
	Name        string // 工具名,默认 service_method
	Description string
	Risk        capability.Risk
	// Params 描述请求体字段;为 nil 时模型直接产出整个请求 JSON。
	Params map[string]*schema.ParameterInfo
}

Method 声明一个要暴露给模型的 RPC 方法。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL