Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

refactor!: migrate from streamstore to s2-sdk#183

Merged
quettabit merged 1 commit intomainfrom
qb/rest-take-2
Jan 16, 2026
Merged

refactor!: migrate from streamstore to s2-sdk#183
quettabit merged 1 commit intomainfrom
qb/rest-take-2

Conversation

@quettabit
Copy link
Member

No description provided.

@quettabit
Copy link
Member Author

@greptileai review this draft

@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile Summary

Major Refactoring: CLI Architecture Restructuring

This PR represents a comprehensive architectural refactoring of the S2 CLI, migrating from the streamstore crate to the new s2-sdk crate. The changes consolidate and reorganize the codebase into a cleaner, more maintainable module structure.

Key Changes:

Module Reorganization:

  • New cli.rs (652 lines): Consolidates all CLI argument definitions and command structures
  • New ops.rs (762 lines): Centralizes all S2 API operations, replacing scattered service modules
  • Refactored main.rs (806 lines, down from ~1900): Simplified command routing and output formatting
  • Renamed formats.rsrecord_format.rs: Clarifies module purpose

Deleted Modules:

  • account.rs, basin.rs, stream.rs, ping.rs: Functionality merged into ops.rs

Package Updates:

  • Replaced streamstore (0.20.0) → s2-sdk (0.22.2)
  • Added strum and tabled crates for enum utilities and table formatting
  • Updated tracing-subscriber (0.3.19 → 0.3.20)
  • Added preserve_order feature to serde_json

Design Improvements:

  • Better separation of concerns: CLI parsing, operations, configuration, and error handling
  • Trait-based abstractions in record_format.rs for extensibility
  • Centralized error types with helpful diagnostics using miette
  • Strong typing for S2 URIs with comprehensive parsing and validation

Architecture Flow:

`cli.rs` (CLI parsing) → `main.rs` (routing) → `ops.rs` (SDK calls) → `s2-sdk` (API communication)

The refactoring successfully reduces coupling between modules and improves code organization, making the codebase more maintainable for future development.

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations around SDK integration testing and command completeness verification
  • The refactoring is well-executed with clear separation of concerns and proper error handling. The new module structure is logical and maintainable. The main concern is the significant shift from the old streamstore crate to s2-sdk requires verification that all command behaviors are preserved. The changes to error handling, configuration, and output formatting appear sound. No syntax errors or critical logic issues were detected. However, the WIP status suggests incomplete testing/integration work.
  • All modified files appear well-implemented. Focus verification on: main.rs for completeness of all command handlers, ops.rs to ensure all SDK integration points work correctly with the new s2-sdk API, and integration testing of the new architecture with the s2-sdk crate.

Important Files Changed

Filename Overview
src/cli.rs New file that consolidates CLI argument definitions and command structures using clap derive API. Cleanly separated from main.rs. Properly defines all subcommands with appropriate arg groups and helps.
src/main.rs Refactored significantly. Now ~800 lines (down from ~1900). Cleaner module organization with command routing and output formatting. Good separation of concerns. Key issue: appears to have deleted old module references (account, basin, stream, formats, ping) without comprehensive review of all command handlers (truncated output prevents full analysis).
src/ops.rs New comprehensive operations module (762 lines) consolidating all S2 API interactions. Well-structured with clear separation between basin, stream, token, metrics, and record operations. Uses futures and streaming abstractions appropriately.
src/config.rs Clean configuration management module. Added Compression enum with proper serialization support. Functions for load/save/get/set operations are straightforward. Proper error handling with helpful messages.
src/error.rs Well-organized error types using thiserror and miette. Clear error variants with helpful diagnostics. OpKind enum properly categorizes operations. S2UriParseError and OpGroupsParseError handle domain-specific parsing errors.
src/types.rs Comprehensive custom types for CLI. S2 URI parsing (S2BasinUri, S2BasinAndStreamUri) is robust with proper error handling. Configuration types (BasinConfig, StreamConfig) are well-designed. Some complexity with enum variants but overall sound design.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as cli.rs
    participant Main as main.rs
    participant Config as config.rs
    participant Ops as ops.rs
    participant SDK as s2-sdk
    
    User->>CLI: Parse args
    CLI->>Main: Send command
    
    alt Config Commands
        Main->>Config: List/Get/Set/Unset
        Config->>Config: Read/Write TOML
    else Stream Operations
        Main->>Config: Load CLI config
        Config->>Config: Read from file + env
        Main->>Config: Build SDK config
        Main->>SDK: Initialize S2
        
        Main->>Ops: list_basins/create_basin/...
        Ops->>SDK: Call SDK methods
        SDK-->>Ops: Return results
        Ops-->>Main: Return stream/result
        
        Main->>Main: Format output
        Main->>User: Display result
    end

Loading

@quettabit quettabit changed the title [WIP] refactor!: migrate from streamstore to s2-sdk Jan 16, 2026
@quettabit quettabit marked this pull request as ready for review January 16, 2026 08:10
@quettabit quettabit requested a review from a team as a code owner January 16, 2026 08:10
@quettabit quettabit merged commit 3da8d1f into main Jan 16, 2026
3 of 4 checks passed
@quettabit quettabit deleted the qb/rest-take-2 branch January 16, 2026 08:10
@greptile-apps
Copy link

greptile-apps bot commented Jan 17, 2026

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant