httpDiscover

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	EtcdAddrs  []string
	Env        string
	ServerName string
	// 超时时间, 单位秒
	Timeout int
	// 重试次数
	RetryCount int
	// 重试间隔时间, 单位秒. 会自动加上[10,100)毫秒的随机数, 同时重试时间会指数级增加.
	RetryDelay int
}

type Result

type Result struct {
	Code int         `json:"code"` // 业务码
	Msg  string      `json:"msg"`  // 描述信息
	Data interface{} `json:"data"` // 返回值
}

func NewResult

func NewResult(data interface{}) *Result

func (Result) Error

func (r Result) Error() string

type RetryVerify

type RetryVerify func(body []byte) (shouldRetry bool)

type ServiceClient

type ServiceClient struct {
	// contains filtered or unexported fields
}

func CreateSpecialHttpClient

func CreateSpecialHttpClient(rs ...Resource) *ServiceClient

func New

func New(rs ...Resource) *ServiceClient

func (*ServiceClient) DeleteJson

func (s *ServiceClient) DeleteJson(ctx mux.Context, serviceName string, urlPath string, params interface{}, result interface{}) (code int, err error)

func (*ServiceClient) GetJson

func (s *ServiceClient) GetJson(ctx mux.Context, serviceName string, urlPath string, params interface{}, result interface{}) (code int, err error)

func (*ServiceClient) PatchJson

func (s *ServiceClient) PatchJson(ctx mux.Context, serviceName string, urlPath string, params interface{}, result interface{}) (code int, err error)

func (*ServiceClient) PostJson

func (s *ServiceClient) PostJson(ctx mux.Context, serviceName string, urlPath string, params interface{}, result interface{}) (code int, err error)

func (*ServiceClient) PutJson

func (s *ServiceClient) PutJson(ctx mux.Context, serviceName string, urlPath string, params interface{}, result interface{}) (code int, err error)

Jump to

Keyboard shortcuts

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