Skip to content

Move data streams into their own crate#1227

Merged
1egoman merged 20 commits into
mainfrom
data-streams-refactor
Jul 9, 2026
Merged

Move data streams into their own crate#1227
1egoman merged 20 commits into
mainfrom
data-streams-refactor

Conversation

@1egoman

@1egoman 1egoman commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Breaks out a subset of the changes from #1192 into a pull request which exclusively moves the existing data streams implementation into its own crate, livekit-data-streams, and adds a new livekit-common crate (kept fairly minimal for now) for common utilities which livekit-data-streams and livekit both need.

This is largely being scoped to a "lift and shift" type effort, more extensive refactoring of the livekit-data-streams crate will be done in #1192.

Breaking changes

There should not be any breaking changes from the perspective of livekit's public api. If so, please surface them.

Testing

This pull request adds the relevant v1 data streams tests from #1192. More test coverage will be introduced as a follow up in the data streams v2 change.

@1egoman 1egoman requested a review from ladvoc as a code owner July 7, 2026 20:23
@1egoman 1egoman marked this pull request as draft July 7, 2026 20:23
@1egoman 1egoman removed the request for review from ladvoc July 7, 2026 20:23
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Changeset

The following package versions will be affected by this PR:

Package Bump
livekit patch
livekit-ffi patch

devin-ai-integration[bot]

This comment was marked as resolved.

@1egoman 1egoman force-pushed the data-streams-refactor branch from 1e4e420 to 4492d6e Compare July 7, 2026 20:57
Comment thread livekit-data-stream/src/incoming.rs
Comment thread livekit/src/room/data_stream/mod.rs
Comment thread livekit/src/utils/take_cell.rs
Comment thread livekit-data-stream/src/lib.rs
Comment on lines +9 to +15

[features]
# End-to-end testing hooks (exposes is_compressed/is_inline on stream info). Forwarded from
# the `livekit` crate's `__lk-e2e-test` feature.
__e2e-test = []
# Exposes constructors used by downstream crates' test suites (e.g. `TextStreamReader::new_for_test`).
test-utils = []

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: should these be separate features or just one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to keep them, they should be separate (I plan to eventually drop the special feature for E2E testing and instead just skip E2E tests based on env).

However, there's the bigger question of if we should be using non-public methods in integration tests in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, there's the bigger question of if we should be using non-public methods in integration tests in the first place.

Right now, that's how it works so I don't think this makes it worse. IMO I'd rather decouple that conversation and revisit as part of the data streams v2 pull request since I will be making some more extensive updates there.

@1egoman 1egoman Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to keep them, they should be separate (I plan to eventually drop the special feature for E2E testing and instead just skip E2E tests based on env).

I've combined them into one feature for now, test-utils.

Comment thread livekit-data-stream/src/lib.rs
@ladvoc

ladvoc commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

suggestion: To prevent future abuse of the livekit-common crate, it might be a good idea to describe it in AGENTS.md (or add a new one scoped to the crate) laying out what belongs here and what doesn't (e.g., lightweight functions, types, etc.).

mgr.handle_chunk(chunk("s1", 0, text.as_bytes().to_vec()), EncType::None);
mgr.handle_trailer(trailer("s1"));
assert_eq!(read_text(reader).await.unwrap(), text);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notable improvement: I've added in an initial set of data streams v1 unit tests which exercises some happy paths in the data streams outgoing manager and data streams incoming manager. These will be further developed as part of the data streams v2 pull request.

Comment thread livekit/src/room/mod.rs
1egoman and others added 2 commits July 8, 2026 13:43
Co-authored-by: Jacob Gelman <3182119+ladvoc@users.noreply.github.com>
@1egoman

1egoman commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

suggestion: To prevent future abuse of the livekit-common crate, it might be a good idea to describe it in AGENTS.md (or add a new one scoped to the crate) laying out what belongs here and what doesn't (e.g., lightweight functions, types, etc.).

Done in 4445b08

@1egoman 1egoman marked this pull request as ready for review July 8, 2026 17:50
@1egoman 1egoman requested a review from ladvoc July 8, 2026 17:54
devin-ai-integration[bot]

This comment was marked as resolved.

@1egoman 1egoman requested a review from jhugman July 8, 2026 18:02
Comment thread livekit-common/src/lib.rs
thiserror = { workspace = true }
parking_lot = { workspace = true }
bytes = { workspace = true }
tokio = { workspace = true, default-features = false, features = ["sync", "fs", "io-util", "rt"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Outside the scope of this PR and a pre-existing issue, but we should only depend on tokio with the sync feature unconditionally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, I will investigate in the data-streams-v2 follow up pull request.

@xianshijing-lk xianshijing-lk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work, lgtm

@1egoman 1egoman merged commit 05cc5a4 into main Jul 9, 2026
29 checks passed
@1egoman 1egoman deleted the data-streams-refactor branch July 9, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants