raix:stubfence

v1.0.2Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

raix:stubfence

This tiny package creates a method stub fence, effectivly stops latency compensation temporarily.

Why would you ever do this?

Its an odd egde case we have in grounddb. GroundDB resumes "outstanding" method calls - this is normally not a problem since we previously worked around this by removing data before inserting etc.

But we cannot catch reruns that mutate the data incrementally eg. updating data with $inc, $dec, $push, $pull.

So what we really just wanted to do was a plain old server method only call.

Mongo.Collections are pr. default rigged with client-side method stubs, eg. a collection foo would have following methods rigged on client and server pr. default:

  • /foo/insert
  • /foo/update
  • /foo/remove

For the groundDB project we want code to be as non-intrusive as possible - this makes it easier to maintain eg. relying on core functionallity in Meteor keeps the footprint down.

This package actually reduces the original workaround by approx 50%

How does this work?

On a collection:

1    var foo = new Mongo.Collection('foo');
2
3    foo.stubFence(function() {
4        // All inserts, updates, remove in here will be without
5        // latencycompensation
6        foo.insert({ name: 'foo' });
7    });

On a connection

1    Meteor.connection.stubFence('bar', function() {
2        // If theres a client-side definition / stub for this method it
3        // will be blocked and only run on the server
4        Meteor.call('bar');
5    });

stubFence takes a string or array of strings as methods to fence

Kind regards

Morten (aka RaiX)