-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allows to define custom mappings for devices and assets for a tenant group only #61
Conversation
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.
First round of reviews
features/fixtures/application/app.ts
Outdated
@@ -10,27 +10,49 @@ const deviceManager = new DeviceManagerPlugin(); | |||
deviceManager.registerDecoder(new DummyTempDecoder()); | |||
deviceManager.registerDecoder(new DummyTempPositionDecoder()); | |||
|
|||
deviceManager.mappings.devices.measures = { | |||
deviceManager.devices.registerMeasures({ |
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.
To me this method could take the measure name as first parameter and then the measure definition.
This could allows to avoid to register 2 times the same measure for example
features/fixtures/application/app.ts
Outdated
value: { type: 'float' }, | ||
} | ||
} | ||
}, 'astronaut'); |
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.
Since it's an option, it should be of this form { group: "astronaut" }
lib/DeviceManagerPlugin.ts
Outdated
this.config.mappings.set(tenantGroup, { | ||
...this.config.mappings.get(tenantGroup), | ||
assets, | ||
'asset-history': assets |
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.
What is this? This collection is not included by default in the device manager plugin
lib/DeviceManagerPlugin.ts
Outdated
}) | ||
} | ||
} | ||
console.log(this.config.mappings); |
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.
Debug leftover
lib/DeviceManagerPlugin.ts
Outdated
this.config.mappings.set(tenantGroup, { | ||
...this.config.mappings.get(tenantGroup), | ||
assets: this.config.mappings.get('shared').assets, | ||
'asset-history': this.config.mappings.get('shared').assets |
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 collection does not exists in the device manager
lib/controllers/EngineController.ts
Outdated
@@ -52,7 +52,8 @@ export class EngineController { | |||
|
|||
async create (request: KuzzleRequest) { | |||
const index = request.getIndex(); | |||
const { collections } = await this.engineService.create(index); | |||
const tenantGroup = request.input.args.group; |
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.
You should use a request params helper intsead
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.
Please can you add proper comments to every function with also parameter explanation for developers but also maintainers
Why is the package.lock getting modified? |
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.
I would need an explanation on why was there the need to explode a functionality, into specific class methods.
Are we trying to build overkill setup functionalities on top of what should be templating?
register-measures
register-metadata
register-qos
Do these modifications imply that if we add new specific custom properties in the future OR new default collections with customizable properties, one would have to reconstruct/setup all this boilerplate by hand?
It seems to me at first glance, that a bad architectural choice was made somewhere.
@Yoann-Abbes @Aschen
doc/1/classes/devices-custom-properties/register-measures/index.md
Outdated
Show resolved
Hide resolved
A simple guide to be added and IMO all done! |
Co-authored-by: Michele Leo <[email protected]>
Co-authored-by: Michele Leo <[email protected]>
Co-authored-by: Michele Leo <[email protected]>
What this PR does
This PR allows to have custom mapping for each tenant group for the
assets
anddevices
collections#28
They are meant to be loaded at application startup
For
devices
collection, onlyqos
,measures
, andmetadata
fields are meant to be customized.For
assets
collection, onlymetadata
field is meant to be customized.How to test
Functional tests.
Clone KIoTP repo on branch
add-custom-mappings
Install plugins and switch to the
add-custom-mappings
branch on thedevice-plugin-manager
Define your own mappings in
lib/plugins/device-manager/mappings/
Register it in
lib/plugins/device-manager/index.ts
with the provided methodsRun KIoTP
Create and engine
kourou device-manager/engine:create -a group="groupTest" index="test"
Verify the mappings are correctly added.