Skip to content

Commit

Permalink
feat: update query request topic naming
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hung <[email protected]>
  • Loading branch information
Chris Hung committed Oct 21, 2022
1 parent aae9db3 commit 3608a9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions clients/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

const (
QueryRequestTopic = "QueryRequestTopic"
QueryRequestTopicPrefix = "QueryRequestTopicPrefix"
QueryResponseTopic = "QueryResponseTopic"
CommandRequestTopicPrefix = "CommandRequestTopicPrefix"
CommandResponseTopic = "CommandResponseTopic"
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *CommandClient) AllDeviceCoreCommands(ctx context.Context, offset int, l

queryParams := map[string]string{common.Offset: strconv.Itoa(offset), common.Limit: strconv.Itoa(limit)}
requestEnvelope := types.NewMessageEnvelopeForRequest(nil, queryParams)
requestTopic := strings.Join([]string{c.topics[QueryRequestTopic], common.All}, "/")
requestTopic := strings.Join([]string{c.topics[QueryRequestTopicPrefix], common.All}, "/")
err := c.messageBus.Publish(requestEnvelope, requestTopic)
if err != nil {
return responses.MultiDeviceCoreCommandsResponse{}, edgexErr.NewCommonEdgeXWrapper(err)
Expand Down Expand Up @@ -135,7 +135,7 @@ func (c *CommandClient) DeviceCoreCommandsByDeviceName(ctx context.Context, devi
}

requestEnvelope := types.NewMessageEnvelopeForRequest(nil, nil)
requestTopic := strings.Join([]string{c.topics[QueryRequestTopic], deviceName}, "/")
requestTopic := strings.Join([]string{c.topics[QueryRequestTopicPrefix], deviceName}, "/")
err := c.messageBus.Publish(requestEnvelope, requestTopic)
if err != nil {
return responses.DeviceCoreCommandResponse{}, edgexErr.NewCommonEdgeXWrapper(err)
Expand Down
8 changes: 4 additions & 4 deletions clients/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (m mockMessageClient) Disconnect() error {
func TestCommandClient_AllDeviceCoreCommands(t *testing.T) {
mockMessageBus := mockMessageClient{signal: make(chan struct{})}
topics := map[string]string{
QueryRequestTopic: testQueryRequestTopic,
QueryResponseTopic: testQueryResponseTopic,
QueryRequestTopicPrefix: testQueryRequestTopic,
QueryResponseTopic: testQueryResponseTopic,
}

client, err := NewCommandClient(mockMessageBus, topics, 10*time.Second)
Expand Down Expand Up @@ -100,8 +100,8 @@ func TestCommandClient_AllDeviceCoreCommands(t *testing.T) {
func TestCommandClient_DeviceCoreCommandsByDeviceName(t *testing.T) {
mockMessageBus := mockMessageClient{signal: make(chan struct{})}
topics := map[string]string{
QueryRequestTopic: testQueryRequestTopic,
QueryResponseTopic: testQueryResponseTopic,
QueryRequestTopicPrefix: testQueryRequestTopic,
QueryResponseTopic: testQueryResponseTopic,
}

client, err := NewCommandClient(mockMessageBus, topics, 10*time.Second)
Expand Down

0 comments on commit 3608a9e

Please sign in to comment.