go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Can I create WS service in rpc?

Open shrkx opened this issue 1 year ago • 8 comments

需求:我需要在rpc的服务里面创建ws的服务,因为我需要在其他的服务里面进行消息的发送,通过grpc进行发送ws的消息

现有的是api有ws的服务

1662552115948

shrkx avatar Sep 07 '22 12:09 shrkx

I don't think it's a good practice to do that.

Use WS in api services.

kevwan avatar Sep 08 '22 04:09 kevwan

我认为这样做不是一个好习惯。

在 api 服务中使用 WS。

但是我需要后台的其他的服务,推送ws的消息的时候怎么处理呢?

shrkx avatar Sep 08 '22 04:09 shrkx

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I don't think this is a good practice.

Use WS in the api service.

But I need other services in the background, what should I do when I push ws messages?

Issues-translate-bot avatar Sep 08 '22 04:09 Issues-translate-bot

I think a reasonable route: client -> api(ws) -> rpc

chenquan avatar Sep 08 '22 09:09 chenquan

我认为合理的路线: client-> api(ws)->rpc

业务的逻辑需要的线路是: rpc -> ws 其他的服务发送任务的时候需要进行同步推送ws的消息

shrkx avatar Sep 08 '22 10:09 shrkx

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I think a reasonable route: client-> api(ws)->rpc

The line required by the business logic is: rpc -> ws When other services send tasks, they need to push ws messages synchronously

Issues-translate-bot avatar Sep 08 '22 10:09 Issues-translate-bot

It's nothing to do with RPC. You just need to send messages to the clients through WS.

In spite of RPC or HTTP services, you need to know the WS connections where to send the messages.

kevwan avatar Sep 11 '22 15:09 kevwan

Also, in case of single direct push notification, use MQ instead.

genewoo avatar Sep 12 '22 16:09 genewoo

why not use rpc stream instead of it?

Suyghur avatar Oct 11 '22 03:10 Suyghur

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Mar 14 '24 01:03 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 18 '24 01:06 github-actions[bot]