Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1kbgz Tributary Streaming Input Sources

From Leeroopedia
Knowledge Sources
Domains Streaming, Data_Ingestion
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete streaming source classes for producing data into Tributary streaming pipelines, provided by the Tributary library.

Description

The input source classes (Timer, Const, Func, Curve, Random, Console, Queue) are subclasses of the streaming Node class. They wrap Python callables, static values, generators, and async generators into async streaming nodes that yield values on a schedule. Timer is the base class that periodically calls a callable count times with a delay of interval seconds. Const wraps a scalar, Func wraps an arbitrary callable, Curve unrolls an iterable, Random yields simulated market data, Console reads from stdin, and Queue emits values from an asyncio Queue.

External input sources (File, HTTP, Kafka, Postgres, WebSocket, SSE, SocketIO, Subprocess) are provided in sibling modules and follow the same pattern.

Usage

Import these classes when you need to define the origin of a streaming data pipeline. Use Timer or Func for periodic callable invocation, Const for a fixed scalar, Random for test data, Console for interactive input, and Queue for inter-task communication. For network and file sources, import the corresponding classes from their respective modules.

Code Reference

Source Location

  • Repository: Tributary
  • File: tributary/streaming/input/input.py

Signature

class Timer(Node):
    def __init__(self, func, func_kwargs=None, count=1, interval=0, **kwargs):
        ...

class Const(Timer):
    def __init__(self, value, count=0, **kwargs):
        ...

class Curve(Timer):
    def __init__(self, value, **kwargs):
        ...

class Func(Timer):
    def __init__(self, func, func_kwargs=None, count=0, interval=0, **kwargs):
        ...

class Random(Func):
    def __init__(self, count=10, interval=0.1, **kwargs):
        ...

class Console(Func):
    def __init__(self, message="", json=False, **kwargs):
        ...

class Queue(Func):
    def __init__(self, queue, **kwargs):
        ...

Import

from tributary.streaming import Timer, Const, Func, Curve, Random, Console, Queue
# or from individual modules:
from tributary.streaming.input.input import Timer, Const, Func, Curve, Random, Console, Queue

I/O Contract

Inputs

Name Type Required Description
func callable Yes (Timer, Func) Python callable (function, generator, async function, or async generator)
func_kwargs dict No Static keyword arguments for the callable
value any Yes (Const, Curve) Scalar value (Const) or iterable (Curve)
count int No Number of times to call; 0 means infinite
interval int/float No Minimum delay between calls in seconds
queue asyncio.Queue Yes (Queue) Asyncio queue to receive values from
message str No (Console) Prompt message for console input
json bool No (Console) Parse console input as JSON

Outputs

Name Type Description
return Node A streaming Node instance that yields values as an async stream

Usage Examples

Timer Source

import tributary.streaming as ts

# Emit the current time every 1 second, 5 times
import time
source = Timer(func=time.time, count=5, interval=1)

# Wire to Print and run
out = ts.Print(source)
ts.run(out)

Const Source

import tributary.streaming as ts

# Emit a constant value 3 times
source = Const(value=42, count=3)
out = ts.Print(source)
ts.run(out)
# Output: 42, 42, 42

Func Source with Generator

import tributary.streaming as ts

# Use a generator function as a source
def counter():
    i = 0
    while True:
        yield i
        i += 1

source = Func(func=counter, count=10, interval=0.1)
out = ts.Print(source)
ts.run(out)

Random Source

import tributary.streaming as ts

# Emit 20 random market data dicts at 0.1s intervals
source = Random(count=20, interval=0.1)
out = ts.Print(source)
ts.run(out)

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment