// NOTE: calls are totally synchronized for sanity func (s *StubClient) DescribeStream(input *kinesis.DescribeStreamInput) (*kinesis.DescribeStreamOutput, error) { s.Lock() defer s.Unlock() // always leave the last description in the stream. should never run out. if len(s.describe) == 0 { return nil, fmt.Errorf("ran out of shards. test over") } var shards []shard if len(s.describe) == 1 { shards = s.describe[0] } else { shards, s.describe = s.describe[0], s.describe[1:] } output := &kinesis.DescribeStreamOutput{ StreamDescription: &kinesis.StreamDescription{ HasMoreShards: aws.Bool(false), Shards: shardsToAws(shards...), }, } return output, nil }
} return } } if r.HTTPResponse == nil { // Add a dummy request response object to ensure the HTTPResponse // value is consistent. r.HTTPResponse = &http.Response{ StatusCode: int(0), Status: http.StatusText(int(0)), Body: ioutil.NopCloser(bytes.NewReader([]byte{})), } } // Catch all other request errors. r.Error = awserr.New("RequestError", "send request failed", err) r.Retryable = aws.Bool(true) // network errors are retryable } }} // ValidateResponseHandler is a request handler to validate service response. var ValidateResponseHandler = request.NamedHandler{"core.ValidateResponseHandler", func(r *request.Request) { if r.HTTPResponse.StatusCode == 0 || r.HTTPResponse.StatusCode >= 300 { // this may be replaced by an UnmarshalError handler r.Error = awserr.New("UnknownError", "unknown error", nil) } }} // AfterRetryHandler performs final checks to determine if the request should // be retried and how long to delay. var AfterRetryHandler = request.NamedHandler{"core.AfterRetryHandler", func(r *request.Request) { // If one of the other handlers already set the retry state