Socket
Book a DemoInstallSign in
Socket

mongo_delegate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo_delegate

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

= MongoDelegate

A DelegateCollection wraps a local collection and remote collection in one object that implements the Collection interface.

  • All reads are first done on the local collection, then supplemented by a read on the remote collection, if necessary.
  • All write occur in the local collection. The remote collection is treated as read-only.

This was inspired by things I’ve been told about Goldman Sachs’ proprietary object database. You can point one database at another remote database, and it will function in this manner.

The classic use case is debugging a production problem, or developing while using production data.

  • The annoying way: Generate data that mimics production, get a production dump and load it locally, or “test” in production while walking on eggshells to make sure not to break anything
  • The easy way: Have your local app use a delegating collection that points at the production db. Your app will be using live production data, but all writes occur locally. As writes occur, the app will get your newly written data for those documents. Your app can be oblivious to the delegation and function normally, and you can modify data without fear.

Just create a DelegatingDatabase and pass to your application, wherever you would normally supply a database
db = Mongo::DelegatingDatabase.new(:local => Mongo::Connection.new.db(‘db-name’), :remote => Mongo::Connection.new(‘remote ip’).db(‘db-name’))

Later, anywhere collections are retrieved in your app
coll = db.collection(‘some-collection-name’) # This returns an instance of Mongo::DelegatingCollection

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don’t break it in a
    future version unintentionally.
  • Commit, do not mess with rakefile, version, or history.
    (if you want to have your own version, that is fine but
    bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright © 2010 Mike Harris. See LICENSE for details.

FAQs

Package last updated on 15 Jan 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.