-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Supports Provider-side asynchronous #1511
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughIntroduces an example async RPC service (interface, impl, client, server) under tests. Adds BoltAsyncContext to manage server-side async responses, handling context switch/reset and single-send enforcement. Updates BoltServerProcessor to attach the incoming request into RpcInternalContext for async handling. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant B as Bolt Transport
participant S as Service (HelloServiceImpl)
participant T as Worker Thread
participant AC as BoltAsyncContext
C->>B: sayHello("world")
B->>S: invoke(request)
Note over S: Processor attaches request to RpcInternalContext
S->>S: create BoltAsyncContext
S->>T: spawn async task
S-->>B: return (no immediate response)
rect rgba(220, 235, 255, 0.5)
note over T,AC: Async phase (server-side)
T->>AC: signalContextSwitch()
T->>AC: write("Hello world") or writeException(e)
AC-->>B: sendResponse(SofaResponse)
AC->>AC: resetContext()
end
B-->>C: SofaResponse (result or exception)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (2)remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/server/bolt/BoltServerProcessor.java (1)
remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/message/bolt/BoltAsyncContext.java (8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
core/api/src/main/java/com/alipay/sofa/rpc/common/RemotingConstants.java
(1 hunks)example/src/test/java/com/alipay/sofa/rpc/serviceasync/HelloService.java
(1 hunks)example/src/test/java/com/alipay/sofa/rpc/serviceasync/HelloServiceImpl.java
(1 hunks)example/src/test/java/com/alipay/sofa/rpc/serviceasync/start/Client.java
(1 hunks)example/src/test/java/com/alipay/sofa/rpc/serviceasync/start/Service.java
(1 hunks)remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/message/bolt/BoltAsyncContext.java
(1 hunks)remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/server/bolt/BoltServerProcessor.java
(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-08T06:59:23.963Z
Learnt from: EvenLjj
PR: sofastack/sofa-rpc#1488
File: remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java:105-120
Timestamp: 2025-05-08T06:59:23.963Z
Learning: In SOFA RPC, TripleTracerAdapter.serverReceived() sets the invocation type on the SofaRequest based on the gRPC method type (CLIENT_STREAMING, SERVER_STREAMING, BIDI_STREAMING), but the SofaRequest.isAsync() method does not directly recognize these streaming types as asynchronous. According to EvenLjj, some modification in TripleTracerAdapter.serverReceived makes sofaRequest.isAsync() return true for streaming requests.
Applied to files:
remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/server/bolt/BoltServerProcessor.java
🧬 Code graph analysis (4)
example/src/test/java/com/alipay/sofa/rpc/serviceasync/HelloServiceImpl.java (1)
remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/message/bolt/BoltAsyncContext.java (1)
BoltAsyncContext
(31-116)
remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/server/bolt/BoltServerProcessor.java (3)
core/api/src/main/java/com/alipay/sofa/rpc/common/RpcConstants.java (1)
RpcConstants
(28-747)core/common/src/main/java/com/alipay/sofa/rpc/common/utils/CommonUtils.java (1)
CommonUtils
(30-278)core/api/src/main/java/com/alipay/sofa/rpc/common/RemotingConstants.java (1)
RemotingConstants
(27-269)
example/src/test/java/com/alipay/sofa/rpc/serviceasync/start/Client.java (2)
core/api/src/main/java/com/alipay/sofa/rpc/config/ConsumerConfig.java (1)
ConsumerConfig
(71-1044)core/api/src/main/java/com/alipay/sofa/rpc/log/LoggerFactory.java (1)
LoggerFactory
(29-70)
example/src/test/java/com/alipay/sofa/rpc/serviceasync/start/Service.java (3)
core/api/src/main/java/com/alipay/sofa/rpc/config/ProviderConfig.java (1)
ProviderConfig
(55-561)core/api/src/main/java/com/alipay/sofa/rpc/config/ServerConfig.java (1)
ServerConfig
(66-909)example/src/test/java/com/alipay/sofa/rpc/serviceasync/HelloServiceImpl.java (1)
HelloServiceImpl
(21-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: sca
example/src/test/java/com/alipay/sofa/rpc/serviceasync/HelloServiceImpl.java
Show resolved
Hide resolved
remoting/remoting-bolt/src/main/java/com/alipay/sofa/rpc/message/bolt/BoltAsyncContext.java
Show resolved
Hide resolved
Each time we use |
What I mean is, if you use isAsyncChain in BoltAsyncContext, you'll achieve the same effect. So creating another isServerAsync seems redundant. n the thread model, these two also seem to have the same meaning: ignoring the return value of the current thread invoker. |
I think you are right, and I did it. |
Supports Provider-side asynchronous
支持服务端异步调用
Summary by CodeRabbit
New Features
Documentation