Changeset 11778 for lang/perl/Punc/trunk

Show
Ignore:
Timestamp:
05/17/08 20:38:17 (6 months ago)
Author:
mizzy
Message:

r68@puppet: miya | 2008-05-16 02:12:11 +0900


Location:
lang/perl/Punc/trunk/lib/Punc
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Punc/trunk/lib/Punc/Client.pm

    r11777 r11778  
    4545        module => $module, 
    4646    }); 
     47 
     48    return $client->init; 
    4749} 
    4850 
  • lang/perl/Punc/trunk/lib/Punc/Client/Request.pm

    r11749 r11778  
    99our $AUTOLOAD; 
    1010 
    11 sub new { 
    12     my ( $class, $args ) = @_; 
     11use Moose; 
    1312 
    14     my $confdir = $args->{conf}->{confdir}; 
     13has 'conf'   => ( is => 'rw', isa => 'HashRef' ); 
     14has 'hosts'  => ( is => 'rw', isa => 'ArrayRef' ); 
     15has 'module' => ( is => 'rw', isa => 'Str' ); 
     16has 'method' => ( is => 'rw', isa => 'Str' ); 
     17has 'args'   => ( is => 'rw', isa => 'HashRef' ); 
     18 
     19has 'client' => ( 
     20    is      => 'rw', 
     21    isa     => 'JSON::RPC::Client', 
     22    default => sub { JSON::RPC::Client->new }, 
     23); 
     24 
     25sub init { 
     26    my ( $self, $args ) = @_; 
     27 
     28    my $confdir = $self->conf->{confdir}; 
    1529 
    1630    $ENV{HTTPS_VERSION}   = 3; 
     
    2236    ); 
    2337 
    24     $args->{client} = JSON::RPC::Client->new; 
    25  
    26     bless $args, $class; 
    27 } 
     38    return $self; 
     39}; 
    2840 
    2941sub request { 
     
    3143 
    3244    my $response = Punc::Client::Response->new; 
    33     for my $host ( @{ $self->{hosts} } ) { 
     45    for my $host ( @{ $self->hosts } ) { 
    3446 
    3547        my $url     = "https://$host:7080/$self->{module}"; 
    3648        my $callobj = { 
    37             method  => $self->{method}, 
    38             params  => $self->{args}, 
     49            method  => $self->method, 
     50            params  => $self->args, 
    3951        }; 
    4052 
    41         my $res = $self->{client}->call($url, $callobj) or warn @?; 
     53        my $res = $self->client->call($url, $callobj) or warn @?; 
    4254 
    4355        if( $res ) { 
     
    5870    return if $method eq 'DESTROY'; 
    5971 
    60     $self->{method} = $method; 
    61     $self->{args}   = $args; 
     72    $self->method($method); 
     73    $self->args($args); 
    6274 
    63     if ( $self->{module} eq 'file' and $self->{method} eq 'copy' ) { 
     75    if ( $self->module eq 'file' and $self->method eq 'copy' ) { 
    6476        open my $fh, '<', $args->{src} or die $!; 
    6577        $args->{content} = do { local $/; <$fh> };