Bio-KBase
view release on metacpan or search on metacpan
lib/Bio/KBase/IDServer/Impl.pm view on Meta::CPAN
package Bio::KBase::IDServer::Impl;
use strict;
=head1 NAME
IDServerAPI
=head1 DESCRIPTION
The KBase ID provides access to the mappings between KBase identifiers and
external identifiers, the original identifiers for data that was migrated from
other databases into the KBase.
=cut
#BEGIN_HEADER
use Try::Tiny;
use Config::Simple;
use Data::Dumper;
use MongoDB;
use strict;
use base 'Class::Accessor';
__PACKAGE__->mk_accessors(qw(conn db coll_data coll_next));
sub _init_instance
{
my($self) = @_;
my $host;
if (my $e = $ENV{KB_DEPLOYMENT_CONFIG})
{
my $service = $ENV{KB_SERVICE_NAME};
my $c = Config::Simple->new();
$c->read($e);
$host = $c->param("$service.mongodb-host");
}
if (!$host)
{
$host = "mongodb.kbase.us";
warn "No deployment configuration found; falling back to $host";
}
my $conn;
try {
$conn = MongoDB::Connection->new(host => $host);
} catch {
die "Error connecting to MongoDB server on $host: $_";
};
my $db = $conn->idserver_db;
my $coll_data = $db->data;
my $coll_next = $db->next;
$self->conn($conn);
$self->db($db);
$self->coll_data($coll_data);
$self->coll_next($coll_next);
$coll_data->ensure_index({ext_name => 1, ext_id => 1});
$coll_data->ensure_index({kb_id => 1});
$coll_next->ensure_index({prefix => 1});
}
#END_HEADER
sub new
{
my($class, @args) = @_;
my $self = {
};
bless $self, $class;
#BEGIN_CONSTRUCTOR
#END_CONSTRUCTOR
if ($self->can('_init_instance'))
( run in 1.353 second using v1.01-cache-2.11-cpan-39bf76dae61 )