Interface ITopicViews
This feature allows a client session to manage topic views.
Inherited Members
Namespace: PushTechnology.ClientInterface.Client.Features
Assembly: Diffusion.Client.dll
Syntax
public interface ITopicViews : IFeature
Remarks
A topic view maps one part of a server's topic tree to another. It dynamically creates a set of reference topics from a set of source topics, based on a declarative topic view specification. The capabilities of topic views range from simple mirroring of topics within the topic tree to advanced capabilities including publication of partial values, expanding a single topic value into many topics, inserting values from other topics, throttling the rate of publication, and applying a fixed delay to the publication.
A topic view can also map topics from another server (in a different cluster). This capability is referred to as 'remote topic views'. The view can specify the server that the source topics are hosted on in terms of a remote server (see IRemoteServers for details of how to create and maintain remote servers).
Each reference topic has a single source topic and has the same topic type as its source topic. Reference topics are read-only (they cannot be updated), nor can they be created or removed directly. Otherwise, they behave just like standard topics. A client session can subscribe to a reference topic, and can fetch the reference topic's current value if it has one.
The source topics of a topic view are defined by a topic selector. One or more reference topics are created for each source topic, according to the topic view. If a source topic is removed, reference topics that are derived from it will automatically be removed. If a topic is added that matches the source topic selector of a topic view, corresponding reference topics will be created. Removing a topic view will remove all of its reference topics.
Topic view specifications
The following is a simple topic view specification
that mirrors all topics below the path a
to reference topics below the path b
.
map ?a// to b/<path(1)>
A topic view with this specification
will map a source topic at the path a/x/y/z
to a reference topic at the path b/x/y/z
.
The specification is simple,
so the reference topic will exactly mirror the source topic.
A general topic view specification comprises several parts:
- The source topic clause identifies the source topics.
- The optional from clause which may identify a remote server that hosts the source topics.
- The path mapping clause determines how reference topic paths are derived from the source topic paths, and when expanding to more than one reference topic, from where the values are obtained.
- The optional patch clause(s) can specify that a JSON patch is applied to the reference topic value.
- The optional insert clause(s) can specify that values from other topics are inserted into the final reference topic value.
- The optional topic property mapping clause determines how reference topic properties are derived from source topic properties.
- The optional value mapping clause determines how reference topic values are derived from source topic or expanded values.
- The optional throttle clause constrains the rate at which each reference topic is updated when its source topic is updated.
- The optional delay by clause causes a change to a view's source topic to be delayed by a fixed time before it is reflected in reference topics.
- The optional separator clause can define a replacement path separator for values extracted using the scalar or expand directives.
- The optional type clause can specify that the reference topic that is created is of a different TopicType from the selected source topic.
Source topic clause
The source topic clause begins with the
map
keyword
and is followed by a topic selector.
These topic selectors follow the same parsing rules
as other topic selectors.
When evaluating a topic view, topics in the topic tree that match the source topic selector are considered, with the following exceptions:
- Topics created through the Publisher API;
- ROUTING topics.
Reference topics are valid source topics. In particular, chaining of topic views is supported; that is, a reference topic created by one topic view can be the source topic of another topic view. Additionally, a reference topic can be the source topic of a routing topic subscription.
From clause
The from
clause optionally follows the source topic clause. It begins with
the from
keyword and is followed by a remote server name. The name
refers to a remote server created using the IRemoteServers feature.
The presence of the clause indicates that the source topics will be selected from the specified server and not from the local server.
Further details regarding the processing of remote topic views are given below.
Path mapping clause
The paths of reference topics are derived from the source topic according to the topic view path mapping. The path mapping allows the source topic path and the value of the source topic to determine the path of the reference topic. In addition the path mapping can include expand directives which allow objects and arrays in JSON source topic values to be expanded to produce many reference topics.
A path mapping clause begins with the
to
keyword
and is followed by a path mapping template.
A path mapping template is a topic path
with embedded directives.
Directives are evaluated when creating the topic reference
and substituted into the topic path.
Directives are delimited by angle brackets
<
,
>
and consist of the name of the directive
and a list of parameters.
The parameter list is comma-separated
and surrounded by parentheses ((
, )
).
The following mapping directives are supported:
Source path directives extract a portion of the source path
and are parameterized by the index
of the start part of the source path
and the number of parts to include.
The number of parts parameter is optional
– if it is missing,
the selection extends to the end of the source path.
The syntax is
<path(start, number)>
,
or <path(start)>
when the number of parts parameter is omitted.
For example,
given the source path
a/b/c/d
,
the source path directive
<path(1, 2)>
is mapped to the reference topic path
b/c
,
and the source path directive
<path(2)>
is mapped to the reference topic path
c/d
.
Patch clause(s)
Patch clauses may be specified directly after the path mapping, but before any other clauses, to indicate that a JSON patch is to be applied to the value.
Patch clauses only apply to JSON source topics; if the topic view specification contains a patch clause, non-JSON topics matching the source topic selector are ignored.
The patch is applied to the current value within a view processing chain, so if a patch occurs after an expand then the patch will be applied to each expanded value.
The format of a patch clause is
patch 'patch string'
The patch string should be formatted according to the JSON Patch standard (see RFC 6902: JavaScript Object Notation (JSON) Patch).
Patches are a sequence of JSON Patch operations contained in an array. They are applied as an atomic update to the previous value if the resulting update is successfully calculated. The following patch will check the value at a specific key and update if the expected value is correct:
[{"op":"test", "path":"/price", "value" : 22}, {"op":"add", "path":"/price", "value": 23}]
The available operations are:
-
Add:
{"op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ]}
-
Remove:
{"op": "remove", "path": "/a/b/c"}
-
Replace:
{"op": "replace", "path": "/a/b/c", "value": 43}
-
Move:
{"op": "move", "from": "/a/b/c", "path": "/a/b/d"}
-
Copy:
{"op": "copy", "from": "/a/b/c", "path": "/a/b/e"}
-
Test:
{"op": "test", "path": "/a/b/c", "value": "foo"}
The test operation checks that the CBOR representation of the value of a topic is identical to the value provided in the patch after converting it to CBOR. If the value is represented differently as CBOR, commonly due to different key ordering, then the patch will return the index of the failed operation. e.g the values
{"foo": "bar", "count": 43}
and
{"count": 43, "foo": "bar"}
are unequal despite semantic equality due to the differences in a byte for byte comparison.
The following patch clause would add the 'price' field and remove the 'name' field from an input JSON object.
patch '[{"op":"add", "path":"/price", "value" : 22}, {"op":"remove", "path":"/name"}]'
Patches can only be applied to JSON arrays or objects and if they fail to apply, no resulting reference topic will be created by the view. If an update patch fails, any previously created reference topic would be removed.
Any number of patch clauses may be chained together but must be before any insert clauses. For example:
patch '[{"op":"add", "path":"/price", "value" : 22}]'
patch '[{"op":"remove", "path":"/name"}]'
insert AnyTopic at /T/- default "unknown"
Insert clause(s)
Insert clauses may be specified directly after the path mapping, and after any patch clause(s), to indicate that values from other topics (insertion topics) are to be added to the derived reference topic value.
Insert clauses only apply to JSON source topics; if the topic view specification contains an insert clause, non-JSON topics matching the source topic selector are ignored.
The name of the topic to insert from can be specified in a similar way to the path mapping in that constants, path directives, and scalar directives (but not expand directives) may be used.
The value from the insertion topic (if found) is inserted into the 'current' value at a specified key position. The current value may be the source topic value, the value output from expand directives (in which case the insertion applies to each value), or the value from a previous insert clause. Insertion topics may be type JSON, STRING, INT64, or DOUBLE.
If, when evaluating a topic view, the insertion topic is not found (or the specified key within it is not found), or it is of an unsupported topic type, an optional default value may be inserted, but if no default is specified then no insertion takes place and the value is passed to the derived reference topic unchanged.
The values of the insertion topics are only taken at the point when the source topic is evaluated against the topic view (i.e. when the source topic is updated). Changes to the value of the insertion topic that occur in the interim are not applied to the derived reference topics.
The format of an insert clause is
insert path [key fromKey] at insertionKey [default defaultValue]
The path is specified in exactly the same way as for the path mapping clause, except it may not contain expand directives. path directives operate on the path of the source topic, whereas scalar directives operate on the 'current' value as defined previously.
key is optional and can specify a fromKey which is a JSON pointer indicating the data within the insertion topic that is to be inserted. If no key is specified then the whole of the insertion topic value is inserted.
at specifies the insertionKey which is a JSON pointer
indicating where to insert the insertion topic value. If a value already
exists at the specified key then it is replaced otherwise it is inserted.
Insertion can only occur if the parent of the key exists in the value and is
of a compatible type. Array pointers may only be used to replace existing
entries or append one greater than the last entry. The special pointer value
/-
may be used to append to the end of an existing array.
default is optional and may be used to specify a string defaultValue to be inserted if the insertion topic does not exist, it is of an unsupported topic type, or the specified key within it could not be found.
The following insert clause would cause the whole value of the topic named AnyTopic to be inserted into the current value at key /T, assuming that the current value is an object.
insert AnyTopic at /T
The following insert clause would cause the whole value of the topic named AnyTopic to be inserted into the current value at key /T/MyKey, assuming that an object with the key T exists in the current value.
insert AnyTopic at /T/MyKey
The following insert clause would cause the whole value of the topic named AnyTopic to be appended to the array at the key T in the current value.
insert AnyTopic at /T/-
The following insert clause would cause the value at the key name within the topic named AnyTopic to be appended to the array at the key T in the current value.
insert AnyTopic key /name at /T/-
In the above examples no insertion would take place if the insertion value was not found, but a default value can be specified to insert into the current value in this case.
insert AnyTopic at /T/- default "unknown"
The path of the topic to insert from can be built from parts of the source topic path and/or scalar values within the current value. For example:
insert AC/<path(1,1)>/<scalar(/myval)> at /T
Any number of insert clauses may be chained together. For example:
insert AnyTopic at /T/- default "unknown" insert AnotherTopic at /X/Another
Topic property mapping clause
The ITopicSpecification of a reference topic is derived from the topic specification of the source topics. A reference topic has the same topic type as its source topic.
The topic properties of a reference topic are derived from the source topic. Some topic properties can be tuned using the optional topic property mapping clause. The following table describes the behavior for each topic property.
Source topic property | Reference topic specification default | Can be set by topic property mapping? | Notes |
---|---|---|---|
Compression | Copied from source topic specification | Yes | |
Conflation | Copied from source topic specification | Yes | |
DontRetainValue | Copied from source topic specification | Yes | |
Owner | Not set | No | |
Persistent | Not set | No | Reference topics are not persisted. Topic views are persisted, so a reference topic will be recreated on server restart if its source is persistent. |
Priority | Copied from source topic specification | Yes | |
PublishValuesOnly | Copied from source topic specification | Yes | |
Removal | Not set | No | Reference topics cannot be removed directly. |
Schema | Copied from source topic specification | No | A RECORD_V2 reference topic has the same schema as its source topic. |
TidyOnUnsubscribe | Copied from source topic specification | Yes | |
TimeSeriesEventValueType | Copied from source topic specification | No | A TIME_SERIES reference topic has the same value type as its source topic. |
TimeSeriesRetainedRange | Copied from source topic specification | Yes, with restrictions | A topic property mapping cannot increase the time series retained range by overriding the TimeSeriesRetainedRange property. The retained range of a reference time series topic will be constrained to be no greater than that of its source topic. |
TimeSeriesSubscriptionRange | Copied from source topic specification | Yes | |
ValidateValues | Not set | No | A reference topic reflects updates to its source topic. It cannot reject updates. |
A topic property mapping clause begins with the keywords
with properties
and consists of a comma-separated list
of topic property keys and values,
each separated by a colon.
For example,
the following topic view specification
maps all topics below the path
a
to reference topics below the path
b
,
and disables both conflation
and compression for the reference topics.
map ?a// to b/<path(1)> with properties CONFLATION:off, COMPRESSION:false
Topic value mapping
By default, a reference topic's value is a copy of the source topic value, or part of the source value produced by an expand path mapping directive and/or modified by insert clauses. For JSON source topics or TIME_SERIES topics with a JSON event type, the optional topic value mapping clause can be applied to extract part of the resulting value (the latest value in the case of TIME_SERIES_ topics).
A topic value mapping begins with the keyword as
and is followed
by a value directive. A value directive is delimited by angle brackets
(<
, >
), and consists of the value
keywords and
a single JSON pointer parameter. The JSON pointer selects the part of the
current value to copy.
For example, given a current value of
{
"account" : "1234",
"balance" : { "amount" : 12.57, "currency" : "USD" }
}
and the value mapping clause
as <value(/balance)>
,
the reference topic value will be
{
"amount" : 12.57,
"currency" : "USD"
}
Value mappings that follow expand directives and/or insert clauses apply to the current derived value and not the source topic value.
Topic value mappings only alter the reference topic value;
only the path mapping determines whether a reference topic
should exist. If the topic value mapping's JSON pointer fails
to select anything from the source topic value, the reference
topic will have the JSON value null
.
Topic value mappings are often used with path value mappings to avoid repeating information in the path and the value. For example:
map ?accounts// to balances/<scalar(/account)> as <value(/balance)>
Value mappings that follow expand directives apply to the expanded value and not the source topic value.
Throttle clause
The optional throttle clause can be used to constrain the rate at which a reference topic is updated when its source topic is updated. The primary application of a throttle clause is to restrict the number of updates sent to reference topic subscribers, reducing network utilization or the processing each subscriber must do. Throttling also restricts the rate at which client sessions can observe changes to reference topic values using the fetch API.
The throttle clause has the form
throttle to X updates every period
,
where X is a positive integer,
and period is a positive integer
followed by a time unit which is one of
seconds
,
minutes
,
or hours
.
For example,
the following topic view specification
maps all topics below the path
a
to reference topics below the path
b
,
but updates the value of each reference topic
at most twice every five seconds:
map ?a// to b/<path(1)> throttle to 2 updates every 5 seconds
To improve readability,
the throttling clause allows
1 update
as an alternative to
1 updates
,
and every second
as an alternative to
every 1 seconds
(and so on, for other time units).
For example,
the following topic view specification
maps all topics below the path
a
to reference topics below the path
b
,
but updates the value of each reference topic
at most once every hour:
map ?a// to b/<path(1)> throttle to 1 update every minute
The throttle clause is only applied when a source topic is updated more frequently than the configured rate. If a source topic is updated less frequently, updates are passed on unconstrained. If the rate is exceeded, a reference topic will not be updated again until the configured period has expired. At this time, the reference topic will be updated based on the source topic updates that happened in the interim, and a single value will be published. Thus, a throttle clause provides topic-scoped conflation.
The throttle clause is ignored for time series topics because time series updates do not support efficient conflation. Updates to source time series topics are passed on immediately to the corresponding reference topics, regardless of any throttle clause.
Delay clause
The optional delay clause causes a change to a view's source topic to be delayed by a fixed time before it is reflected in reference topics. Topic additions, updates, and removals are all delayed. Delays can range from one second to many days.
Such a publication delay is a useful way to devalue topic data so it can be given away to non-paying users.
The delay clause has the form delay by duration
, where
duration is a positive integer followed by a time unit which is one
of seconds
, minutes
, or hours
.
For example, the following topic view specification maps all topics below the
path a
to reference topics below the path b
, but
changes to a source topic are delayed by five minutes before they are
reflected in the corresponding reference topic.
map? a// to b/<path(1)> delay by 5 minutes
Views with delay clauses initially create reference topics in an unpublished state. The topics are published once the delay time has expired. A topic in the unpublished state prevents a lower priority topic view from creating a reference topic with the same path. Sessions with the rights to read the source topic can browse unpublished topics using the WithUnpublishedDelayedTopics fetch request option.
Preserve topics clause
The default behavior for a topic view is that only the reference topics that can be derived from the current value of the source topic are maintained. This applies to views using directives that derive the path of the reference topic(s) from a value within the source topic (e.g. scalar or expand). For example if a view uses a scalar directive to determine the path of the reference topic and the source topic is updated such that the selected scalar value changes then the previously created reference topic will be removed and a new one created. Similarly an expand directive may create many reference topics from the source value but if the source is updated then only those reference topics that still have a corresponding value within the source value will be updated (or new ones added if not in the previous value), whilst others will be removed.
There are situations where an application may not want reference topics to be removed because of source value changes. In such cases the 'preserve topics' clause may be used to indicate that all reference topics created by a view should be retained (and updated by later updates that apply to it) until either the source topic or the creating view are removed.
For example:
map ?a/path/ to b/<expand()> preserve topics
Separator clause
Views can use the scalar and expand directives in path mappings to extract
text from the source value. By default, any /
characters in the text
are interpreted as path separators and will introduce extra levels in
reference topic paths. If this is undesirable, the optional separator clause
can be used to replace any /
characters produced by the scalar and
expand directives with a constant string. The replacement can contain path
separators but must have no empty path segments (//
).
Here is an example replacing all path separators with an alternate character:
map ?a/path/ to b/<scalar(/x/y)> separator '%'
If the value at '/x/y' in the source topic was foo/bar, this would cause the reference topic to be created at /b/foo%bar instead of /b/foo/bar.
Topic type clause
The optional 'type' clause can be used to specify the TopicType of the target reference topic. If the current source value of type indicated by the source topic's type can be converted to the target type, a reference topic of the specified type will be created.
The 'type' clause may occur anywhere after path mapping or transformation (e.g 'insert') clauses.
For example:
map ?a/ to b/<path(1)> type STRING
The specified type must be one of the supported target types (STRING, INT64, DOUBLE, JSON, TIME_SERIES, or BINARY), case insensitive.
The following table describes the supported conversions from the source topic type (the left column) to the supported target types. The number in brackets indicates a note at the foot of the table describing exactly how the conversion is processed. Where there is no number, no conversion is necessary and the derived source value is simply mapped to the target reference topic as if the 'type' option was not specified. Where there is no entry for the source topic type in the left column, no conversion is supported and topics of unsupported types will not be processed by the topic view. An 'x' indicates that the conversion is not supported.
In all cases the value being processed will be the 'current' value as derived from other mappings within the topic view (e.g. expand) which is not necessarily the value of the source topic.
Source topic | STRING | INT64 | DOUBLE | JSON | TIME_SERIES | BINARY |
---|---|---|---|---|---|---|
STRING | ( 1 ) | ( 1 ) | ( 2 ) | ( 3 ) | x | |
INT64 | ( 4 ) | ( 5 ) | ( 2 ) | ( 3 ) | x | |
DOUBLE | ( 4 ) | ( 6 ) | ( 2 ) | ( 3 ) | x | |
JSON | ( 7 ) | ( 7 ) | ( 7 ) | ( 3 ) | x | |
TIME_SERIES | ( 8 ) | ( 8 ) | ( 8 ) | ( 8 ) | ( 9 ) | BINARY | x | x | x | x | ( 9 ) |
Conversion notes:-
- STRING to number conversions will only occur if the value of the string can be converted to the target number type. If the string cannot be converted then no reference topic will be created.
- Primitive types to JSON will result in a JSON topic containing just the scalar value.
- Conversions to TIME_SERIES will result in a time series topic with an event type matching the source topic. Every update to the source topic will result in a new value being appended to the reference time series topic. It is not possible to convert to a time series topic with a different event type from the source topic.
- Conversions from number types to STRING will result in a simple string representation of the number in the reference topic value.
- INT64 to DOUBLE conversions perform a simple conversion. For example, 123 becomes 123.0.
- DOUBLE to INT64 conversions perform rounding to the nearest integer value. For example 12.51 becomes 13.
- JSON to primitive type conversions only occur if the JSON value is a scalar which can be read as a string and converted to the target type. Currently, only string and integer scalar values can be read as a string (i.e. not doubles). The string representation of the value will be converted in the same way as specified for STRING to other primitive types. If the JSON value is a structure or cannot be converted then no conversion takes place and no reference topic will be created.
- The conversion of TIME_SERIES to other types follows the same rules as for conversion from the source topic type that matches the source time series topic's event value type. So if the time series event type is 'double' then the conversion rules from source topic type DOUBLE to the target type will apply. Each value appended to the source time series topic will result in an update to the reference topic. If a failure to convert occurs at any point then the reference topic would be removed and only recreated if a value is appended that can be converted.
- BINARY to TIME_SERIES, and vice-versa is supported in the same way as for other time series conversions.
Escaping and quoting special characters
Each part of a topic view expression
has characters with special significance.
Source topic clauses
and path mapping clauses
are delimited by white space.
Directives in path
and topic property mapping clauses
are delimited by the
<
and >
characters,
and each directive parameter is terminated by
,
or
)
.
Topic property mapping
clauses are delimited by white space,
and the :
and ,
characters.
Sometimes a topic view must refer to
or generate topics with paths
that contains special characters,
or use a JSON pointer containing special characters.
The escape sequence
\x
can be used to literally insert any character
x
,
with a one exception:
\/
cannot be used in path fragments
since the path delimiter
/
is always significant.
Here is an example topic view expression
containing escape sequences.
It maps the topic path
a topic
a reference topic with the path
another topic
.
map a\ topic to another\ topic
Here is an example with a source value directive
that uses the JSON pointer
/x()/y
to extract the target path from the source value.
The
)
character in the JSON pointer must be escaped
so it is not treated as the end of the parameter list.
map ?a// to <scalar(/x(\)/y)>
To insert
\
,
the escape sequence
\\
must be used.
There is no need to escape white space
in JSON pointers directive parameters.
However,
white space is significant.
For example,
the following expressions have different topic value mapping clauses
since the JSON pointer in the second expression is
"/x "
;
that is,
it has a trailing space:
map a to b as <value(/x)>
map a to b as <value(/x )>
Instead of using escape sequences,
white space characters can be included in source topic clauses
and path mapping clauses using quotes.
A clause is quoted by wrapping it in single quote
('
)
or double quote
("
)
characters.
For example:
map "a topic" to "another topic"
Within a quoted clause, quotes of the same type must be escaped:
map 'alice\'s topic' to 'bob\'s topic'
For consistency, the values in topic property mapping clauses can be escaped or quoted. However, there is no need to do so because none of the valid values for the mappable properties contain special characters.
Dealing with topic path conflicts
Reference topics have a lower priority than normal topics created through the API, including replicas of normal topics created by topic replication or fan-out. A reference topic will only be created if no topic or reference topic is already bound to its derived topic path.
Topic views have a precedence based on order of creation. If two topic views define mappings the same topic path, the earliest-created topic view will create a reference topic. If a topic view is updated, it retains its original precedence.
Remote topic views
A remote topic view is one that specifies another server as the location of the source topics using the from clause as shown in the example below:
map? a// from server1 to b/<path(1)>
The server name server1
in this example refers to the name of a
remote server created using the IRemoteServers feature.
In this case, upon establishing a successful connection with the remote server indicated the topic view will create reference topics locally based upon the topics selected by the topic view's selector at the remote server. It is important to note that the selector only refers to topics that match it at the remote server and not on the local server and there is no reason why there could not be a source topic at the remote server that has the same path as an entirely different topic on the local server.
More than one topic view can specify the same remote server.
A remote server only makes a physical connection when it is in use, therefore the first topic view that specifies a remote server will cause it to establish a connection. Similarly, if the last topic view that uses a remote server is removed then the connection will be closed.
It is not necessary for the named remote server definition to exist before creating the topic view, as if it does not then the topic view will simply remain dormant until the remote server is created and a successful connection to the server specified in its URL is established. Similarly, if a remote server that is in use by remote topic views is removed then all of the reference topics created by the topic views will be removed and the topic views will become dormant until the named remote server is created again or the views are changed to name a different remote server.
If a remote topic view selects a ROUTING
topic at the remote server
then local mappings will only be performed if the routing topic mapping at
the remote server is able to establish a mapping for the remote server
connection. The mapping will be done as if from the resolved routing topic.
The rules of precedence for remote topic views are the same as for other topic views. If the remote server for a remote topic view does not exist or does not have an established connection then the remote topic view is not evaluated (i.e. it is as if the source topics for the view did not exist), but if the remote server later connects then the view will be evaluated and rules of precedence will determine whether reference topic will replace those created by earlier views.
Topic view persistence and replication
Reference topics are neither replicated nor persisted. They are created and removed based on their source topics. However, topic views are replicated and persisted. A server that restarts will restore topic views during recovery. Each topic view will then create reference topics based on the source topics that have been recovered.
The server records all changes to topic views in a persistent store. Topic views are restored if the server is started.
If a server belongs to a cluster, topic views (and remote servers) will be replicated to each server in the cluster. Topic views are evaluated locally within a server. Replicated topic views that select non-replicated source topics can create different reference topics on each server in the cluster. When remote topic views are in use, each server in the cluster will make a connection to the specified remote server and will separately manage their remote topic views.
A view with a delay clause uses temporary storage to record delayed events. If there is a high volume of updates, temporary per-server disk files will be used to save server memory. The storage is per-server, and does not survive server restart. When a server is started, no data will be published by a view with a delay clause until the delay time has expired.
Access control
The following access control restrictions are applied:
- To list the topic views, a session needs the READ_TOPIC_VIEWS global permission.
- To create, replace, or remove a topic view, a session needs the MODIFY_TOPIC_VIEWS global permission and SELECT_TOPIC permission for the path prefix of the source topic selector.
- Each topic view records the principal and security roles of the session that created it as the topic view security context. When a topic view is evaluated, this security context is used to constrain the creation of reference topics. A reference topic will only be created if the security context has READ_TOPIC permission for the source topic path, and MODIFY_TOPIC permission for the reference topic path. The topic view security context is copied from the creating session at the time the topic view is created or replaced, and is persisted with the topic view. The topic view security context is not updated if the roles associated with the session are changed.
Note
This interface does not require user implementation and is only used to hide implementation details.
Added in 6.3.
Examples
An instance of this feature can be obtained by calling TopicViews.
// session is a previously obtained ISession instance.
var topicViews = session.TopicViews;
Or it can be obtained by calling Topics.
// session is a previously obtained ISession instance.
var topics = session.Topics;
Methods
CreateTopicViewAsync(String, String)
Create a new named topic view.
Declaration
Task<ITopicView> CreateTopicViewAsync(string name, string specification)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the view. |
String | specification | The specification of the topic view. |
Returns
Type | Description |
---|---|
Task<ITopicView> | The |
Remarks
If a view with the same name already exists the new view will update the existing view.
If the operation completes successfully, the Task
result will be a
ITopicView instance.
Exceptions
Type | Condition |
---|---|
InvalidTopicViewException | The supplied specification is invalid. Thrown by the returned |
SessionSecurityException | The calling session does not have MODIFY_TOPIC_VIEWS permission or
appropriate path prefix permissions. Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
ClusterRoutingException | A transient cluster error occured. Thrown by the returned |
See Also
CreateTopicViewAsync(String, String, CancellationToken)
Create a new named topic view.
Declaration
Task<ITopicView> CreateTopicViewAsync(string name, string specification, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the view. |
String | specification | The specification of the topic view. |
CancellationToken | cancellationToken | The cancellation token used to cancel the current operation. |
Returns
Type | Description |
---|---|
Task<ITopicView> | The |
Remarks
The topic view name cannot be empty.
If a view with the same name already exists the new view will update the existing view.
If the operation completes successfully, the Task
result will be a
ITopicView instance.
Exceptions
Type | Condition |
---|---|
InvalidTopicViewException | The supplied specification is invalid. Thrown by the returned |
SessionSecurityException | The calling session does not have MODIFY_TOPIC_VIEWS permission or
appropriate path prefix permissions. Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
ClusterRoutingException | A transient cluster error occured. Thrown by the returned |
ListTopicViewsAsync()
List all of the topic views that have been created.
Declaration
Task<IReadOnlyCollection<ITopicView>> ListTopicViewsAsync()
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<ITopicView>> | The |
Remarks
If the operation completes successfully, the Task
result will be a
Exceptions
Type | Condition |
---|---|
SessionSecurityException | The calling session does not have READ_TOPIC_VIEWS permission.
Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
See Also
ListTopicViewsAsync(CancellationToken)
List all of the topic views that have been created.
Declaration
Task<IReadOnlyCollection<ITopicView>> ListTopicViewsAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token used to cancel the current operation. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<ITopicView>> | The |
Remarks
If the operation completes successfully, the Task
result will be a
Exceptions
Type | Condition |
---|---|
SessionSecurityException | The calling session does not have READ_TOPIC_VIEWS permission.
Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
RemoveTopicViewAsync(String)
Remove a named topic view if it exists.
Declaration
Task<object> RemoveTopicViewAsync(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the view. |
Returns
Type | Description |
---|---|
Task<Object> | The |
Remarks
If the named view does not exist the Task
will complete successfully.
If the task completes successfully, the Task
result will be null
.
Exceptions
Type | Condition |
---|---|
SessionSecurityException | The calling session does not have MODIFY_TOPIC_VIEWS permission.
Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
ClusterRoutingException | A transient cluster error occured. Thrown by the returned |
See Also
RemoveTopicViewAsync(String, CancellationToken)
Remove a named topic view if it exists.
Declaration
Task<object> RemoveTopicViewAsync(string name, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the view. |
CancellationToken | cancellationToken | The cancellation token used to cancel the current operation. |
Returns
Type | Description |
---|---|
Task<Object> | The |
Remarks
If the named view does not exist the Task
will complete successfully.
If the task completes successfully, the Task
result will be null
.
Exceptions
Type | Condition |
---|---|
SessionSecurityException | The calling session does not have MODIFY_TOPIC_VIEWS permission.
Thrown by the returned |
SessionClosedException | The calling session is closed. Thrown by the returned |
ClusterRoutingException | A transient cluster error occured. Thrown by the returned |