Skip to content

Commit

Permalink
feat: adding destination id (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr authored Apr 22, 2024
1 parent aa5a8e7 commit ee57769
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/stream/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
mapKeyRoutingKey = "routingKey"
mapKeyWorkspaceID = "workspaceID"
mapKeySourceID = "sourceID"
mapKeyDestinationID = "destinationID"
mapKeyRequestIP = "requestIP"
mapKeyReceivedAt = "receivedAt"
mapKeyUserID = "userID"
Expand All @@ -33,6 +34,7 @@ type MessageProperties struct {
SourceID string `json:"sourceID" validate:"required"`
ReceivedAt time.Time `json:"receivedAt" validate:"required"`
RequestIP string `json:"requestIP" validate:"required"`
DestinationID string `json:"destinationID"` // optional
UserID string `json:"userID,omitempty"` // optional
SourceJobRunID string `json:"sourceJobRunID,omitempty"` // optional
SourceTaskRunID string `json:"sourceTaskRunID,omitempty"` // optional
Expand All @@ -53,6 +55,7 @@ func FromMapProperties(properties map[string]string) (MessageProperties, error)
RequestIP: properties[mapKeyRequestIP],
UserID: properties[mapKeyUserID],
SourceID: properties[mapKeySourceID],
DestinationID: properties[mapKeyDestinationID],
ReceivedAt: receivedAt,
SourceJobRunID: properties[mapKeySourceJobRunID],
SourceTaskRunID: properties[mapKeySourceTaskRunID],
Expand All @@ -68,6 +71,7 @@ func ToMapProperties(properties MessageProperties) map[string]string {
mapKeyWorkspaceID: properties.WorkspaceID,
mapKeyUserID: properties.UserID,
mapKeySourceID: properties.SourceID,
mapKeyDestinationID: properties.DestinationID,
mapKeyRequestIP: properties.RequestIP,
mapKeyReceivedAt: properties.ReceivedAt.Format(time.RFC3339Nano),
mapKeySourceJobRunID: properties.SourceJobRunID,
Expand Down
4 changes: 4 additions & 0 deletions go/stream/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestMessage(t *testing.T) {
"workspaceID": "workspaceID",
"userID": "userID",
"sourceID": "sourceID",
"destinationID": "destinationID",
"requestIP": "10.29.13.20",
"receivedAt": time.Date(2024, 8, 1, 0o2, 30, 50, 200, time.UTC).Format(time.RFC3339Nano),
"sourceJobRunID": "sourceJobRunID",
Expand All @@ -34,6 +35,7 @@ func TestMessage(t *testing.T) {
WorkspaceID: "workspaceID",
UserID: "userID",
SourceID: "sourceID",
DestinationID: "destinationID",
RequestIP: "10.29.13.20",
ReceivedAt: time.Date(2024, 8, 1, 0o2, 30, 50, 200, time.UTC),
SourceJobRunID: "sourceJobRunID",
Expand Down Expand Up @@ -62,6 +64,7 @@ func TestMessage(t *testing.T) {
"workspaceID": "workspaceID",
"userID": "userID",
"sourceID": "sourceID",
"destinationID": "destinationID",
"receivedAt": "2024-08-01T02:30:50.0000002Z",
"requestIP": "10.29.13.20",
"sourceJobRunID": "sourceJobRunID",
Expand All @@ -87,6 +90,7 @@ func TestMessage(t *testing.T) {
WorkspaceID: "workspaceID",
UserID: "userID",
SourceID: "sourceID",
DestinationID: "destinationID",
RequestIP: "10.29.13.20",
ReceivedAt: time.Date(2024, 8, 1, 0o2, 30, 50, 200, time.UTC),
SourceJobRunID: "sourceJobRunID",
Expand Down

0 comments on commit ee57769

Please sign in to comment.