MongoX v0.1.2 Mongo.Pool behaviour
Defines a pool of MongoDB connections.
A pool can be defined as:
defmodule MyPool do
use Mongo.Pool,
adapter: Mongo.Pool.Poolboy,
hostname: "localhost"
end
Options will be passed to the pool adapter and to Mongo.Connection
.
Logging
The pool may define a log/5
function, that will be called by the
driver on every call to the database.
Please refer to the callback’s documentation for more information.
Summary
Functions
Invokes given pool’s run/1
gathering information necessary for the pools
log/5
function
Callbacks
Called every time when the driver has a logging information to be printed
Executes given function checking out a connection from pool, and ensuring it will be properely checked in back once finished
Returns the version of the MongoDB wire protocol used for the pool’s connections
Types
Functions
Callbacks
Specs
Called every time when the driver has a logging information to be printed.
The first argument result can be of form: :ok
, {:ok, _}
or {:error, _}
.
The second element of the tuples should be considered private, and not used.
Operations
The fourth argument determines the operation, these can be (listed with the arguments passed as the fifth argument to the log function):
Operation | Arguments |
---|---|
:run_command | [query, options] |
:insert_one | [collection, document, options] |
:insert_many | [collection, documents, options] |
:delete_one | [collection, filter, options] |
:delete_many | [collection, filter, options] |
:replace_one | [collection, filter, replacement, options] |
:update_one | [collection, filter, update, options] |
:update_many | [collection, filter, update, options] |
:find | [collection, query, projection, options] |
:find_rest | [collection, cursor, options] |
:kill_cursors | [cursors, options] |
Specs
run((pid -> return)) :: {queue_time :: time, return} when return: var
Executes given function checking out a connection from pool, and ensuring it will be properely checked in back once finished.