-
-
Notifications
You must be signed in to change notification settings - Fork 52
Scale out
Gerasimos (Makis) Maropoulos edited this page Jul 14, 2019
·
2 revisions
Scale out through StackExchange interface and its completors is a feature that was implemented at neffos v0.0.6.
Made after a user feature request* with the five following commits:
- New feature: Scale-out using Redis built-in StackExchange implementation
- Add the ability to register and use more than one StackExchange
- Add nats StackExchange and scale-out example
- Add nats support for the new Server.Ask method
- Add redis support for the new Server.Ask method
- Export nats subject prefix
Scaling out a neffos app can be achieved by adding just three extra lines of code(!)
- Import
github.com/kataras/neffos/stackexchange/redis
ornats
- Initialize the StackExchange, e.g.
exc := redis.NewStackExchange(...)
- Right after the server := neffos.New add
server.UseStackExchange(exc)
.
Each StackExchange contains its own configuration.
How it works
- Each client connected to a neffos namespace is subscribed a channel/subject and unsubscribes itself on namespace disconnection.
- Each time a neffos Broadcast is called the message directly goes to the registered StackExchange.Publish method, which takes care to publish the message to the correct channel/subject, so subscribers can be notified about this message.
- Each time a subscriber notified for a new message its Conn.Write is responsible to dispatch that message to the client side.
- The same pattern is used for one to one messaging and Server.Ask.
Use this feature when you have multiple neffos servers hosted independently for a particular neffos app of yours and you want your app to be able to communicate with all of those neffos servers as one.
Next steps
Home | About | Project | Getting Started | Technical Docs | Copyright © 2019-2023 Gerasimos Maropoulos. Documentation terms of use.