Documentation ¶
Index ¶
- Constants
- Variables
- func ConstantBackOff(_ int) time.Duration
- func ExponentialBackoff(i int) time.Duration
- func HystrixConfigureCommand(configName string, config hystrix.CommandConfig)
- func LinearBackoff(i int) time.Duration
- func NewRequestOptions() *requestOptions
- func SetDefaultTokenManager(tokenManager TokenManager)
- type BackoffStrategy
- type Client
- func (c *Client) Delete(url string, reqOptions ...*requestOptions) (*goreq.Response, error)
- func (c *Client) Get(url string, reqOptions ...*requestOptions) (*goreq.Response, error)
- func (c *Client) Post(url string, body interface{}, reqOptions ...*requestOptions) (*goreq.Response, error)
- func (c *Client) Put(url string, body interface{}, reqOptions ...*requestOptions) (*goreq.Response, error)
- type ClientOptions
- type HTTP
- type HystrixConfig
- type OAuthTokenManager
- type Token
- type TokenManager
- type TokenOptions
Constants ¶
View Source
const ( DefaultClientTimeout = 20 * time.Second DefaultClientMaxRetries = 2 DefaultContentType = "application/json" )
View Source
const ( DefaultTokenMaxRetries = 2 DefaultTokenClientTimeout = 1 * time.Second )
Variables ¶
View Source
var TokenExpiredError = errors.New("Token expired")
Functions ¶
func ConstantBackOff ¶
ConstantBackOff always returns 30 Millisecond
func ExponentialBackoff ¶
ExponentialBackoff returns ever increasing backoffs by a power of 2 in seconds
func HystrixConfigureCommand ¶
func HystrixConfigureCommand(configName string, config hystrix.CommandConfig)
ConfigureCommand applies settings for a circuit
func LinearBackoff ¶
LinearBackoff returns increasing durations, each a second longer than the last n seconds where n is the retry number
func NewRequestOptions ¶
func NewRequestOptions() *requestOptions
func SetDefaultTokenManager ¶
func SetDefaultTokenManager(tokenManager TokenManager)
Types ¶
type BackoffStrategy ¶
BackoffStrategy is used to determine how long a retry request should wait until attempted
type Client ¶
type Client struct { TokenManager TokenManager Options ClientOptions // contains filtered or unexported fields }
func NewClient ¶
func NewClient(options ...ClientOptions) *Client
func NewClientCustom ¶
func NewClientCustom(tokenManager TokenManager, options ClientOptions) *Client
type ClientOptions ¶
type ClientOptions struct { ContentType string Timeout time.Duration Backoff BackoffStrategy MaxRetries int ShowDebug bool HystrixConfig *HystrixConfig }
func NewClientOptions ¶
func NewClientOptions(timeout time.Duration, debug bool, maxRetries int, hystrixConfigName string, backoff ...BackoffStrategy) ClientOptions
type HTTP ¶
func NewHttpError ¶
type HystrixConfig ¶
type HystrixConfig struct { Name string // contains filtered or unexported fields }
func NewHystrixConfig ¶
func NewHystrixConfig(configName string) *HystrixConfig
type OAuthTokenManager ¶
type OAuthTokenManager struct { TokenEndPoint string ClientId string ClientSecret string Authorization string Options TokenOptions // contains filtered or unexported fields }
func NewTokenManager ¶
func NewTokenManager(tokenEndPoint string, clientId string, clientSecret string, options ...TokenOptions) *OAuthTokenManager
func (*OAuthTokenManager) GetToken ¶
func (tm *OAuthTokenManager) GetToken() (*Token, error)
func (*OAuthTokenManager) ResetToken ¶
func (tm *OAuthTokenManager) ResetToken()
type TokenManager ¶
type TokenOptions ¶
type TokenOptions struct { Timeout time.Duration Backoff BackoffStrategy MaxRetries int ShowDebug bool HystrixConfig *HystrixConfig }
func NewTokenOptions ¶
func NewTokenOptions(timeout time.Duration, debug bool, maxRetries int, circuitName string, backoff ...BackoffStrategy) TokenOptions
Click to show internal directories.
Click to hide internal directories.