Module: Jetpants

Defined in:
lib/jetpants.rb,
lib/jetpants.rb,
lib/jetpants/db.rb,
lib/jetpants/host.rb,
lib/jetpants/pool.rb,
lib/jetpants/shard.rb,
lib/jetpants/table.rb,
lib/jetpants/callback.rb,
lib/jetpants/db/state.rb,
lib/jetpants/topology.rb,
lib/jetpants/db/client.rb,
lib/jetpants/db/server.rb,
lib/jetpants/db/privileges.rb,
lib/jetpants/db/replication.rb,
lib/jetpants/db/import_export.rb

Overview

Namespace for the Jetpants toolkit.

Defined Under Namespace

Modules: CallbackHandler Classes: Callback, CallbackAbortError, DB, Host, Pool, Shard, Table, Topology

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.topologyObject (readonly)

A singleton Jetpants::Topology object is accessible from the global Jetpants module namespace.



48
49
50
# File 'lib/jetpants.rb', line 48

def topology
  @topology
end

Class Method Details

.app_credentialsObject

Returns a hash containing :user => username string, :pass => password string for the MySQL application user, as found in Jetpants’ configuration. Plugins may freely override this if there’s a better way to obtain this password – for example, if you already distribute an application configuration or credentials file to all of your servers.



60
61
62
# File 'lib/jetpants.rb', line 60

def app_credentials
  {user: @config['mysql_app_user'], pass: @config['mysql_app_password']}
end

.method_missing(name, *args, &block) ⇒ Object

Proxy missing top-level Jetpants methods to the configuration hash, or failing that, to the Topology singleton.



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/jetpants.rb', line 76

def method_missing(name, *args, &block)
  if @config.has_key? name.to_s
    @config[name.to_s]
  elsif name.to_s[-1] == '=' && @config.has_key?(name.to_s[0..-2])
    var = name.to_s[0..-2]
    @config[var] = args[0]
  elsif @topology.respond_to? name
    @topology.send name, *args, &block
  else
    super
  end
end

.plugin_enabled?(plugin_name) ⇒ Boolean

Returns true if the specified plugin is enabled, false otherwise.

Returns:

  • (Boolean)


51
52
53
# File 'lib/jetpants.rb', line 51

def plugin_enabled?(plugin_name)
  !!@config['plugins'][plugin_name]
end

.replication_credentialsObject

Returns a hash containing :user => username string, :pass => password string for the MySQL replication user, as found in Jetpants’ configuration. Plugins may freely override this if there’s a better way to obtain this password – for example, by parsing master.info on a specific slave in your topology. SEE ALSO: DB#replication_credentials, which only falls back to the global version when needed.



70
71
72
# File 'lib/jetpants.rb', line 70

def replication_credentials
  {user: @config['mysql_repl_user'], pass: @config['mysql_repl_password']}
end

.respond_to?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/jetpants.rb', line 89

def respond_to?(name, include_private=false)
  super || @config[name] || @topology.respond_to?(name)
end