nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
15.91k stars 1.41k forks source link

[refactor]: encapsulate the network logic into internal/network folder #3181

Open xieyuschen opened 2 years ago

xieyuschen commented 2 years ago

Currently, nats-server provides many network protocol support such as mqtt and websocket. But the code management seems not good and it might block the further network feature such as adding quic support.

// this is a mqtt function. func (c client) mqttConnectTrace(cp mqttConnectProto) string {

Instead, we should encapsulate those function like the following.
```go
package websocket
func (c *client) Read(r *wsReadInfo, ior io.Reader, buf []byte) ([][]byte, error) 
package mqtt
func (c *client) ConnectTrace(cp *mqttConnectProto) string

What's worse, all unexported function are visable in server package but they should not. I think it's better to encapsulate the network into a single package to make the code cleaner.

Thanks

xieyuschen commented 2 years ago

For the code coupling, could also see the #3174 . To enable a global logger which binds to the server, we could decouple many functions from the server struct.

Thanks.

derekcollison commented 2 years ago

Will have @kozlovic take a look once back from extended holiday.

xieyuschen commented 2 years ago

Will have @kozlovic take a look once back from extended holiday.

Got it, could I know about the approximate agenda about him? Thanks

derekcollison commented 2 years ago

A few weeks.

derekcollison commented 1 year ago

I am picking this up possibly looking forward to v2.10.0.

xieyuschen commented 1 year ago

I am picking this up possibly looking forward to v2.10.0.

Glad to here it:) Regards