package
1.1.0
Repository: https://github.com/compose/transporter.git
Documentation: pkg.go.dev

# README

MongoDB adaptor

The MongoDB adaptor is capable of reading/tailing collections and receiving data for inserts.

NOTE You may want to check your collections to ensure the proper index(es) are in place or performance may suffer.

Example

m = mongodb({
  "uri": "mongodb://127.0.0.1:27017/test"
  // "timeout": "30s",
  // "tail": false,
  // "ssl": false,
  // "cacerts": ["/path/to/cert.pem"],
  // "wc": 1,
  // "fsync": false,
  // "bulk": false,
  // "collection_filters": "{\"foo\": {\"i\": {\"$gt\": 10}}}"
})

Options

ParameterDescriptionDefault
uriDefines the full connection string of the MongoDB database.mongodb://127.0.0.1:27017/test
timeoutOverrides the default session timeout and should be parseable by time.ParseDuration10s
tailWhether the source connection will listen for updates after the initial sync (requires oplog access)false
sslConfigures the database connection to connect via TLSfalse
cacertsConfigures the RootCAs for the underlying TLS connection[]
wcConfigures the write concern option for the session0
fsyncWhether the server will wait for Fsync to complete before returning a responsefalse
bulkWhether the sink connection will use bulk inserts rather than writing one record at a time.false
collection_filtersA JSON string where the top level key is the collection name and its value is a query that will be used when iterating the collection. The commented out example above would only include documents where the i field had a value greater than 10{}

Run adaptor test

Spin up required containers

You'll need those ports on your local machine: 10000, 10001, 27017, 27018, 11112, 29017, 15000, 20000

So make sure to kill anything that might use them (like a local mongo instance)

# From transporter's root folder
version=3.2.11
# Pay attention to a WARNING telling you to add a line to /etc/hosts in the following command
scripts/run_db_in_docker.sh mongodb $version

Run the tests

# From transporter's root folder
go test -v ./adaptor/mongodb/

Tear down containers

Once you're done

TESTDIR=adaptor/mongodb scripts/teardown_db_in_docker.sh