Skip to content

Commit

Permalink
Merge pull request #793 from lenny-intel/topic-constants
Browse files Browse the repository at this point in the history
feat: Add topic constants that will replace configured topics
  • Loading branch information
Lenny Goodell authored Feb 14, 2023
2 parents 1b561ae + 7d63dd3 commit 4a060e2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
38 changes: 38 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ const (
)

// Constants related to topics for Commanding via MessageBus
// TODO: Remove these once all services are using the constants in the next block
const (
CommandQueryRequestTopicKey = "CommandQueryRequestTopic"
CommandQueryRequestTopicPrefixKey = "CommandQueryRequestTopicPrefix"
Expand All @@ -324,3 +325,40 @@ const (
ExternalCommandResponseTopicPrefixKey = "CommandResponseTopicPrefix"
ResponseTopicPrefixKey = "ResponseTopicPrefix"
)

// MessageBus Topics
const (

// Common Topics
DefaultBaseTopic = "edgex" // Used if the base topic is not specified in MessageBus configuration
EventsPublishTopic = "events" // <ServiceType>/<DeviceServiceName>/<ProfileName>/<DeviceName>/<SourceName> are appended
ResponseTopic = "response" // <ServiceName>/<RequestId> are prepended
MetricsPublishTopic = "telemetry" // <ServiceName>/<MetricName> are prepended
SystemEventPublishTopic = "system-events" // <SourceServiceName>/<SystemEventType>/<SystemEventAction><OwnerServiceName>/<ProfileName>

// Core Data Topics
CoreDataEventSubscribeTopic = "events/device/#"

// Core Command Topics
CoreCommandDeviceRequestPublishTopic = "device/command/request" // <DeviceServiceName>/<DeviceName>/<CommandName>/<CommandMethod> are appended
CoreCommandRequestSubscribeTopic = "core/command/request/#"
CoreCommandQueryRequestSubscribeTopic = "core/commandquery/request/#"

// Command Client Topics
CoreCommandQueryRequestPublishTopic = "core/commandquery/request" // <deviceName>|all is prepended
CoreCommandRequestPublishTopic = "core/command/request" // <DeviceName>/<CommandName>/<CommandMethod> are appended

// Support Notifications
// No Topics Yet

// Support Scheduler
// No Topics Yet

// Device Services Topics
CommandRequestSubscribeTopic = "device/command/request" // <DeviceServiceName>/# is appended <
MetadataSystemSubscribeEvent = "system-events/core-metadata/+/+" // <DeviceServiceName>/# is appended
ValidateDeviceSubscribeTopic = "validate/device" // <DeviceServiceName> is pre-pended

// App Service Topics
// App Service topics remain configurable inorder to filter by subscription.
)
5 changes: 5 additions & 0 deletions common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ func NormalizeValueType(valueType string) (string, error) {
}
return "", errors.NewCommonEdgeX(errors.KindContractInvalid, fmt.Sprintf("unable to normalize the unknown value type %s", valueType), nil)
}

// BuildTopic is a helper function to build MessageBus topic from multiple parts
func BuildTopic(parts ...string) string {
return strings.Join(parts, "/")
}

0 comments on commit 4a060e2

Please sign in to comment.