threadTrace => $threadTrace,
payload => $payload,
complete => 0,
+ resp_count => 0,
+ max_chunk_count => 0,
+ current_chunk_count => 0,
+ max_chunk_size => 0,
+ current_chunk_size => 0,
+ current_chunk => [],
timeout_reset => 0,
recv_timeout => 30,
remaining_recv_timeout => 30,
return $self;
}
+sub max_chunk_count {
+ my $self = shift;
+ my $value = shift;
+ $self->{max_chunk_count} = $value if (defined($value));
+ return $self->{max_chunk_count};
+}
+
+sub max_chunk_size {
+ my $self = shift;
+ my $value = shift;
+ $self->{max_chunk_size} = $value if (defined($value));
+ return $self->{max_chunk_size};
+}
+
sub recv_timeout {
my $self = shift;
my $timeout = shift;
$response->content($msg);
}
+ if ($self->{max_chunk_count} > 0 or $self->{max_chunk_size} > 0) { # we are chunking, and we need to test the size or count
+
+ $self->{current_chunk_size} += OpenSRF::Utils::JSON->perl2JSON($response);
+ push @{$self->{current_chunk}}, $response;
+ $self->{current_chunk_count}++;
+
+ if (
+ ($self->{max_chunk_size} && $self->{current_chunk_size} >= $self->{max_chunk_size} ) ||
+ ($self->{max_chunk_count} && $self->{current_chunk_count} >= $self->{max_chunk_count})
+ ) { # send chunk and reset
+ my $send_res = $self->session->send(( map { ('RESULT', $_) } @{$self->{current_chunk}} ), $self->threadTrace);
+ $self->{current_chunk} = [];
+ $self->{current_chunk_size} = 0;
+ $self->{current_chunk_count} = 0;
+ return $send_res;
+ } else { # not at a chunk yet, just queue it up
+ return $self->session->app_request( $self->threadTrace );
+ }
+ }
+
$self->session->send('RESULT', $response, $self->threadTrace);
}
$response->content($msg);
}
+ push @{$self->{current_chunk}}, $response;
+
my $stat = OpenSRF::DomainObject::oilsConnectStatus->new(
statusCode => STATUS_COMPLETE(),
status => 'Request Complete' );
- $self->session->send( 'RESULT' => $response, 'STATUS' => $stat, $self->threadTrace);
+ $self->session->send( ( map { ('RESULT', $_) } @{$self->{current_chunk}} ), 'STATUS' => $stat, $self->threadTrace);
$self->complete(1);
}
return $self->{argc};
}
+sub max_chunk_size {
+ my $self = shift;
+ return 0 unless ref($self);
+ return $self->{max_chunk_size} if (defined($self->{max_chunk_size}));
+ return 10240;
+}
+
+sub max_chunk_count {
+ my $self = shift;
+ return 0 unless ref($self);
+ return $self->{max_chunk_count} || 0;
+}
+
sub api_name {
my $self = shift;
return 1 unless ref($self);
if (ref $coderef) {
my @args = $app_msg->params;
my $appreq = OpenSRF::AppRequest->new( $session );
+ $appreq->max_chunk_size( $coderef->max_chunk_size );
+ $appreq->max_chunk_count( $coderef->max_chunk_count );
$log->debug( "in_request = $in_request : [" . $appreq->threadTrace."]", INTERNAL );
if( $in_request ) {