http

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

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 NewClient

func NewClient(host string) Client

NewClient returns client with given host, and uses sd by default

func NewClientWithSD

func NewClientWithSD(host string, useServiceDiscovery bool) Client

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 Retry

type Retry struct {
}

Retry retry policies

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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