From 07e2f5532fb9cdc462a6ec5e0375af5e5837b96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 31 May 2024 12:33:36 +0800 Subject: [PATCH] =?UTF-8?q?request=20=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define/request.go | 27 +++++++++++++++++++++++---- go.mod | 2 ++ go.sum | 4 ++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/define/request.go b/define/request.go index 1df5bfe..21090c7 100644 --- a/define/request.go +++ b/define/request.go @@ -13,8 +13,27 @@ package define // // Date : 17:10 2024/5/24 type Request struct { - Body map[string]any `json:"body"` // 请求Body - Header map[string]string `json:"header"` // 请求Header - Cookie map[string]string `json:"cookie"` // 请求Cookie - Query map[string]string `json:"query"` // 请求query + Body map[string]any `json:"body"` // 请求Body + Header map[string]string `json:"header"` // 请求Header + Cookie map[string]string `json:"cookie"` // 请求Cookie + Query map[string]string `json:"query"` // 请求query + FullUrl string `json:"full_url"` // 完整的请求URL + ContentType string `json:"content_type"` // 请求类型 + Method string `json:"method"` // 请求方法 + DataField string `json:"data_field"` // 数据字段 + CodeField string `json:"code_field"` // 业务状态码字段 + MessageField string `json:"message_field"` // code描述字段 + RetryRule *RequestRetryRule `json:"retry_rule"` // 重试规则 +} + +// RequestRetryRule 重试规则 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:26 2024/5/31 +type RequestRetryRule struct { + RetryCount int64 `json:"retry_count"` // 重试次数 + RetryTimeInterval int64 `json:"retry_time_interval"` // 重试的时间间隔 1 - 10 之间, 单位毫秒 + RetryHttpCodeList []int64 `json:"retry_http_code_list"` // 哪些http状态码需要重试 + RetryBusinessCodeList []string `json:"retry_business_code_list"` // 哪些业务状态码需要重试 } diff --git a/go.mod b/go.mod index 79f62fe..b461607 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,7 @@ go 1.22.3 require ( github.com/go-resty/resty/v2 v2.13.1 // indirect + go.uber.org/multierr v1.10.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/net v0.25.0 // indirect ) diff --git a/go.sum b/go.sum index 8739277..ddb1a3c 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,10 @@ github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=