Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] adapters support for scalability #3

Open
syklevin opened this issue Jul 6, 2019 · 5 comments
Open

[FEATURE REQUEST] adapters support for scalability #3

syklevin opened this issue Jul 6, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@syklevin
Copy link

syklevin commented Jul 6, 2019

Like socketio or signalr, they provide serval adapters such as redis.
Hope neffos could provide the adapter interface. let users could add their own implemention;
And It would be great for builtin support serval great pubsub system like redis and nats

Thanks again for the great library.

@syklevin syklevin added the enhancement New feature or request label Jul 6, 2019
@kataras
Copy link
Owner

kataras commented Jul 7, 2019

Hello @syklevin, neffos already allow users to add their own implementations or wrap an existing one, see the Upgrader and Dialer interfaces that target the Socket interface (I think that is what you are refer to), read wiki at: https://github.com/kataras/neffos/wiki/Upgraders-and-dialers

Tell me if that helped, and if not, please write down how you imagine it to use/API, with go code.

I thank YOU for your support!

@syklevin
Copy link
Author

syklevin commented Jul 8, 2019

thanks for the docs, let me read it deeply and try to make a custom Upgrader.

@kataras
Copy link
Owner

kataras commented Jul 9, 2019

@syklevin Sorry, the Upgraders and Dialers is not the place for that type of implementation (it can be done through it but it requires more boilerplate code at this case). I have to ask you, signalr can keep messages that's why redis is important there on production and to scale out but neffos does not percist messages so there is no data stored in the server-side except the websocket connections and its information like connected namespaces and joined rooms. At the other side, for scaling it may be useful but are we sure is for the best or real need to adapt redis pub sub on neffos as a built-in feature? Because I think you can handle it outside of neffos, inside your app, and just call the specific events based on the connection ID from a redis SUBSCRIBE and do redis PUBLISH from inside neffos events.

Give me some days for R&D and thinking more about the necessity of implement that as built-in package (which will require an external dependency of the redigo library, which is heavy and I really want to keep neffos clean of extra external dependencies) or as a different optional package/repository.

@kataras kataras added the good first issue Good for newcomers label Jul 11, 2019
@kataras
Copy link
Owner

kataras commented Jul 11, 2019

Hey @syklevin , It didn't took long, 1 day asleep and it's ready. It works with redis clusters too (signalR does not). I didn't use the redigo library because it's heavy enough and I wanted other code style for performance boost and subscribe whenever is required, so I used the radix one as I did with iris redis session database for v11.2 - it is not popular like redigo or redis-go but as far as I made my research, he seems a passionate guy and good coder*

Example: https://github.com/kataras/neffos/tree/master/_examples/scale-out

Redis

import "github.com/kataras/neffos/stackexchange/redis"
// [server := neffos.New...]

exc, err := redis.NewStackExchange(redis.Config{}, "MyChatApp")
if err != nil {
	// [...]
}
server.UseStackExchange(exc)

Nats

import "github.com/kataras/neffos/stackexchange/nats"
// [server := neffos.New...]

exc, err := nats.NewStackExchange(":4222" /*, [other optional args here...]*/ )
if err != nil {
	// [...]
}
server.UseStackExchange(exc)

Made with:


Please test it out and tell me if I missed something out or if that was exactly what you were looking for, thanks again!

@syklevin
Copy link
Author

WOW! That is exactly what i looking for. can't wait to try it out and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants