-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathoptions.go
42 lines (35 loc) · 953 Bytes
/
options.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
package amqp
import (
"context"
"fmt"
"time"
"github.com/satori/go.uuid"
"github.com/streadway/amqp"
)
const (
MaxMessagePriority = 9
MinMessagePriority = 0
)
const (
defaultWaitDeadline = time.Second * 5
defaultEventBuffer = 1
defaultWorkers = 1
defaultContentType = "application/json"
)
type (
// Function, that changes message before publishing.
PublishingBefore func(context.Context, *amqp.Publishing)
// Function, that changes message before delivering.
DeliveryBefore func(context.Context, *amqp.Delivery) context.Context
// Function, that changes error, which caused on incorrect handling.
// Common use-case: debugging.
ErrorBefore func(amqp.Delivery, error) error
)
// CommonTyper prints go-style type of value.
func CommonTyper(v interface{}) string {
return fmt.Sprintf("%T", v)
}
// CommonMessageIdBuilder builds new UUID as message Id.
func CommonMessageIdBuilder() string {
return uuid.NewV4().String()
}