dongma2388 2017-07-03 15:19
浏览 93
已采纳

基本的客户端/服务器体系结构和交互

I'm trying to implement a client and server and define their interactions. The client is designed using Golang, the server is designed in Node.js, and they interact using gRPC.

So the basic gist is:

  1. Client contacts server to update backend DB
  2. Client receives success response from server
  3. Client then itself changes the state of the overall system that the DB now reflects

But say something were to happen such that the process dies between steps 2 and 3 (Client process is terminated somehow). What is the best way to ensure that my backend DB doesn't reflect a system state that is inconsistent with reality? I'm sure this isn't a novel problem and would just like a couple pointers to how people typically cope with this type of design.

So I've already thought of redesigning this interaction such that the server is the entity that will handle the system changes— that way everything is handled in the same request and on the backend— but I'm using an open source technology that is designed in Go (so I can easily wrap it in my Go client). In other words, the client must be the entity that performs that system-change operation.

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • douqian9729 2017-07-03 17:02
    关注
    1. The client ACKs (responds to server) that it has also updated local state to be synchronous with the server.

    If 4. doesn't happen, then the server rolls back the transaction done in 1. and the entire operation of 1 - 4 is atomic.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog