Skip to content

Instantly share code, notes, and snippets.

@jadeallenx
Last active December 15, 2015 12:59
Show Gist options
  • Save jadeallenx/5264113 to your computer and use it in GitHub Desktop.
Save jadeallenx/5264113 to your computer and use it in GitHub Desktop.
Generate pool stanzas for erl.config files. Use with https://github.com/dizzyd/erlang-mysql-driver
use 5.010;
my $user = 'root';
my $pass = 'pass';
my $host = '10.1.2.3';
my $port = '3306';
my %names = (
pool1 => 'db_foo',
pool2 => 'db_bar',
);
my $pool_stanza = qq|
{pool, '%s',
[{connection,
{max, 2},
{database, "%s"},
{host, "$host"},
{port, $port},
{user, "$user"},
{password, "$pass"}
}]
}|;
say join ",", map { sprintf ($pool_stanza, $_, $names{$_}) } sort keys %names;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment