module TwistlockControl

TwistLockControl main module.

Configure TwistlockControl by calling `TwistlockControl.configure` and passing it a block in which you set the attributes.

Update this for releases

Constants

VERSION

Attributes

connection_pool_size[RW]
connection_pool_timeout[RW]
database_name[RW]
rethinkdb_host[RW]
rethinkdb_port[RW]

Public Class Methods

configure() { |self| ... } click to toggle source
# File lib/twistlock_control.rb, line 25
def configure
        yield self

        set_defaults

        setup_connection_pool
end
database() click to toggle source
# File lib/twistlock_control.rb, line 33
def database
        RethinkDB::RQL.new.db(database_name)
end
with_connection() { |conn| ... } click to toggle source
# File lib/twistlock_control.rb, line 37
def with_connection
        @connection_pool.with do |conn|
                yield conn
        end
end

Private Class Methods

set_defaults() click to toggle source
# File lib/twistlock_control.rb, line 45
def set_defaults
        @connection_pool_size ||= 5
        @connection_pool_timeout ||= 5
        @rethinkdb_host ||= 'localhost'
        @rethinkdb_port ||= 28_015
        @database_name ||= 'twistlock-control'
end
setup_connection_pool() click to toggle source
# File lib/twistlock_control.rb, line 53
def setup_connection_pool
        @connection_pool = ConnectionPool.new(
                size:    connection_pool_size,
                timeout: connection_pool_timeout
        ) do
                RethinkDB::Connection.new(
                        host: rethinkdb_host,
                        port: rethinkdb_port
                )
        end
end