resty

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.6.4

type Client = resty.Client

Client ...

type Config

type Config struct {
	// Debug 开关
	Debug bool `json:"debug" toml:"debug"` // debug开关
	// 指标采集开关
	EnableMetric bool `json:"enableMetric" toml:"enableMetric"` // 指标采集开关
	// 链路追踪开关
	EnableTrace bool `json:"enableTrace" toml:"enableTrace"` // 链路开关
	// 失败重试次数
	RetryCount int `json:"retryCount" toml:"retryCount"` // 重试次数
	// 失败重试的间隔时间
	RetryWaitTime time.Duration `json:"retryWaitTime" toml:"retryWaitTime"` // 重试间隔时间
	// 失败重试的最贱等待时间
	RetryMaxWaitTime time.Duration `json:"retryMaxWaitTime" toml:"retryMaxWaitTime"` // 重试最大间隔时间
	// 目标服务地址
	Addr string `json:"addr" toml:"addr"` // 目标地址
	// 请求超时时间
	Timeout time.Duration `json:"timeout" toml:"timeout" `
	// 收到响应以后是否立即关闭连接
	CloseConnection bool `json:"closeConnection" toml:"closeConnection" `
	// 慢日志阈值
	SlowThreshold time.Duration `json:"slowThreshold" toml:"slowThreshold"` // slowlog 时间阈
	// 访问日志开关
	EnableAccessLog bool `json:"enableAccessLog" toml:"enableAccessLog"`
	// 熔断降级
	EnableSentinel bool `json:"enableSentinel" toml:"enableSentinel"`
	// 重试
	RetryCondition resty.RetryConditionFunc `json:"-" toml:"-"`

	// 配置名称
	Name string `json:"name"`
	// contains filtered or unexported fields
}

Config options

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 返回默认配置

func RawConfig

func RawConfig(key string) *Config

RawConfig 返回配置

func StdConfig

func StdConfig(name string) *Config

StdConfig 返回标准配置

func (*Config) Build

func (config *Config) Build() (*resty.Client, error)

func (*Config) MustBuild

func (c *Config) MustBuild() *resty.Client

MustBuild panics when error found.

func (*Config) MustSingleton added in v0.11.0

func (config *Config) MustSingleton() *Client

MustSingleton panics when error found.

func (*Config) Singleton added in v0.11.0

func (config *Config) Singleton() (*Client, error)

Singleton returns a singleton client conn.

Jump to

Keyboard shortcuts

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