条件请求在连接上

huangapple go评论100阅读模式
英文:

Conditional Requests on Connections

问题

我们在事物上有条件请求-HTTP API或Ditto协议标头。
是否有一种方法可以限制有效载荷发布到Ditto连接中的主题,除非匹配条件请求?

例如,在我的孪生中,我有一个名为“connectionState”的特性,其值为“Disconnected”。我想限制发布Ditto协议消息到一个主题,以在连接状态为Disconnected时更新其他特性。一旦连接状态变为“Connected”,我希望已发布的所有Ditto协议消息都可以更新所有其他特性。

Ditto连接是否有这样的条件请求?

英文:

We have conditional requests on things- HTTP API or Ditto Protocol headers.
Is there a way to restrict payload to get published into a topic in the ditto connections unless a conditional request is matched?

For example, in my twin I have a feature "connectionState" with value "Disconnected". I want to restrict publishing ditto protocol messages to a topic to update other features when the connectionState is Disconnected. Once the connectionState is "Connected", I want all the ditto protocol messages that have been published to update all the other features.

Is there such conditional request for ditto connections?

答案1

得分: 1

是的,可以配置如连接目标过滤器文档所述,并与请求额外字段一起使用。

例如:

{
  "address": "<target-address>",
  "topics": [
    "_/_/things/twin/events?filter=ne(features/connectionState/properties/value,'Disconnected')&extraFields=features/connectionState/properties/value" 
  ],
  "authorizationContext": ["ditto:outbound-auth-subject", "..."]
}

这将仅在连接状态不是Disconnected时将孪生事件发布到目标地址。

英文:

Yes, that can be configured as documented for connection target filters
and in combination with requesting extraFields.

E.g.:

{
 &quot;address&quot;: &quot;&lt;target-address&gt;&quot;,
 &quot;topics&quot;: [
   &quot;_/_/things/twin/events?filter=ne(features/connectionState/properties/value,&#39;Disconnected&#39;)&amp;extraFields=features/connectionState/properties/value&quot; 
 ],
 &quot;authorizationContext&quot;: [&quot;ditto:outbound-auth-subject&quot;, &quot;...&quot;]
}

That will publish twin events to the target address only if the connectionState is not Disconnected.

huangapple
  • 本文由 发表于 2023年2月19日 03:04:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495726.html
  • eclipse-ditto
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定