我们正在将我们的应用程序从Rackspace迁移到Modulus。我们有两个应用程序被配置为微服务,使用的是meteorhacks:cluster package。似乎流星方法(server1到server2)调用正常,但流星订阅(client2到server1)不起作用。我正在尝试弄清楚这是否是跨域请求问题。
// https://github.com/meteorhacks/cluster#microservices
//server2/app.js
Cluster.register(process.env.APP_NAME,{endpoint:process.env.ROOT_URL});
mainApp = Cluster.discoverConnection("server1");
Cluster.allowPublicAccess("server1");
//client2/app.js
mainApp = Cluster.discoverConnection("server1");
ContentLibrary= new Meteor.Collection('content_library', {connection:mainApp,idGeneration : 'MONGO'});
//client2/home.js
mainApp.subscribe('contentDocuments','all',function(e){
if(!e)
doSomething();//Never gets called
});
//server1/publish.js
Meteor.publish("contentDocuments", function(){
return ContentLibrary.find({});
}客户端上的ContentLibrary集合永远不会填充。
我们的应用程序在Rackspace上的运行符合预期。
发布于 2016-01-15 03:25:15
我没有使用meteorhacks:cluster,但我正在为我的meteor应用程序运行微服务。它在DO上,所以设置可能会有所不同,但我是这样做的。
我正在使用reactive-publish来帮助处理服务器端的反应性
// client ------
/server/lib/ddp-setup.js
ContentLibrary = DDP.connect('10.123.455.332:3000')
/server/publications.js
Content = new Mongo.Collection('content', {connection: ContentLibrary})
Meteor.publish('content', function(opts){
check(opts, Object)
this.autorun(()=>{
let sub = ContentLibrary.subscribe('content', opts)
if( sub.ready() ){
return Content.find({})
}
})
})
// server1 @ 10.123.455.332:3000 -------
/server/publications.js
Meteor.publish('content', function(opts){
check(opts, Object)
// do something with opts...
return Content.find({})
})这个想法是,您的客户端只与它自己的服务器对话,但服务器随后与您的所有其他微服务进行对话。这为您提供了更高的安全性,允许服务器在专用网络上相互通信(就像我的数字海洋设置一样)。
让服务器通过专用网络相互通信是最好的安全性,而且服务器之间的网络延迟几乎为零。这样设置还意味着您只需担心客户端浏览器和面向web的应用程序/服务之间的粘性会话。
这可能会回答您的问题,也可能不会回答您的问题,但希望它能让您对架构的设置有一些了解。
https://stackoverflow.com/questions/34660949
复制相似问题