Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface UpdateStream

An update stream provides a method for updating a specific topic.

An update stream is associated with a specific topic. The type of the topic must match the type of values passed to the update stream. It can be created with an optional constraint. The existence of the topic, its type and the constraint are validated lazily by the first set or validate operation. Subsequent operations issued before the first operation completes will be deferred until the completion of the first operation.

An update stream can be used to send any number of updates. It sends a sequence of updates for a specific topic to the server. If supported by the data type, updates will be sent to the server as a stream of binary deltas. An update stream does not prevent other sessions from updating the topic. If exclusive access is required update streams should be used with session locks as constraints.

Once validated an update stream can be invalidated. An invalidated update stream rejects the operations applied to it. The update stream will be invalidated if:

  • the topic is removed
  • another update stream is created for the same topic
  • the topic is updated to a new value by anything other than the stream
  • the session does not have the update permission
  • an operation fails because of cluster repartitioning
since

6.2

Hierarchy

  • UpdateStream

Index

Methods

Methods

get

  • get(): any
  • Return the latest value of the topic set using this update stream.

    The returned value reflects the last value that has been set, before it is sent to the server.

    If the server rejects a set operation, the topic value will not change and this update stream will be invalidated.

    This method will throw an Error if called before the first call to set

    Returns any

    the cached value of the topic

set

  • Sets the topic to a specified value.

    null or undefined can only be passed to the value parameter when updating string, int64 or double topics.

    When a topic of type string, int64 or double is set to `null` or `undefined` , the topic will be updated to have no value. If a previous value was present subscribers will receive a notification that the new value is `undefined` . New subscribers will not receive a value notification.

    Parameters

    • value: any

      the value. Update streams for string, int64, and double topics accept null or undefined, as described above. Using null with other topic types is an error and will result in an Error .

    Returns Result<TopicCreationResult | void>

    a Result that completes when a response is received from the server.

    The first set operation will return a TopicCreationResult indicating whether a new topic was created or it already exists.

    If the task fails, the Result will resolve with an Error .

validate

  • Validates the update stream.

    Update streams are validated lazily when setting the value. This method allows the stream to be validated before a value needs to be set.

    If the update stream has not been validated yet, calling this method checks the topic exists, the topic type is correct, the constraint is satisfied and the session has permission to update the topic. Once it has been validated calling this method checks the topic has not been removed, no other stream has been created for the topic, the value of the topic has not been changed by anything else and the session still has permission to update the topic. If validation fails, the Result will resolve with an Error.

    If this method fails all subsequent calls to set or validate will resolve with an Error.

    Returns Result<TopicCreationResult>

    a Result that completes when a response is received from the server.