chatr / redpubsub Goto Github PK
View Code? Open in Web Editor NEWCustom pub/sub system for Meteor on top of Redis
Custom pub/sub system for Meteor on top of Redis
Sorry my bad english.
i write small test app:
server.js
RPS.config.Messages = {
fetchFields: ['clientId'],
channels: function (selector, fields) {
return 'messageToClientId:' + fields.clientId ;
}
};
Meteor.publish('messages', function (clientId) {
RPS.publish(this, {
collection: Messages,
options: {
selector: {clientId: clientId},
channel: 'messageToClientId:' + clientId
}
});
});
client.js
Meteor.startup(function () {
var clientId = localStorage.getItem('clientID') ;
if(clientId) {
Session.set('myID', clientId);
} else {
clientId = Random.id() ;
localStorage.setItem('clientID', clientId);
Session.set('myID', clientId);
}
Meteor.subscribe('messages', clientId);
});
Template.hello.helpers({
chatData: function(){
return Messages.find();
},
clientId: function(){
return Session.get('myID');
}
});
Template.hello.events({
'submit form': function(event, template) {
event.preventDefault();
var toClient = template.find('#clientID').value;
var msg = template.find('#message').value;
RPS.write(Messages, 'insert', {
doc: {
message: msg,
ts: Date.now(),
clientId: toClient,
fromClient: Session.get('myID')
}
});
}
});
After submit form mongo create new record in Message collection.
But this new record does not appear in other client, subscription is not working.
Record appears only after the page is updated.
What i'm doing wrong?
Turns out when trying to tie in a pub/sub using withoutMongo: true, our messages never get sent out again to subscribers, yet a manual PSUBSCRIBE in redis on the same channel picked them up fine. We later discovered the cause was not having an id on the original message object.
The offending line from observe-changes.js:
ids = !message.id || _.isArray(message.id) ? message.id : [message.id];
I've made an id from our specific use case, but can we please add some validation and / or remove the requirement for an id (object hash + timestamp + rand() ?) in this scenario please?
=> Errors while initializing project:
While selecting package versions:
error: No version of ddp-server satisfies all constraints: @=2.3.1, @~2.4.0
Constraints on package "ddp-server":
I see that you created a new interface to perform mongo reads and writes--couldn't you just monkey patch Meteor to use your system instead. That way we developers don't have to change how they perform mongo calls?
What about doing things like overriding Meteor.publish? I.e. So the interface is the same as what you are used to. Could you use your system completely in place of Meteor's?
What are the caveats? Why did meteor not pursue this implementation to begin with and instead chose LiveQuery?
Hey there I have a conversation going in the Meteor forum that you may be very well suited to lead:
If the redis url does not work, this package crashes the app and causes the meteor container on galaxy I have deployed to keep restarting.
First does it have to crash the app if the url does not work?
Second, is there a way to specify a failover url?
Any advice in this regards would be greatly appreciated! Thanks
Hello guys I believe this is an awesome package. We began working on something similar: https://github.com/cult-of-coders/redis-oplog without knowing there was work done in this direction. So we had to re-invent some stuff. However I looked through your code and I love it. Would you be interested in discussing more about this ?
Should this be used with disable-oplog package or not?
https://atmospherejs.com/meteor/disable-oplog
please see below
regards,
$ meteor update --release 1.5.1
=> Errors while initializing project:
While selecting package versions:
error: Conflict: Constraint [email protected] is not satisfied by ddp-server 2.0.0.
Constraints on package "ddp-server":
- [email protected] <- top level
- [email protected] <- chatra:redpubsub 0.9.19
Please, write small example how it works.
Thanks )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.