@@ -12,21 +12,56 @@ import (
12
12
// The message is used to publish messages to the queue.
13
13
// Read the concept of message publishing in the documentation, here: TODO(bxcodec): Add link to the documentation
14
14
type Message struct {
15
- ID string `json:"id"`
16
- Action string `json:"action"`
17
- Topic string `json:"topic"`
18
- Data any `json:"data"`
19
- ContentType headerVal.ContentType `json:"-"`
20
- Timestamp time.Time `json:"timestamp"`
21
- Headers map [string ]interface {} `json:"-"`
22
- ServiceAgent headerVal.GoquServiceAgent `json:"-"`
15
+ // ID is the unique identifier for the message.
16
+ // This is set by the publisher to identify the message in the queue.
17
+ // The id is auto-generated by the the library if not provided.
18
+ ID string `json:"id"`
19
+ // Action is the action that will be performed on the message.
20
+ // This is set by the publisher to identify the action that will be performed on the message.
21
+ // For RabbitMQ, the action is the routing key.
22
+ Action string `json:"action"`
23
+ // Topic is the topic that the message will be published to.
24
+ // This is set by the publisher to identify the topic that the message will be published to.
25
+ // For RabbitMQ, the topic is the exchange name.
26
+ Topic string `json:"topic"`
27
+ // Data is the data that will be published to the queue.
28
+ // This is set by the publisher to identify the data that will be published to the queue.
29
+ // It should be a valid JSON object.
30
+ Data any `json:"data"`
31
+ // ContentType is the content type of the message.
32
+ // This is set by the publisher to identify the content type of the message.
33
+ // Default value is "application/json".
34
+ ContentType headerVal.ContentType `json:"-"`
35
+ // Timestamp is the timestamp of the message.
36
+ // This is set by the publisher to identify the timestamp of the message.
37
+ // Default value is the current time.
38
+ Timestamp time.Time `json:"timestamp"`
39
+ // Headers is the headers of the message.
40
+ // This is set by the publisher to identify the headers of the message.
41
+ // This library will provide extra headers values by default based on the library type.
42
+ // Don't use any prefix with :goqueue-, it will conflicted and overrided by the library.
43
+ Headers map [string ]interface {} `json:"-"`
44
+ // ServiceAgent is the service agent that will be used to publish the message.
45
+ // This is set by the publisher to identify the service agent that will be used to publish the message.
46
+ // This will be set by the library and override any value
47
+ ServiceAgent headerVal.GoquServiceAgent `json:"-"`
48
+ // SchemaVersion is the schema version of the message.
49
+ // This is set by the publisher to identify the schema version of the message.
50
+ // Default value is the library type.
51
+ // This will be set by the library and override any value
23
52
schemaVersion string
24
53
}
25
54
55
+ // SetSchemaVersion is a method to set the schema version of the message.
56
+ // This is used to set the schema version of the message.
57
+ // This will be set by the library and override any value
26
58
func (m * Message ) SetSchemaVersion (v string ) {
27
59
m .schemaVersion = v
28
60
}
29
61
62
+ // GetSchemaVersion is a method to get the schema version of the message.
63
+ // This is used to get the schema version of the message.
64
+ // This will be set by the library and override any value
30
65
func (m * Message ) GetSchemaVersion () string {
31
66
return m .schemaVersion
32
67
}
0 commit comments