-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
68 lines (54 loc) · 1.46 KB
/
types.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
package sqstransport
import (
"context"
"errors"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/go-kit/kit/transport"
)
type (
Client interface {
ReceiveMessage(ctx context.Context,
params *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)
}
RequestFunc func(context.Context, types.Message) context.Context
DecodeRequestFunc func(context.Context, types.Message) (request interface{}, err error)
ResponseFunc func(ctx context.Context, msg types.Message, response interface{}) context.Context
AfterBatchFunc func(ctx context.Context)
InputFactory func() (params *sqs.ReceiveMessageInput, optFns []func(*sqs.Options))
Runner interface {
Run(func())
}
)
// HandlerError is used for triggering the error handler when the handler returns an error.
type HandlerError struct {
Err error
Request interface{}
Msg types.Message
}
func (obj *HandlerError) Error() string {
if obj.Err == nil {
return defaultHandlerErrorMsh
}
return obj.Err.Error()
}
type DecoderError struct {
Err error
Msg types.Message
}
func (obj *DecoderError) Error() string {
if obj.Err == nil {
return defaultDecoderErrorMsh
}
return obj.Err.Error()
}
const (
defaultHandlerErrorMsh = "HandlerError"
defaultDecoderErrorMsh = "DecoderError"
)
var (
ErrAlreadyStarted = errors.New("already started")
)
type (
transportErrorHandler = transport.ErrorHandler
)