All Projects → mongodb-labs → Mongoproxy

mongodb-labs / Mongoproxy

A server that speaks the MongoDB wire protocol and can analyze/transform requests and responses - This Repository is NOT a supported MongoDB product

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Mongoproxy

Ppspider
web spider built by puppeteer, support task-queue and task-scheduling by decorators,support nedb / mongodb, support data visualization; 基于puppeteer的web爬虫框架,提供灵活的任务队列管理调度方案,提供便捷的数据保存方案(nedb/mongodb),提供数据可视化和用户交互的实现方案
Stars: ✭ 237 (+355.77%)
Mutual labels:  mongodb, proxy
Smtpd
A Lightweight High Performance ESMTP email server
Stars: ✭ 175 (+236.54%)
Mutual labels:  mongodb, proxy
Codeigniter Mongodb Library
CodeIgniter MongoDB library based on PHP 7.1+
Stars: ✭ 47 (-9.62%)
Mutual labels:  mongodb
Mongomem
In-memory MongoDB Server. Ideal for testing.
Stars: ✭ 51 (-1.92%)
Mutual labels:  mongodb
Shadowsocks Qt5
A cross-platform shadowsocks GUI client
Stars: ✭ 7,893 (+15078.85%)
Mutual labels:  proxy
Ldap Auth Proxy
A simple drop-in HTTP proxy for transparent LDAP authentication which is also a HTTP auth backend.
Stars: ✭ 48 (-7.69%)
Mutual labels:  proxy
Restfulapi
flask-restful 中小型项目实例
Stars: ✭ 50 (-3.85%)
Mutual labels:  mongodb
Express Mvc Boilerplate
A simple mvc boilerplate for express.js (gulp + expressjs + nodemon + browser-sync)
Stars: ✭ 46 (-11.54%)
Mutual labels:  mongodb
Proxykit
A toolkit to create code-first HTTP reverse proxies on ASP.NET Core
Stars: ✭ 1,063 (+1944.23%)
Mutual labels:  proxy
V2ray Core
A platform for building proxies to bypass network restrictions.
Stars: ✭ 13,438 (+25742.31%)
Mutual labels:  proxy
Icinema
A Full Stack MERN app with CRUD operations for theatres where users can search for movies that are available and admin can add a movie to the list and much more.
Stars: ✭ 51 (-1.92%)
Mutual labels:  mongodb
Mongo Thingy
🍃 The most idiomatic and friendly-yet-powerful way to use MongoDB with Python
Stars: ✭ 49 (-5.77%)
Mutual labels:  mongodb
Sslkill
Forced Man-In-The-Middle HTTPs-Avoiding Reverse Proxy
Stars: ✭ 48 (-7.69%)
Mutual labels:  proxy
Pythem
pentest framework
Stars: ✭ 1,060 (+1938.46%)
Mutual labels:  proxy
Awesome Recommendation Engine
The purpose of this tiny project is to put things together with the know how that i learned from the course big data expert from formacionhadoop.com The idea is to show how to play with apache spark streaming, kafka,mongo, spark machine learning algorithms.
Stars: ✭ 47 (-9.62%)
Mutual labels:  mongodb
Orleans.providers.mongodb
A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
Stars: ✭ 51 (-1.92%)
Mutual labels:  mongodb
Mqtt Mongo
A generic service that subscribes to MQQT broker and saves messages to MongoDB.
Stars: ✭ 46 (-11.54%)
Mutual labels:  mongodb
Capturepacket
Capture http/https packets for Android. Android端网络抓包工具。
Stars: ✭ 49 (-5.77%)
Mutual labels:  proxy
Aclify
🔒 Node Access Control Lists (ACL).
Stars: ✭ 49 (-5.77%)
Mutual labels:  mongodb
Megalodon
Mastodon, Pleroma and Misskey API client library for node.js and browser
Stars: ✭ 52 (+0%)
Mutual labels:  proxy

Mongoproxy

A server that speaks the MongoDB wire protocol, and can analyze and transform requests and responses to and from a client and a MongoDB server instance. All requests go through a module pipeline, and modules include a proxy to send requests to mongod, as well as a module to collect real-time analytics about the requests passing through the server.

