Skip to content

Stream#

lit.sdk.services.stream #

This module defines the Stream class and associated functions for managing real-time data-streaming services. It provides functionality to start, stop, restart, and retrieve the status of streams, as well as a function to get a list of available streams.

Stream #

Bases: Service

Represents a real-time data-streaming service worker.

name instance-attribute #

The name of the Stream.

team instance-attribute #

The name of the team that owns the Stream.

__init__(team, name) #

Initializes a new instance of Stream.

Parameters:

Name Type Description Default
team str

The name of the team that owns the Stream.

required
name str

The name of the Stream.

required

restart() #

Restarts the stream.

Returns:

Type Description
ServiceActionStatus

An object containing the status of the operation.

Examples:

>>> stream = Stream("contoso", "bitcoin")
>>> stream.restart()
{'status': 'SUCCESS', 'message': 'Stream restarted successfully.'}

start() #

Starts the stream.

Returns:

Type Description
ServiceActionStatus

An object containing the status of the operation.

Examples:

>>> stream = Stream("contoso", "bitcoin")
>>> stream.start()
{'status': 'SUCCESS', 'message': 'Stream started successfully.'}

status() #

Retrieves the status of the stream.

Returns:

Type Description
ServiceStatus

An object containing the current status of the stream.

Examples:

>>> stream = Stream("contoso", "bitcoin")
>>> stream.status()
{'name': 'bitcoin', 'active': 'active', 'status': 'running', 'started': 'Wed 2024-07-24 13:32:23 CDT', 'pid': 3687984, 'tasks': 5, 'memory': '3.3G'}

stop() #

Stops the stream.

Returns:

Type Description
ServiceActionStatus

An object containing the status of the operation.

Examples:

>>> stream = Stream("contoso", "bitcoin")
>>> stream.stop()
{'status': 'SUCCESS', 'message': 'Stream stopped successfully.'}

get_streams(team) #

Gets a list of the available streams.

Parameters:

Name Type Description Default
team str

The name of the team.

required

Returns:

Type Description
list[Stream]

List of available streams.

Examples:

>>> get_streams("contoso")
[Stream(team='contoso', name='bitcoin')]