Пример #1
0
// New will return a pointer to a new initialized service client.
func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, options ...func(*Client)) *Client {
	svc := &Client{
		Config:     cfg,
		ClientInfo: info,
		Handlers:   handlers,
	}

	switch retryer, ok := cfg.Retryer.(request.Retryer); {
	case ok:
		svc.Retryer = retryer
	case cfg.Retryer != nil && cfg.Logger != nil:
		s := fmt.Sprintf("WARNING: %T does not implement request.Retryer; using DefaultRetryer instead", cfg.Retryer)
		cfg.Logger.Log(s)
		fallthrough
	default:
		maxRetries := aws.IntValue(cfg.MaxRetries)
		if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries {
			maxRetries = 3
		}
		svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries}
	}

	svc.AddDebugHandlers()

	for _, option := range options {
		option(svc)
	}

	return svc
}
Пример #2
0
func init() {
	initClient = func(c *client.Client) {
		if c.Config.MaxRetries == nil || aws.IntValue(c.Config.MaxRetries) == aws.UseServiceDefaultRetries {
			c.Retryer = client.DefaultRetryer{NumMaxRetries: 10}
		}

		c.Handlers.Build.PushBack(disableCompression)
		c.Handlers.Unmarshal.PushFront(validateCRC32)
	}
}
Пример #3
0
// New will return a pointer to a new initialized service client.
func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, options ...func(*Client)) *Client {
	svc := &Client{
		Config:     cfg,
		ClientInfo: info,
		Handlers:   handlers,
	}

	maxRetries := aws.IntValue(cfg.MaxRetries)
	if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries {
		maxRetries = 3
	}
	svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries}

	svc.AddDebugHandlers()

	for _, option := range options {
		option(svc)
	}

	return svc
}
// MaxRetries returns the number of maximum returns the service will use to make
// an individual API request.
func (d DefaultRetryer) MaxRetries() uint {
	if aws.IntValue(d.Service.Config.MaxRetries) < 0 {
		return d.DefaultMaxRetries
	}
	return uint(aws.IntValue(d.Service.Config.MaxRetries))
}
Пример #5
0
// MaxRetries returns the number of maximum returns the service will use to make
// an individual API request.
func (s *Service) MaxRetries() uint {
	if aws.IntValue(s.Config.MaxRetries) < 0 {
		return s.DefaultMaxRetries
	}
	return uint(aws.IntValue(s.Config.MaxRetries))
}