Skip to content

Simplify lifetime management #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 11, 2025
Merged

Simplify lifetime management #347

merged 7 commits into from
Jun 11, 2025

Conversation

Mr3zee
Copy link
Collaborator

@Mr3zee Mr3zee commented Jun 2, 2025

Strict mode Migration
A series of changes to simplify kRPC protocol

  • Remove fields support
  • Remove stream scopes
  • Simplify lifetime management
  • Cold RPC clients creation
  • Deprecated declarations cleanup
  • Documentation update for previous changes

Subsystem
kRPC

Problem Description
Lifetimes now have a hierarchy. We decided to abandon this approach.

Solution
Remove complex hierarchy of requests.
One of the side effects:

  • Service on client-server are now 1-to-n instead of 1-to-1.

@Mr3zee Mr3zee self-assigned this Jun 2, 2025
@Mr3zee Mr3zee added breaking Contains breaking changes deprecation Contains derecations labels Jun 2, 2025
@Mr3zee Mr3zee changed the base branch from main to remove-stream-scopes June 2, 2025 16:17
@Mr3zee Mr3zee force-pushed the lifetime branch 2 times, most recently from 0066ed8 to 935af81 Compare June 6, 2025 14:27
@Mr3zee Mr3zee marked this pull request as ready for review June 10, 2025 14:33
@Mr3zee Mr3zee requested a review from e5l June 10, 2025 14:33
@e5l e5l requested a review from Copilot June 11, 2025 07:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies lifetime management in the kRPC protocol by removing the complex inheritance hierarchy and related fields. Key changes include:

  • Eliminating inheritance from CoroutineScope in RpcServer and RpcClient while updating the service factory signatures.
  • Deprecating and removing the RemoteService interface along with its coroutineContext-related properties.
  • Removing support code that auto-injects RemoteService as a supertype, including associated compiler plugin components.

Reviewed Changes

Copilot reviewed 193 out of 193 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/commonMain/kotlin/kotlinx/rpc/annotations/Rpc.kt Removed explicit RemoteService inheritance from annotated interfaces and updated sample code.
core/src/commonMain/kotlinx/rpc/RpcServer.kt Changed serviceFactory signature and removed CoroutineScope inheritance; documentation remains outdated.
core/src/commonMain/kotlinx/rpc/RpcClient.kt Removed CoroutineScope and Deferred usage; documentation still refers to CoroutineScope lifetime.
core/src/commonMain/kotlinx/rpc/RemoteService.kt Deprecated the RemoteService interface and removed its CoroutineScope dependency.
core/api/core.api Updated API definitions to reflect removed coroutine context parameters.
Compiler plugin files Removed several supertype generator files and updated diagnostic messages and checkers accordingly.
compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcStubGenerator.kt Removed coroutineContext property generation from RPC stub code.
Remaining compiler-plugin files Adjusted references to removed properties and methods related to lifetime/coroutineContext.
Comments suppressed due to low confidence (2)

core/src/commonMain/kotlin/kotlinx/rpc/RpcServer.kt:14

  • The documentation comment still mentions [CoroutineScope] defines server lifetime, but RpcServer no longer extends CoroutineScope. Please update the comment to reflect the current lifetime management approach.
 * Server may contain multiple services. [CoroutineScope] defines server lifetime.

core/src/commonMain/kotlin/kotlinx/rpc/RpcClient.kt:17

  • The documentation comment for RpcClient still refers to CoroutineScope for defining its lifetime, but the interface no longer extends CoroutineScope. Please update the comment accordingly.
 * [CoroutineScope] defines the lifetime of the client.

@Mr3zee Mr3zee force-pushed the remove-stream-scopes branch from 126ec96 to d9dc982 Compare June 11, 2025 08:53
Base automatically changed from remove-stream-scopes to enforce-strict-mode June 11, 2025 08:53
@Mr3zee Mr3zee merged commit ac827a1 into enforce-strict-mode Jun 11, 2025
1 check passed
@Mr3zee Mr3zee deleted the lifetime branch June 11, 2025 08:55
Mr3zee added a commit that referenced this pull request Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Contains breaking changes deprecation Contains derecations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants