1 package OpenSRF::Utils::SettingsClient;
2 use OpenSRF::Utils::SettingsParser;
4 use OpenSRF::AppSession;
5 use OpenSRF::Utils::Config;
6 use OpenSRF::EX qw(:try);
8 use vars qw/$host_config/;
11 sub new {return bless({},shift());}
15 # ------------------------------------
16 # utility method for grabbing config info
20 if(!$host_config) { grab_host_config($host); }
22 throw OpenSRF::EX::Config ("Unable to retrieve host config for $host" );
25 my $hash = $host_config;
27 # XXX TO DO, check local config 'version',
28 # call out to settings server when necessary....
31 $hash = $hash->{$key};
36 throw OpenSRF::EX::Config ("No Config information for @keys : $e : $@");
44 # XXX make smarter and more robust...
45 sub grab_host_config {
49 OpenSRF::System::bootstrap_client("system_client");
50 $session = OpenSRF::AppSession->create( "settings" ) unless $session;
51 my $bsconfig = OpenSRF::Utils::Config->current;
56 if( ! ($session->connect()) ) {die "Settings Connect timed out\n";}
57 my $req = $session->request( "opensrf.settings.host_config.get", $host );
58 $resp = $req->recv( timeout => 10 );
60 } catch OpenSRF::EX with {
63 warn "Connection to Settings Failed $e : $@ ***\n";
68 warn "No Response from settings server...going to sleep\n";
72 if( $resp && UNIVERSAL::isa( $resp, "OpenSRF::EX" ) ) {
76 $host_config = $resp->content();