monet v0.0.9 Monet.Connection

Represents a connection (a socket) to the MonetDB Server.

Although this can be accessed directy (staring with conn/1), the intention is for it to be accessed via the Monet module (which manages a pool of these connections).

Link to this section Summary

Functions

Connects to the MonetDB server. See Monet.start_link/1 for available options (although some of the options listed there such as pool_size are specific to the Monet pool and not this individual connection).

In Elixir, every socket is assigned a "controlling" process. This is to control the destination of incoming data when the socket is in active mode. We don't use active mode (but we might leverage it in the future).

Get the name of the pool this connection belongs tos

A query with no arguments is executed as a simple query. A query with arguments is executed as a prepare + exec + deallocate.

Runs fun in a transaction. Automaticaly starts and commits/rollsback the transaction.

Link to this section Functions

Connects to the MonetDB server. See Monet.start_link/1 for available options (although some of the options listed there such as pool_size are specific to the Monet pool and not this individual connection).

Link to this macro

connection(args \\ [])

(macro)
Link to this macro

connection(record, args)

(macro)
Link to this function

controlling_process(conn, pid)

In Elixir, every socket is assigned a "controlling" process. This is to control the destination of incoming data when the socket is in active mode. We don't use active mode (but we might leverage it in the future).

Still, it appears that the socket is also tied to the lifetime of the controlling process, so we do have to set this once in Monet.init_worker.

Link to this function

pool_name(conn)

Get the name of the pool this connection belongs tos

Link to this function

query(conn, sql, args \\ nil)

A query with no arguments is executed as a simple query. A query with arguments is executed as a prepare + exec + deallocate.

Query does not mutate the conn, but conn is returned nonetheless (along with the result or error). The returned conn can be nil, which indicates that the connection can no longer be used.

Link to this function

transaction(conn, fun)

Runs fun in a transaction. Automaticaly starts and commits/rollsback the transaction.

When called through the pool (that is via Monet.transaction/1) the connection is automatically closed (and thus the transaction rolledback) on an exception.

If calling this directly, it is up to the caller to deal with exceptions.