Building and running

To grab dependencies (should not be necessary, as dependencies are checked into the repository):

chmod 755 ./vendor.sh # only needs to be done once
./vendor.sh

Note that currently, mongoproxy requires a specific fork of mgo because it requires some features not yet pulled into the main repo.

To run:

chmod 755 ./start.sh # only needs to be done once
./start.sh <options>

start.sh sets up the go path, and runs the main/server.go file. It's equivalent to the following two commands:

. ./set_gopath.go
go run main/server.go

Configurations

Configurations tell the server which modules to load and run, and also specifies configurations for each module. They can either be a document in a MongoDB instance (as BSON), or a JSON file in the local directory.

By default, the server expects a mongod instance to be running on localhost:27017 with a configuration document in the test.config collection. The location for the configuration document can be set as a command line option, and can also be a file.

Configurations have one field modules, which is an array. Each object in the array has a name field for the name of the module, and a config field for the module's configuration.

A configuration can be found in the project directory named example_bi_config.json, which is run with the following command:

./start.sh -f example_bi_config.json

Command Line Options

-port 		Port number to run the server on. Defaults to 8124.
-logLevel 	Sets verbosity of the logs from 1 to 5, with 1 being least verbose and 5 being the most. Defaults to 3.
-m 			URL of a mongod server to connect to to retrieve configuration information from. Defaults to localhost:27017
-c 			Namespace of the collection in the mongod server to retrieve configuration information from. Defaults to test.config
-f 			Path to a configuration file. If set, the m and c flags are ignored.

Tests

To run unit tests:

chmod 755 ./test.sh
./test.sh

To run integration tests:

# single test
node tests/test <js file to test>

# a directory full of test files
node tests/test_dir <directory of files to test>

Modules

The only thing that the server does to requests is to translate them into a Go struct. Everything else happens in a module.

Usage

The server can use modules that are defined in its configuration.

All modules have a unique name to identify them, which is also used in the name field of the configuration. Requests are passed from module to module in the order defined in the configuration, and the response sent to the server, and finally back up to the client.

The following modules are implemented and included in the source:

mockule 	A mock module that stores insert requests in memory and can dump them back out. It also pretends it is a 1-node replica set.
mongod 		A module that forwards the request to a MongoDB instance and passes back the response to the server.
bi 			A module with pre-configured rules that analyzes requests and aggregates them into metrics.

Developing Modules

All modules implement the Module interface, defined in server/modules.go. Configure() is called at the server startup, and Process(req, res, next) is called every time a request passes through the server.

A module is responsible for calling the next module in the pipeline via the next argument in the Process function, which is a function that takes two arguments: a request and a response.

Modules also have to be added to the registry in order for the server to know they exist. Each module should live in their own package, and have an init function with the following line:

server.Publish(<Module>)

where server is the imported github.com/mongodbinc-interns/mongoproxy/server package.

Then, in the server/registry.go file, add the import path of the module to the file preceded by an underscore, to add the module to the registry.

Example Module

package examplemodule

import (
	"github.com/mongodbinc-interns/mongoproxy/messages"
	"github.com/mongodbinc-interns/mongoproxy/server"
	"gopkg.in/mgo.v2/bson"
)

type ExampleModule struct {
}

func init() {
	server.Publish(ExampleModule{})
}

func (m ExampleModule) Name() string {
	return "find-only"
}

func (m ExampleModule) Configure(config bson.M) error {
	// configure the module here. Returns an error if configuration fails
	return nil
}

// this module will drop all requests except for Find requests
func (m ExampleModule) Process(req messages.Requester, res messages.Responder,
next server.PipelineFunc) {
	switch req.Type() {
	case messages.FindType:
		// send the request and response to the next module
		next(req, res)
	default:
		res.Write(<Request dropped>)
		return
}

This module can then be run with a configuration like the following:

{
	"modules": [
		...
		{
			"name": "find-only",
			"config": {}
		},
		...
	]
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].