Documentation
¶
Index ¶
- Constants
- func CachedFallback(service, uri string, params ...map[string]any) func(error) (string, bool)
- func Call(service, uri string, op *Options) (result string, callErr error)
- func CallPageT[T any](service, uri string, op *Options) vo.ResponsePage[T]
- func CallResultT[T any](service, uri string, op *Options) models.Result[T]
- func CallT[T any](service, uri string, op *Options) vo.Response[T]
- type Options
Constants ¶
const ( CONTENT_TYPE_FORM = "x-form" CONTENT_TYPE_JSON = "json" CONTENT_TYPE_RESTFUL = "restful" CONTENT_TYPE_FILE = "file" )
Variables ¶
This section is empty.
Functions ¶
func CachedFallback ¶
CachedFallback supplies the latest successful response when a downstream call fails. It is opt-in and therefore preserves existing fail-fast behavior.
func CallPageT ¶
func CallPageT[T any](service, uri string, op *Options) vo.ResponsePage[T]
CallPageT 调用微服务并解析 data.list/total/page/pageSize 分页响应。
func CallResultT ¶
CallResultT 调用使用 status/data/msg 协议的旧版微服务。
Types ¶
type Options ¶ added in v1.19.0
type Options struct {
Method string `json:"method"` //接口方法 GET|POST|PUT|DELETE
Protocol string `json:"protocol"` //协议 x-form|json|restful
Group string `json:"group"` //应用分组,用于nacos中分组,不传为当前nacos分组及默认分组
Header any `json:"header"` //额外的头部参数
Query any `json:"query"` //URL Query参数
Data any `json:"data"` //x-form Postform参数
Json any `json:"json"` //json或restful模式的body参数
Path map[string]string `json:"path"` //restful模式的路径参数
Files []grequests.FileUpload //文件上传数据
Retry bool `json:"retry"` //是否重试
// Timeout bounds the complete outbound request. Zero uses the framework default.
Timeout time.Duration `json:"timeout"`
Fallback func(error) (string, bool) `json:"-"`
CircuitKey string `json:"circuit_key"`
// CircuitFailures and CircuitOpenWindow override the safe defaults when set.
CircuitFailures int `json:"circuit_failures"`
CircuitOpenWindow time.Duration `json:"circuit_open_window"`
}