如何设计一个流星智能包来透明地将一个应用程序分成不同的实例? [英] How to design a meteor smart package to transparently separate an app into different instances?

查看:17
本文介绍了如何设计一个流星智能包来透明地将一个应用程序分成不同的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常熟悉 Meteor 架构的人的问题.

This is a question for those who are very familiar with Meteor's architecture.

我正在尝试设计一个可以透明地运行 Meteor 应用程序的多个副本"的智能包.也就是说,给定一个现有的 Meteor 应用程序和几个预定义的用户组,该包可以半自动地隔离"应用程序 - 以对于每组用户的方式运行它,似乎只有那些用户是使用应用.

I am trying to design a smart package that can transparently run several "copies" of a Meteor app. That is, given an existing Meteor app, and several predefined groups of users, the package can semi-automagically "segregate" the app - run it in a way that for each group of users, it appears that only those users are using the app.

我了解此功能可以针对任何应用程序进行定制设计.但是,考虑到 Meteor 的 Collections 和所有的使用,我正在寻找最直接的方式让智能包在任何现有应用程序之上提供此功能.因此,它或多或少应该满足以下条件:

I understand that this functionality could be custom designed for any application. However, I'm looking for the most straightforward way for a smart package to provide this functionality on top of any existing app, taking into account the use of Meteor's Collections and all. Hence, it should more or less satisfy the following:

  • 它应该和普通的 Meteor 应用一样高效.
  • 将现有的 Meteor 应用程序转换为使用此系统应该需要最少的代码修改.
  • 该包不应修改或覆盖 Meteor,并且相对面向未来.

以下是我针对此问题考虑的一些方法和相应的缺点:

Here are some approaches and corresponding drawbacks I've thought about for this problem:

  • 使用常规 Meteor 应用程序的所有集合,并使用代表用户所在组的附加 ID 标记每个文档.每个用户的发布/订阅仅提取具有相同组 ID 的文档.
  • 覆盖 Meteor.Collection(或实现相同的接口),使其了解这些不同的组,并且从客户端的角度来看,它的行为就好像当前用户的组是整个应用程序.
  • Use all the collections of the regular Meteor app, and tag each document with an additional id representing the group that the user is in. The publications/subscriptions for each user only pull the documents with the same group id.
  • Override Meteor.Collection (or implement an identical interface) in a way that makes it aware of these different groups, and from the client perspective it behaves as if the current user's group is the entire app.

我正在从真正了解 Meteor 系统的人那里寻找好主意.我如何设计此功能,使绝大多数 Meteor 应用程序都可以轻松转换为使用它(即避免非常脆弱的疯狂黑客攻击),但在 Meteor 上实施起来又简单又高效?

I'm looking for good ideas here from someone who really knows Meteor's system. How can I design this functionality in a way that the vast majority of Meteor apps can be easily converted to work with it (i.e. avoid crazy hacks that are very brittle) yet is straightforward and efficient to implement on top of Meteor?

(如果你是纽约地区的流星大师,我很乐意带你出去吃饭讨论这个!)

(If you are a Meteor guru in the NYC area, I would be happy to take you out to dinner to discuss this!)

推荐答案

我已经着手解决这个问题,并将其放入 Meteor 智能包中.它满足我在问题中指出的所有要求.有关更多详细信息,请参阅文档和说明.

I've taken my work on this problem and pulled it out into a Meteor smart package. It satisfies all the requirements I noted in my question. For more details, see the documentation and instructions.

https://github.com/mizzao/meteor-partitioner

因为我已经在实践中使用过它,所以代码非常稳定并且有一组很好的测试.欢迎提出意见和贡献.

Because I've been using this in practice already, the code is pretty stable and has a good set of tests. Comments and contributions are welcome.

使用它的包示例如下:

https://github.com/HarvardEconCS/turkserver-meteor

这篇关于如何设计一个流星智能包来透明地将一个应用程序分成不同的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