-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessage.go
64 lines (53 loc) · 1.36 KB
/
message.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
package babex
import (
"context"
"encoding/json"
"github.com/opentracing/opentracing-go"
)
type RawMessage interface {
Ack() error
Nack() error
}
type Message struct {
Exchange string
Key string
Chain Chain
Data json.RawMessage
Headers map[string]interface{}
Config []byte
Meta map[string]string
InitialMessage *InitialMessage
RawMessage RawMessage
Context context.Context
Span opentracing.Span
done []MiddlewareDone
}
func NewMessage(initialMessage *InitialMessage, exchange, key string) *Message {
return &Message{
Exchange: exchange,
Key: key,
Chain: initialMessage.Chain,
Data: initialMessage.Data,
Config: initialMessage.Config,
Meta: initialMessage.Meta,
InitialMessage: initialMessage,
Context: context.Background(),
}
}
func (m Message) Ack() error {
return m.RawMessage.Ack()
}
func (m Message) Nack() error {
return m.RawMessage.Nack()
}
type InitialMessage struct {
Chain Chain `json:"chain"`
Data json.RawMessage `json:"data"`
Config json.RawMessage `json:"config"`
Meta map[string]string `json:"meta"`
Catch Chain `json:"catch"`
}
// DataAll is container for total number of multiple-sent messages and shoud be placed in `data` key of a message.
type DataAll struct {
All int `json:"all"`
}