httpclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCircuitBreaker

func GetCircuitBreaker(name string) *gobreaker.CircuitBreaker

GetCircuitBreaker returns a CircuitBreaker by name

func GetSelfServiceName

func GetSelfServiceName() string

func InitChildService

func InitChildService(cfg []map[string]interface{})

func InitCircuitBreaker

func InitCircuitBreaker(c []map[string]interface{})

InitCircuitBreaker 初始化熔断配置

{
   "default":{
       "maxRequests":1,
       "interval":1,
       "timeout":10,
       "failureRatio":1,
       "consecutiveFailures":100
   }
}

func InitSelfService

func InitSelfService(selfName string, closeBreaker bool)

InitSelfService selfName 本身服务名称 closeBreaker 子服务熔断开启 默认开启 ,true 关闭

func InjectSidecarHeader

func InjectSidecarHeader(req *http.Request, ServiceName string)

func InjectTrace

func InjectTrace(name string, tracer opentracing.Tracer, span opentracing.Span, req *http.Request)

Types

type Client

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

func New

func New(name string) *Client

func (*Client) Send

func (c *Client) Send(ctx context.Context, method string, path string, reqBody map[string]interface{}, result interface{}, irs ...InjectRequest) (err error)

type HttpServer

type HttpServer struct {
	SelfServiceName string                 `yaml:"self_service_name"`
	CloseBreaker    bool                   `yaml:"close_breaker"`
	BreakerCfg      map[string]interface{} `yaml:"breaker_cfg"`
	ChildServer     map[string]interface{} `yaml:"child_server"`
}

type InjectRequest

type InjectRequest func(*http.Request)

注入请求操作,如http 头注入

type Server

type Server struct {
	Name                 string  `mapstructure:"name"`
	Url                  string  `mapstructure:"url"`
	DiscoveryServiceName string  `mapstructure:"discovery_service_name"`
	DiscoveryTag         string  `mapstructure:"discovery_tag"`
	Timeout              float64 `mapstructure:"timeout"`
}

Jump to

Keyboard shortcuts

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