TrustedTwin Homepage

Articles

Figure 1. Objects and services on the Trusted Twin platform which allow for the use of Templates (Ledger Entries, Timeseries, Indexes, Notifications).

Templates concept

Summary

This article describes the structure and purpose of templates used in advanced services (Timeseries, Indexes, Notifications) on the Trusted Twin platform. 

The purpose of this article is to provide system architects and developers with conceptual knowledge required to design solutions on the Trusted Twin platform. For developer resources, please consult the Trusted Twin docs website.

5 min read.

Concept

Templates

Templates are expressions (e.g., “{entry_value.serial}”) used on the Trusted Twin platform where the name or value needs to be dynamically built based on the current request execution context. Templates follow the Python XXX format() convention (see PEP YYY).

Figure 2.  Example of a template and dynamically built name.

Templates are used, for example:

  • to determine the name of a measurement column in which the value of a given Entry in the Ledger has to be stored in a Timeseries table.
  • to determine the values of properties which have to be stored in the Indexes table.

Templates use contextual variables including:

  • resource or object names, UUID4 identifiers or descriptions (e.g., user, Twin),
  • entry names, values, or timestamps (i.e., Ledger),
  • user dictionary provided in the request (i.e., “X-TrustedTwin” header),
  • current time.

Developer resources
Variables available in templates

Templates are used in:

  • Indexes service – for building values for properties.
  • Timeseries service – for building values for timestamp or dimensions and names for measurements (available in general configuration and in Ledger Entry configuration)
  • Notifications (subscribe/notify) service – form building topic name to publish the information about the change.

Tips & tricks

  • Entry value or object description can store any JSON serializable object. Templates allow for advanced addressing (e.g., entry_value.user_list[2] or entry_value.user_dict.name).
  • Templates used for building names and values differ on how they handle strings. 

Developer resources
Template types

  • Templates can be used in the Timeseries service to handle automatic measurement unpacking from a dictionary (i.e., “**”). 

Figure 3. “**” template example.

 

Developer resources
create_timeseries_table

Up next/ Next step

Related articles

For more information about how to use the Trusted Twin platform in your application’s architecture or technology stack, please contact hello@trustedtwin.com

ON THIS PAGE