-
Notifications
You must be signed in to change notification settings - Fork 3
/
propagation.go
66 lines (56 loc) · 1.68 KB
/
propagation.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
package rocketmq
import (
"github.com/apache/rocketmq-client-go/v2/primitive"
"go.opentelemetry.io/otel/propagation"
)
type MessageTextMapCarrier struct {
msg *primitive.Message
}
var _ propagation.TextMapCarrier = &MessageTextMapCarrier{}
// Get returns the value associated with the passed key.
func (carrier *MessageTextMapCarrier) Get(key string) string {
//for i := 0; i < len(carrier.msg.); i++ {
// header := carrier.msg.Headers[i]
// if strings.Compare("md-"+key, header.Key) == 0 {
// return string(header.Value)
// }
//}
return ""
}
// Set stores the key-value pair.
func (carrier *MessageTextMapCarrier) Set(key string, value string) {
//carrier.msg.WithProperty(key, value)
//carrier.msg.Headers = append(carrier.msg.Headers, kafka.Header{
// Key: "md-" + key,
// Value: []byte(value),
//})
}
// Keys lists the keys stored in this carrier.
func (carrier *MessageTextMapCarrier) Keys() []string {
return nil
}
type MessageExtTextMapCarrier struct {
msg *primitive.MessageExt
}
// Get returns the value associated with the passed key.
func (carrier *MessageExtTextMapCarrier) Get(key string) string {
//for i := 0; i < len(carrier.msg.); i++ {
// header := carrier.msg.Headers[i]
// if strings.Compare("md-"+key, header.Key) == 0 {
// return string(header.Value)
// }
//}
return ""
}
// Set stores the key-value pair.
func (carrier *MessageExtTextMapCarrier) Set(key string, value string) {
//carrier.msg.WithProperty(key, value)
//carrier.msg.Headers = append(carrier.msg.Headers, kafka.Header{
// Key: "md-" + key,
// Value: []byte(value),
//})
}
// Keys lists the keys stored in this carrier.
func (carrier *MessageExtTextMapCarrier) Keys() []string {
return nil
}