Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan authored Jul 3, 2024
1 parent 553342a commit 1b9b332
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/manuals/orion-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2533,15 +2533,15 @@ Thus, if we have this:
}
```

`B` could be set to the desired `0.04` (if `A` is evaluated before `B`) or to the underised `null` (if `B` is evaluated before `A`), randomly.
in the resulting notification `B` could be set to the desired `0.04` (if `A` is evaluated before `B`) or to the underised `null` (if `B` is evaluated before `A`), randomly.

In order to overcome this problem, the `evalPriority` metadata can be used to define the evaluation order. It works this way:

* `evalPriority` metadata is a number from 1 (first evaluation) to 100000 (last evaluation)
* Expressions are evaluated in incresing order of priority
* In case of ties, Orion does not guarantee a particular evaluation order. Thus, expressions in the same priority level must be considered independent or bad things would happen
* If no `evalPriority` is set, default 100000 is used
* `evalPriority` only has a meaning in `notification.httpCustom.ngsi` in subscriptions. As metadata in regular entities (e.g. an entity created with `POST /v2/entities`) Orion doesn't implements any semantic.
* `evalPriority` only has a meaning in `notification.httpCustom.ngsi` in subscriptions. As metadata in regular entities (e.g. an entity created with `POST /v2/entities`) Orion doesn't implements any semantic for it

Using `evalPriority` the above example could be reformuled this way:

Expand Down
7 changes: 2 additions & 5 deletions src/lib/ngsi/ContextAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,11 @@ std::string ContextAttribute::toJson(const std::vector<std::string>& metadataFi
filterAndOrderMetadata(metadataFilter, &orderedMetadata);

//
// metadata (note that ngsi field in custom notifications avoids empety metadata array, i.e. "metadata": {})
// metadata (note that ngsi field in custom notifications avoids empty metadata array, i.e. "metadata": {})
//
if ((!renderNgsiField) || (metadataVector.size() > 0))
{
jh.addRaw("metadata", metadataVector.toJson(orderedMetadata));
jh.addRaw("metadata", metadataVector.toJson(orderedMetadata));
}

return jh.str();
Expand Down Expand Up @@ -1185,9 +1185,6 @@ std::string ContextAttribute::toJsonValue(ExprContextObject* exprContextObjectP)
}
else if (valueType == orion::ValueTypeString)
{
//std::string out = "\"";
//out += toJsonString(stringValue);
//out += '"';
return smartStringValue(stringValue, exprContextObjectP, "null");
}
else if (valueType == orion::ValueTypeBoolean)
Expand Down

0 comments on commit 1b9b332

Please sign in to comment.