forked from meteorhacks/kadira
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove meteorhacks:meteorx dependency.
This commit brings the relevant bits of meteorhacks:meteorx into the mdg:meteor-apm-agent package, so that various issues can be fixed without forking or continuing to maintain meteorhacks:meteorx. Related: meteor/meteor#10337 (comment) meteorhacks/meteorx#8 meteorhacks/meteorx#9 abecks/meteor-fast-render#25
- Loading branch information
Showing
7 changed files
with
194 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Various tricks for accessing "private" Meteor APIs borrowed from the | ||
// now-unmaintained meteorhacks:meteorx package. | ||
|
||
export const Server = Meteor.server.constructor; | ||
|
||
function getSession() { | ||
const fakeSocket = { | ||
send() {}, | ||
close() {}, | ||
headers: [] | ||
}; | ||
|
||
const server = Meteor.default_server; | ||
|
||
server._handleConnect(fakeSocket, { | ||
msg: "connect", | ||
version: "pre1", | ||
support: ["pre1"] | ||
}); | ||
|
||
const session = fakeSocket._meteorSession; | ||
|
||
server._removeSession(session); | ||
|
||
return session; | ||
} | ||
|
||
const session = getSession(); | ||
export const Session = session.constructor; | ||
|
||
const collection = new Mongo.Collection("__dummy_coll_" + Random.id()); | ||
collection.findOne(); | ||
const cursor = collection.find(); | ||
export const MongoCursor = cursor.constructor; | ||
|
||
function getMultiplexer(cursor) { | ||
const handle = cursor.observeChanges({ | ||
added() {} | ||
}); | ||
handle.stop(); | ||
return handle._multiplexer; | ||
} | ||
|
||
export const Multiplexer = getMultiplexer(cursor).constructor; | ||
|
||
export const MongoConnection = | ||
MongoInternals.defaultRemoteCollectionDriver().mongo.constructor; | ||
|
||
function getSubscription(session) { | ||
const subId = Random.id(); | ||
|
||
session._startSubscription(function () { | ||
this.ready(); | ||
}, subId, [], "__dummy_pub_" + Random.id()); | ||
|
||
const subscription = session._namedSubs instanceof Map | ||
? session._namedSubs.get(subId) | ||
: session._namedSubs[subId]; | ||
|
||
session._stopSubscription(subId); | ||
|
||
return subscription; | ||
} | ||
|
||
export const Subscription = getSubscription(session).constructor; | ||
|
||
function getObserverDriver(cursor) { | ||
const multiplexer = getMultiplexer(cursor); | ||
return multiplexer && multiplexer._observeDriver || null; | ||
} | ||
|
||
function getMongoOplogDriver() { | ||
const driver = getObserverDriver(cursor); | ||
let MongoOplogDriver = driver && driver.constructor || null; | ||
if (MongoOplogDriver && | ||
typeof MongoOplogDriver.cursorSupported !== "function") { | ||
return null; | ||
} | ||
return MongoOplogDriver; | ||
} | ||
|
||
export const MongoOplogDriver = getMongoOplogDriver(); | ||
|
||
function getMongoPollingDriver() { | ||
const cursor = collection.find({}, { | ||
limit: 20, | ||
_disableOplog: true, | ||
}); | ||
|
||
const driver = getObserverDriver(cursor); | ||
|
||
// verify observer driver is a polling driver | ||
if (driver && typeof driver.constructor.cursorSupported === "undefined") { | ||
return driver.constructor; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
export const MongoPollingDriver = getMongoPollingDriver(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,14 +88,23 @@ Package.on_test(function(api) { | |
function configurePackage(api) { | ||
if(api.versionsFrom) { | ||
api.versionsFrom('[email protected]'); | ||
api.use('meteorhacks:[email protected]', ['server']); | ||
api.use('meteorhacks:[email protected]', {weak: true}); | ||
} | ||
|
||
api.use([ | ||
'minimongo', 'livedata', 'mongo-livedata', 'ejson', 'ddp-common', | ||
'underscore', 'http', 'email', 'random' | ||
'ecmascript', | ||
'mongo', | ||
'minimongo', | ||
'livedata', | ||
'mongo-livedata', | ||
'ejson', | ||
'ddp-common', | ||
'underscore', | ||
'http', | ||
'email', | ||
'random', | ||
], ['server']); | ||
|
||
api.use(['underscore', 'random', 'http', 'localstorage'], ['client']); | ||
|
||
// common before | ||
|
Oops, something went wrong.