This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
forked from a8m/kinesis-producer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
74 lines (59 loc) · 1.7 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package producer
import (
"fmt"
)
type ErrStoppedProducer struct {
UserRecord
}
func (e *ErrStoppedProducer) Error() string {
return "Unable to Put record. Producer is already stopped"
}
type ErrIllegalPartitionKey struct {
UserRecord
}
func (e *ErrIllegalPartitionKey) Error() string {
return fmt.Sprintf("Invalid parition key. Length must be at least 1 and at most 256: %s", e.PartitionKey())
}
type ErrRecordSizeExceeded struct {
UserRecord
}
func (e *ErrRecordSizeExceeded) Error() string {
return fmt.Sprintf("Data must be less than or equal to 1MB in size: %d", e.Size())
}
// Failure record type for failures from Kinesis PutRecords request
type FailureRecord struct {
Err error
// The PartitionKey that was used in the kinesis.PutRecordsRequestEntry
PartitionKey string
// The ExplicitHashKey that was used in the kinesis.PutRecordsRequestEntry. Will be the
// empty string if nil
ExplicitHashKey string
// UserRecords that were contained in the failed aggregated record request
UserRecords []UserRecord
}
func (e *FailureRecord) Error() string {
return e.Err.Error()
}
type DrainError struct {
Err error
// UserRecords in the buffer when drain attempt was made
UserRecords []UserRecord
}
func (e *DrainError) Error() string {
return e.Err.Error()
}
type ShardBucketError struct {
UserRecord
}
func (s *ShardBucketError) Error() string {
if hk := s.ExplicitHashKey(); hk != nil {
return fmt.Sprintf("ExplicitHashKey outside shard key range: %s", hk.String())
}
return fmt.Sprintf("PartitionKey outside shard key range: %s", s.PartitionKey())
}
type ShardRefreshError struct {
Err error
}
func (s *ShardRefreshError) Error() string {
return fmt.Sprintf("ShardRefreshError: %v", s.Err)
}