-
Notifications
You must be signed in to change notification settings - Fork 30
/
messages.go
59 lines (51 loc) · 1.68 KB
/
messages.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
package payments
import (
"encoding/json"
"fmt"
"time"
"github.com/google/uuid"
)
// WorkerConfig defines the settlement worker configuration structure
type WorkerConfig struct {
PayoutID string `json:"payoutId"`
ConsumerGroup string `json:"consumerGroup"`
Stream string `json:"stream"`
Count int `json:"count"`
}
// MarshalBinary implements encoding.BinaryMarshaler required for go-redis
func (wc WorkerConfig) MarshalBinary() (data []byte, err error) {
bytes, err := json.Marshal(wc)
if err != nil {
return nil, fmt.Errorf("event message: error marshalling binary: %w", err)
}
return bytes, nil
}
// prepareWrapper defines the settlement worker prepare message structure
type prepareWrapper struct {
ID uuid.UUID `json:"id"`
Timestamp time.Time `json:"timestamp"`
Body string `json:"body"`
}
// MarshalBinary implements encoding.BinaryMarshaler required for go-redis
func (pw prepareWrapper) MarshalBinary() (data []byte, err error) {
bytes, err := json.Marshal(pw)
if err != nil {
return nil, fmt.Errorf("event message: error marshalling binary: %w", err)
}
return bytes, nil
}
// submitWrapper defines the settlement worker submit message structure
type submitWrapper struct {
ID uuid.UUID `json:"id"`
Timestamp time.Time `json:"timestamp"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
}
// MarshalBinary implements encoding.BinaryMarshaler required for go-redis
func (sw submitWrapper) MarshalBinary() (data []byte, err error) {
bytes, err := json.Marshal(sw)
if err != nil {
return nil, fmt.Errorf("event message: error marshalling binary: %w", err)
}
return bytes, nil
}