Class: Stream
A convenience API for managing and accessing an individual stream.
Properties
id
• Readonly
id: StreamID
Important Methods
addToStorageNode
▸ addToStorageNode(storageNodeAddress
, waitOptions?
): Promise
\<void
>
Assigns the stream to a storage node.
Parameters
Name | Type | Description |
---|---|---|
storageNodeAddress | string | - |
waitOptions | Object | control how long to wait for storage node to pick up on assignment |
waitOptions.timeout? | number | - |
Returns
Promise
\<void
>
a resolved promise if (1) stream was assigned to storage node and (2) the storage node acknowledged the
assignment within timeout
, otherwise rejects. Notice that is possible for this promise to reject but for the
storage node assignment to go through eventually.
getPermissions
▸ getPermissions(): Promise
\<PermissionAssignment
[]>
See StreamrClient.getPermissions.
Returns
Promise
\<PermissionAssignment
[]>
grantPermissions
▸ grantPermissions(...assignments
): Promise
\<void
>
See StreamrClient.grantPermissions.
Parameters
Name | Type |
---|---|
...assignments | PermissionAssignment [] |
Returns
Promise
\<void
>
hasPermission
▸ hasPermission(query
): Promise
\<boolean
>
See StreamrClient.hasPermission.
Parameters
Name | Type |
---|---|
query | Omit \<UserPermissionQuery , "streamId" > | Omit \<PublicPermissionQuery , "streamId" > |
Returns
Promise
\<boolean
>
publish
▸ publish(content
, metadata?
): Promise
\<Message
>
Parameters
Name | Type |
---|---|
content | unknown |
metadata? | PublishMetadata |
Returns
Promise
\<Message
>
revokePermissions
▸ revokePermissions(...assignments
): Promise
\<void
>
See StreamrClient.revokePermissions.
Parameters
Name | Type |
---|---|
...assignments | PermissionAssignment [] |
Returns
Promise
\<void
>
Other Methods
delete
▸ delete(): Promise
\<void
>
Deletes the stream.
Returns
Promise
\<void
>
Remarks
Stream instance should not be used afterwards.
detectFields
▸ detectFields(): Promise
\<void
>
Attempts to detect and update the config metadata of the stream by performing a resend.
Returns
Promise
\<void
>
be mindful that in the case of there being zero messages stored, the returned promise will resolve even though fields were not updated
Remarks
Only works on stored streams.
getMetadata
▸ getMetadata(): StreamMetadata
Returns the metadata of the stream.
Returns
getStorageNodes
▸ getStorageNodes(): Promise
\<string
[]>
See StreamrClient.getStorageNodes.
Returns
Promise
\<string
[]>
getStreamParts
▸ getStreamParts(): StreamPartID
[]
Returns the partitions of the stream.
Returns
removeFromStorageNode
▸ removeFromStorageNode(nodeAddress
): Promise
\<void
>
See StreamrClient.removeStreamFromStorageNode.
Parameters
Name | Type |
---|---|
nodeAddress | string |
Returns
Promise
\<void
>
update
▸ update(metadata
): Promise
\<void
>
Updates the metadata of the stream by merging with the existing metadata.
Parameters
Name | Type |
---|---|
metadata | Partial \<StreamMetadata > |
Returns
Promise
\<void
>