-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity store: change constructors to remove redundant clones and rename fields #2176
Conversation
Robot Results
|
/// Represents an "MQTT entity identifier" portion of the MQTT topic | ||
/// Represents an "Entity MQTT address" portion of the MQTT topic | ||
/// | ||
/// Example: | ||
/// - topic: `te/device/dev1/service/myservice/m//my_measurement | ||
/// - topic: `te/device/dev1/service/myservice/m//my_measurement` | ||
/// - entity id: `device/dev1/service/myservice` | ||
/// | ||
/// <https://thin-edge.github.io/thin-edge.io/next/references/mqtt-api/#group-identifier> | ||
type EntityId = String; | ||
type EntityMqttAddress = String; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bravo555, @reubenmiller, @albinsuresh
I'm not fully happy with this proposal for a new name:
Pros:
EntityId
is definitely confusing, knowing that device id is already used with a different meaning: (the main device id is the CN of its certificate while its entity identifier isdevice/main//
.
Cons:
- The specifications uses the term entity identifier.
- The address suffix of
EntityMqttAddress
might be confused with some kind of network address. - This identifier is used only for MQTT topics. Hence, I would expect the term topic rather than address
What about EntityTopicId
or EntityMqttTopicId
?
Alternative
Another way to solve the issue is t:
- keep the terms
EntityId
and entity identifier, when speaking about topics. - use the terms
EntityName
and entity name, when speaking about the CommonName (CN) of these devices.
Important
In any case, the terms used in the code base must be the same as those used in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed to use the name EntityTopicId
for entity identifiers in the new topic scheme.
|
||
let external_id = message | ||
.external_id | ||
.unwrap_or_else(|| self.derive_external_id(&message.mqtt_id)); | ||
let entity_id = message | ||
.entity_id | ||
.unwrap_or_else(|| self.derive_entity_id(&message.mqtt_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is really good one, as external id has a specific meaning in the context of c8y.
Codecov Report
Additional details and impacted files
|
Because we need to clone anyway while constructing `EntityTopic` and `EntityRegistrationTopic`, the `TryFrom` impls were changed to convert from references instead of values. Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Because the name `external_id` was not used anywhere else to refer to the identifiers of devices and services on the cloud, it was renamed in favour of `entity_id`, which covers device ids and service ids. `mqtt_id` was renamed to `topic_id`. Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Proposed changes
EntityTopic
andEntityRegistrationMessage
TryInto
impls to take references instead of values, removingneedless clones
external_id
toentity_id
(it was already used in thin-edge documentation as device id or service id) andmqtt_id
totopic_id
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments