w3c / wot-testing

Repository for WoT Testing purposes
15 stars 29 forks source link

Plugfest outcome: ids needed for primary keys #22

Open mmccool opened 4 years ago

mmccool commented 4 years ago

Directories (and any database) need stable primary keys. Since ids are optional in TDs these cannot be used for that purpose. So we need a workaround, perhaps autogenerated ids specific to the database in a wrapper object.

mmccool commented 4 years ago

This was fixed for the purposes of the plugfest by adding IDs to the TDs that were causing the problem (see https://github.com/w3c/wot-testing/pull/25) but since IDs are formally optional we do have to be able to deal with TDs without IDs.

farshidtz commented 4 years ago

The handling of "anonymous" TDs by the sync script is described here.

It uses the TD's id as the resource id during registration and follow-up updates (PUT /td/{id}). TDs that have no id are always created as a new resource using a POST request (POST /td) which responds with a system-generated ID in response Location header. For updates on TDs without id, an overlapping registration will exist in the directory until it gets purged some time after the validity period set as TTL.

The directory does generate a UUID for the TDs that have no ID. But without any mapping between the system-generated ID and anonymous TDs, there is no way to update them. So the script just submits those TDs as a new resource and lets the old ones expire and get removed automatically.

Ideally, a client responsible for registering an anonymous TD should maintain the system-generated ID (obtained from the directory during first registration) and use it for follow-up updates.