Skip to content

[Rust] Split sdk/src/lib.rs into per-concern modules#414

Merged
teodordelibasic-db merged 2 commits into
mainfrom
rust/split-lib-rs
Jun 26, 2026
Merged

[Rust] Split sdk/src/lib.rs into per-concern modules#414
teodordelibasic-db merged 2 commits into
mainfrom
rust/split-lib-rs

Conversation

@teodordelibasic-db

Copy link
Copy Markdown
Collaborator

What changes are proposed in this pull request?

sdk/src/lib.rs had grown to roughly 1800 lines, holding the crate root,
the ZerobusSdk client, and the entire ZerobusStream implementation in one
file. This change breaks it apart into focused modules along two axes: the SDK
client versus the stream, and within the stream, one file per concern. There
is no public API change.

lib.rs now keeps only the crate root: module declarations, the public
pub use re-exports, and the small shared types (StreamType,
TableProperties, ZerobusResult). Everything else moved out:

  • sdk.rs — the ZerobusSdk client: the shared gRPC channel, TLS and proxy
    setup, and stream_builder / recreate_stream.
  • stream/mod.rs — the stream parent module, organized per transport.
  • stream/grpc/ — the gRPC transport, with ZerobusStream and its behavior
    split by concern.

Layout under stream/grpc/:

File Concern Boundary
mod.rs ZerobusStream struct, constructor, Drop gRPC-specific
types.rs Internal types (IngestRequest, channel messages) Transport-agnostic
ingest.rs Public ingest_* methods Transport-agnostic
acks.rs flush, wait_for_offset, unacked queries Transport-agnostic
close.rs close, is_closed, task shutdown Transport-agnostic
callback_handler.rs User-callback dispatch task Transport-agnostic
connection.rs gRPC bidirectional stream setup gRPC-specific
sender.rs Outbound gRPC sender task gRPC-specific
receiver.rs Inbound gRPC receiver task gRPC-specific
supervisor.rs Create, spawn, recover loop gRPC-specific

How is this tested?

  • cargo build and cargo build --all-features
  • cargo clippy --all-features
  • cargo test --all-features
  • cargo fmt --check

@teodordelibasic-db teodordelibasic-db requested a review from a team June 24, 2026 10:24
@teodordelibasic-db teodordelibasic-db self-assigned this Jun 24, 2026
@teodordelibasic-db teodordelibasic-db added the refactoring Refactoring & tech debt label Jun 24, 2026
@zlata-stefanovic-db zlata-stefanovic-db linked an issue Jun 24, 2026 that may be closed by this pull request
@zlata-stefanovic-db

Copy link
Copy Markdown
Contributor

Linked the ticket for this: #34

@danilonajkov-db danilonajkov-db left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, lets not delay merging this as you will always get a lot of conflicts :)

Comment thread rust/sdk/src/stream/grpc/mod.rs Outdated
// `stream/grpc/`) per Rust's visibility rules. That is what we want — no
// external crate or other module should reach into stream internals.
/// Logical landing zone that stores records the user has submitted but the sender task has not yet placed on the wire.
landing_zone: Arc<LandingZone<Box<IngestRequest>>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can use the type from types.rs for this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I had to resolve merge conflicts so I fixed this as well.

Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com>
Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com>
@teodordelibasic-db teodordelibasic-db added this pull request to the merge queue Jun 26, 2026
Merged via the queue into main with commit 88dbfa6 Jun 26, 2026
34 checks passed
@teodordelibasic-db teodordelibasic-db deleted the rust/split-lib-rs branch June 26, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring & tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Rust] Code reorganization

3 participants