Documentation ¶
Index ¶
- func SetServiceDiscoveryCfg(cfg string)
- func SetSettingProvider(p SettingProvider)
- func SetupClient(source, upstreamSetting, discoveryInfo string)
- type Client
- type DefaultClient
- func (c DefaultClient) Do(ctx context.Context, uri, method string, param interface{}, resp interface{}) (err error)
- func (c DefaultClient) DoRaw(ctx context.Context, uri, method string, param interface{}) (resp []byte, code int, err error)
- func (c DefaultClient) SetEndpointSetting(setting *EndpointSetting) (err error)
- func (c DefaultClient) SetEndpointSettings(settings []*EndpointSetting) (err error)
- type EndpointSetting
- type FileSettingProvider
- type Retry
- type SettingProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetServiceDiscoveryCfg ¶
func SetServiceDiscoveryCfg(cfg string)
SetServiceDiscoveryCfg setup service discovery configuration
func SetSettingProvider ¶
func SetSettingProvider(p SettingProvider)
SetSettingProvider setup endpoint setting provider
func SetupClient ¶
func SetupClient(source, upstreamSetting, discoveryInfo string)
SetupClient initializes global api client setting
Types ¶
type Client ¶
type Client interface { Do(ctx context.Context, uri, method string, param interface{}, resp interface{}) (err error) DoRaw(ctx context.Context, uri, method string, param interface{}) (resp []byte, code int, err error) }
Client the new client that supports circuitbreak, client-side lb, metrics etc.
func NewClientWithSD ¶
NewClientWithSD returns client with given host
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient provides a default implementation of ApiClient
func (DefaultClient) Do ¶
func (c DefaultClient) Do(ctx context.Context, uri, method string, param interface{}, resp interface{}) (err error)
Do delegates the request to endpoint client
func (DefaultClient) DoRaw ¶
func (c DefaultClient) DoRaw(ctx context.Context, uri, method string, param interface{}) (resp []byte, code int, err error)
DoRaw delegates the request to endpoint client, supports byte[] as param, and returns []byte, status code
func (DefaultClient) SetEndpointSetting ¶
func (c DefaultClient) SetEndpointSetting(setting *EndpointSetting) (err error)
SetEndpointSetting dynamically changes setting (NOT IMPL YET)
func (DefaultClient) SetEndpointSettings ¶
func (c DefaultClient) SetEndpointSettings(settings []*EndpointSetting) (err error)
SetEndpointSettings dynamically changes setting (NOT IMPL YET)
type EndpointSetting ¶
type EndpointSetting struct { URI string `yaml:"uri"` Method string `yaml:"method"` CBConfig hystrix.CommandConfig `yaml:"hystrix"` }
EndpointSetting hystrix & retry settings for endpoint
type FileSettingProvider ¶
type FileSettingProvider struct {
// contains filtered or unexported fields
}
FileSettingProvider implements a file-based provider.
func NewFileSettingProvider ¶
func NewFileSettingProvider(path string) (*FileSettingProvider, error)
NewFileSettingProvider creates a new setting provider with given yaml file.
func (FileSettingProvider) GetSettings ¶
func (p FileSettingProvider) GetSettings(target string) (map[string]EndpointSetting, error)
GetSettings implements SettingProvider.GetSettings
func (FileSettingProvider) SetHandler ¶
func (p FileSettingProvider) SetHandler(handler func(setting EndpointSetting) error)
SetHandler implements SettingProvider.SetHandler
type SettingProvider ¶
type SettingProvider interface { GetSettings(target string) (map[string]EndpointSetting, error) SetHandler(handler func(setting EndpointSetting) error) }
SettingProvider provides endpoint settings for a given uri target.