Closed dickens7 closed 1 month ago
增加 NilCallServerMessageHandler func(msg *protocol.Message) 支持自定义服务器消息的处理 目的是可以自行控制 服务器 SendMessage的消息 和 RPC reply消息顺序处理问题
NilCallServerMessageHandler func(msg *protocol.Message)
如下代码:
期望先处理 abcde 再处理 reply, 当前 bidirectional 方式是一个 chan 无法保证这种顺序问题 通过 NilCallServerMessageHandler 就可以自行在业务逻辑中处理这种场景
abcde
chan
type Bidirectional struct { *server.Server } func (t *Bidirectional) Mul(ctx context.Context, args *Args, reply *Reply) error { conn := ctx.Value(server.RemoteConnContextKey).(net.Conn) t.SendMessage(conn, "test_service_path", "test_service_method", nil, []byte("abcde")) reply.C = args.A * args.B return nil }
增加
NilCallServerMessageHandler func(msg *protocol.Message)
支持自定义服务器消息的处理 目的是可以自行控制 服务器 SendMessage的消息 和 RPC reply消息顺序处理问题如下代码:
期望先处理
abcde
再处理 reply, 当前 bidirectional 方式是一个chan
无法保证这种顺序问题 通过 NilCallServerMessageHandler 就可以自行在业务逻辑中处理这种场景