Skip to content

Commit

Permalink
Rename a collection "manager" to "connection".
Browse files Browse the repository at this point in the history
  • Loading branch information
awwx authored and glasser committed May 6, 2013
1 parent 1f76275 commit 6c8a4b5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 34 deletions.
4 changes: 2 additions & 2 deletions docs/client/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ Template.api.meteor_collection = {
descr: "The name of the collection. If null, creates an unmanaged (unsynchronized) local collection."}
],
options: [
{name: "manager",
{name: "connection",
type: "Object",
descr: "The Meteor connection that will manage this collection, defaults to `Meteor` if null. Unmanaged (`name` is null) collections cannot specify a manager."
descr: "The Meteor connection that will manage this collection, defaults to `Meteor` if null. Unmanaged (`name` is null) collections cannot specify a connection."
},
{name: "idGeneration",
type: "String",
Expand Down
18 changes: 9 additions & 9 deletions packages/livedata/livedata_connection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ if (Meteor.isClient) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});

// setup method
conn.methods({do_something: function (x) {
Expand Down Expand Up @@ -438,7 +438,7 @@ if (Meteor.isClient) {
startAndConnect(test, stream);

var coll_name = Random.id();
var coll = new Meteor.Collection(coll_name, {manager: conn});
var coll = new Meteor.Collection(coll_name, {connection: conn});

// setup methods
conn.methods({
Expand Down Expand Up @@ -522,7 +522,7 @@ Tinytest.add("livedata stub - reconnect", function (test) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});

var o = observeCursor(test, coll.find());

Expand Down Expand Up @@ -650,7 +650,7 @@ if (Meteor.isClient) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});
var o = observeCursor(test, coll.find());

conn.methods({writeSomething: function () {
Expand Down Expand Up @@ -823,7 +823,7 @@ Tinytest.add("livedata stub - reconnect method which only got data", function (t
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});
var o = observeCursor(test, coll.find());

// Call a method. We'll get the data-done message but not the result before
Expand Down Expand Up @@ -909,7 +909,7 @@ if (Meteor.isClient) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});
var o = observeCursor(test, coll.find());

conn.methods({
Expand Down Expand Up @@ -996,7 +996,7 @@ if (Meteor.isClient) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});

conn.methods({
insertSomething: function () {
Expand Down Expand Up @@ -1138,7 +1138,7 @@ Tinytest.add("livedata connection - two wait methods", function (test) {
startAndConnect(test, stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});

// setup method
conn.methods({do_something: function (x) {}});
Expand Down Expand Up @@ -1526,7 +1526,7 @@ if (Meteor.isClient) {
var conn = newConnection(stream);

var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});

// Start and send "connect", but DON'T get 'connected' quite yet.
stream.reset(); // initial connection start.
Expand Down
2 changes: 1 addition & 1 deletion packages/livedata/livedata_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ if (Meteor.isClient) {
var conn = new Meteor._LivedataConnection('/',
{reloadWithOutstanding: true});
var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var coll = new Meteor.Collection(collName, {connection: conn});
var errorFromRerun;
var gotErrorFromStopper = false;
return [
Expand Down
2 changes: 1 addition & 1 deletion packages/madewith/madewith.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var server = Meteor.connect("madewith.meteor.com");
var sub = server.subscribe("myApp", hostname);

// minimongo collection to hold my singleton app record.
var apps = new Meteor.Collection('madewith_apps', {manager: server});
var apps = new Meteor.Collection('madewith_apps', {connection: server});

server.methods({
vote: function (hostname) {
Expand Down
42 changes: 23 additions & 19 deletions packages/mongo-livedata/collection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manager, if given, is a LivedataClient or LivedataServer
// connection, if given, is a LivedataClient or LivedataServer
// XXX presently there is no way to destroy/clean up a Collection

Meteor.Collection = function (name, options) {
Expand All @@ -7,13 +7,17 @@ Meteor.Collection = function (name, options) {
throw new Error('use "new" to construct a Meteor.Collection');
if (options && options.methods) {
// Backwards compatibility hack with original signature (which passed
// "manager" directly instead of in options. (Managers must have a "methods"
// "connection" directly instead of in options. (Connections must have a "methods"
// method.)
// XXX remove before 1.0
options = {manager: options};
options = {connection: options};
}
// Backwards compatibility: "connection" used to be called "manager".
if (options && options.manager && !options.connection) {
options.connection = options.manager;
}
options = _.extend({
manager: undefined,
connection: undefined,
idGeneration: 'STRING',
transform: null,
_driver: undefined,
Expand Down Expand Up @@ -45,13 +49,13 @@ Meteor.Collection = function (name, options) {
"the collection name to turn off this warning.)");
}

// note: nameless collections never have a manager
self._manager = name && (options.manager ||
// note: nameless collections never have a connection
self._connection = name && (options.connection ||
(Meteor.isClient ?
Meteor.default_connection : Meteor.default_server));

if (!options._driver) {
if (name && self._manager === Meteor.default_server &&
if (name && self._connection === Meteor.default_server &&
Meteor._RemoteCollectionDriver)
options._driver = Meteor._RemoteCollectionDriver;
else
Expand All @@ -61,11 +65,11 @@ Meteor.Collection = function (name, options) {
self._collection = options._driver.open(name);
self._name = name;

if (name && self._manager.registerStore) {
if (name && self._connection.registerStore) {
// OK, we're going to be a slave, replicating some remote
// database, except possibly with some temporary divergence while
// we have unacknowledged RPC's.
var ok = self._manager.registerStore(name, {
var ok = self._connection.registerStore(name, {
// Called at the beginning of a batch of updates. batchSize is the number
// of update calls to expect.
//
Expand Down Expand Up @@ -166,10 +170,10 @@ Meteor.Collection = function (name, options) {

// autopublish
if (!options._preventAutopublish &&
self._manager && self._manager.onAutopublish)
self._manager.onAutopublish(function () {
self._connection && self._connection.onAutopublish)
self._connection.onAutopublish(function () {
var handler = function () { return self.find(); };
self._manager.publish(null, handler, {is_auto: true});
self._connection.publish(null, handler, {is_auto: true});
});
};

Expand Down Expand Up @@ -324,7 +328,7 @@ _.each(["insert", "update", "remove"], function (name) {
args[0] = Meteor.Collection._rewriteSelector(args[0]);
}

if (self._manager && self._manager !== Meteor.default_server) {
if (self._connection && self._connection !== Meteor.default_server) {
// just remote to another endpoint, propagate return value or
// exception.

Expand All @@ -341,12 +345,12 @@ _.each(["insert", "update", "remove"], function (name) {
// asynchronous: on success, callback should return ret
// (document ID for insert, undefined for update and
// remove), not the method's result.
self._manager.apply(self._prefix + name, args, function (error, result) {
self._connection.apply(self._prefix + name, args, function (error, result) {
callback(error, !error && ret);
});
} else {
// synchronous: propagate exception
self._manager.apply(self._prefix + name, args);
self._connection.apply(self._prefix + name, args);
}

} else {
Expand All @@ -362,7 +366,7 @@ _.each(["insert", "update", "remove"], function (name) {
throw e;
}

// on success, return *ret*, not the manager's return value.
// on success, return *ret*, not the connection's return value.
callback && callback(null, ret);
}

Expand Down Expand Up @@ -497,7 +501,7 @@ Meteor.Collection.prototype._defineMutationMethods = function() {
self._prefix = '/' + self._name + '/';

// mutation methods
if (self._manager) {
if (self._connection) {
var m = {};

_.each(['insert', 'update', 'remove'], function (method) {
Expand Down Expand Up @@ -553,8 +557,8 @@ Meteor.Collection.prototype._defineMutationMethods = function() {
// Minimongo on the server gets no stubs; instead, by default
// it wait()s until its result is ready, yielding.
// This matches the behavior of macromongo on the server better.
if (Meteor.isClient || self._manager === Meteor.default_server)
self._manager.methods(m);
if (Meteor.isClient || self._connection === Meteor.default_server)
self._connection.methods(m);
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/mongo-livedata/mongo_livedata_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ if (Meteor.isServer) {
var self = this;
if (self.conn.status().connected) {
self.miniC = new Meteor.Collection("ServerMinimongo_" + self.id, {
manager: self.conn
connection: self.conn
});
var exp = expect(function (err) {
test.isFalse(err);
Expand Down Expand Up @@ -933,7 +933,7 @@ if (Meteor.isServer) {
var self = this;
if (self.conn.status().connected) {
self.miniC = new Meteor.Collection("ServerMinimongoObserve_" + self.id, {
manager: self.conn
connection: self.conn
});
var exp = expect(function (err) {
test.isFalse(err);
Expand Down

0 comments on commit 6c8a4b5

Please sign in to comment.