Skip to content

Tocin defiant refactor#1

Draft
dwerner wants to merge 12 commits into
mainfrom
tocin-defiant-refactor
Draft

Tocin defiant refactor#1
dwerner wants to merge 12 commits into
mainfrom
tocin-defiant-refactor

Conversation

@dwerner
Copy link
Copy Markdown
Owner

@dwerner dwerner commented Oct 29, 2025

Reworking the tonic base to use defiant

These planning documents are no longer needed now that the refactor is complete.

Part of refactor: monoio+defiant integration
tocin-defiant-build changes:
- Move defiant-types from dev-dependencies to dependencies
- Required for public API usage

examples changes:
- Switch from tokio to monoio runtime
- Update dependencies for monoio compatibility

tocin-health changes:
- Update for defiant integration

Root Cargo.toml:
- Update workspace configuration

Part of refactor: monoio+defiant integration
tocin-build changes:
- Remove async_trait in favor of associated CallFuture<'arena> type
- Change trait from Send+Sync+'static to just 'static
- Add arena: &'arena defiant::Arena parameter to all service methods
- Remove with_interceptor (requires Send which monoio doesn't provide)
- Convert GrpcService::call to use CallFuture instead of async fn

tocin runtime changes:
- Change BoxError from Box<dyn Error + Send + Sync> to Box<dyn Error>
- Add arena parameter to UnaryService trait
- Thread arena through server::Grpc::unary()
- Export h2 types from codegen for easier access
- Comment out Status insertion into Extensions (requires Send+Sync)

This adapts tocin for monoio's thread-per-core model which has !Send futures.

Part of refactor: monoio+defiant integration
- Use input_has_arena/output_has_arena from Method struct
- Conditionally add <'arena> only to messages that need it
- Messages with borrowed fields get <'arena> parameter
- Messages with only owned fields have no lifetime parameter

This fixes type mismatches where codegen was unconditionally adding
<'arena> to all message types regardless of whether they needed it.

Part of refactor: monoio+defiant integration
- Add Server::bind() and serve() using monoio TcpListener
- Add stub Channel and Endpoint types for client (incomplete)
- Add transport Error type
- Export channel module

These provide basic server transport using monoio's async runtime.
Client transport is stubbed but not fully implemented.

Part of refactor: monoio+defiant integration
- Use monoio::RuntimeBuilder instead of tokio
- Add arena parameter to say_hello implementation
- Use arena.alloc_str() for response message allocation
- Disable client codegen in build.rs (client not yet complete)

Example now demonstrates zero-copy arena allocation pattern.

Part of refactor: monoio+defiant integration
- Add build.rs for proto code generation
- Update lib.rs for new generated service traits
- Add generated code with arena-aware types
- Add generated module exports

Health service now uses defiant messages and arena allocation.

Part of refactor: monoio+defiant integration
Codec changes:
- Use MessageView::from_buf() instead of Decode::decode()
- Returns View types directly (not Builders)
- Remove unused Decode import

Gitignore changes:
- Add context-snapshot.yaml for session management

Part of refactor: monoio+defiant integration
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.

1 participant