Skip to main content

Overview

The IStream interface enables building custom stream backends for real-time, multi-client data synchronization. It’s designed for applications like collaborative editing, live dashboards, and real-time chat.

IStream Interface

Abstract base class for stream implementations.

Registering a Stream

create_stream

Register stream functions for a given stream name:
This automatically registers the following functions:
  • stream::get(my-stream)
  • stream::set(my-stream)
  • stream::delete(my-stream)
  • stream::list(my-stream)
  • stream::list_groups(my-stream)
  • stream::update(my-stream)
str
required
Unique name for the stream
IStream[Any]
required
Stream implementation instance

Input Types

StreamGetInput

Input for retrieving a single item:

StreamSetInput

Input for setting an item:

StreamDeleteInput

Input for deleting an item:

StreamListInput

Input for listing all items in a group:

StreamListGroupsInput

Input for listing all groups:

StreamUpdateInput

Input for atomic updates:

Output Types

StreamSetResult

Result of set/update operations:

Update Operations

Atomic update operations for the update() method:

UpdateSet

Set a field to a value:

UpdateIncrement

Increment a numeric field:

UpdateDecrement

Decrement a numeric field:

UpdateRemove

Remove a field:

UpdateMerge

Merge an object:

Example: In-Memory Stream

Example: Redis-Backed Stream

Example: Collaborative Todo List

Use Cases

  • Collaborative editing: Real-time document collaboration
  • Live dashboards: Streaming metrics and analytics
  • Chat applications: Multi-user chat rooms
  • Gaming: Real-time game state synchronization
  • IoT: Device state management
  • Presence systems: Track online users