Sagas complicate API design (Sagas 使 API 设计 复杂化 )
Synchronous API vs Asynchronous Saga
Request initiates the saga. When to send back the response?
Option #1: Send response when saga completes:
+ Response specifies the outcome - Reduced availability
选择一:saga完成的时候发送响应
Option #2: Send response immediately after creating the saga
(recommended)
选择二:创建saga之后马上发送响应(推荐)
+ Improved availability(提高可用性)
- Response does not specify the outcome. Client must poll or be notified
(响应没有指定结果。必须轮询或通知Client端)
使用Sagas,可能影响用户体验。
UI界面向用户隐藏异步API
如果需要更长的时间, 用户界面显示“处理中”弹出窗口
服务器可以将通知推送到UI