NAME

Google::gRPC::Engine::PP - Pure-Perl HTTP/2 transport engine for Google::gRPC

SYNOPSIS

use Google::gRPC::Engine::PP;

my $engine = Google::gRPC::Engine::PP->new(
    on_headers      => sub { my ($stream_id, $headers)  = @_; ... },
    on_data         => sub { my ($stream_id, $chunk)    = @_; ... },
    on_trailers     => sub { my ($stream_id, $trailers) = @_; ... },
    on_stream_close => sub { my ($stream_id, $code)     = @_; ... },
);

my $stream_id = $engine->submit_request({
    headers    => [ ':method' => 'POST', ':path' => '/pkg.Svc/Call', ... ],
    data       => $framed_bytes,
    end_stream => 1,
});

my $wire_out = $engine->get_output();
$engine->feed_input($wire_in);

DESCRIPTION

Google::gRPC::Engine::PP is the pure-Perl HTTP/2 transport engine for Google::gRPC, built on Protocol::HTTP2::Client. It is used automatically by Google::gRPC::Engine when libnghttp2 C/XS bindings are unavailable or when engine_type => 'pureperl' is requested explicitly.

ATTRIBUTES

on_headers / on_data / on_trailers / on_stream_close

Optional coderef callbacks invoked for incoming HTTP/2 headers, DATA frames, trailing headers, and stream completion events.

client (read-only, lazy)

Underlying Protocol::HTTP2::Client session instance.

METHODS

is_xs()

Returns 0, indicating this is the pure-Perl engine.

submit_request(\%args)

my $stream_id = $engine->submit_request({
    headers    => \@headers,
    data       => $bytes,
    end_stream => 1,
});

Submits an HTTP/2 request using the provided flat headers arrayref (separating pseudo-headers such as :method, :path, :scheme, and :authority from regular headers) and optional data payload. Returns the assigned stream ID.

feed_input($bytes)

$engine->feed_input($raw_bytes);

Feeds raw bytes read from the TLS/TCP socket into the HTTP/2 state machine, triggering registered callbacks as frames are decoded.

get_output()

my $bytes = $engine->get_output();

Drains and returns all pending outbound HTTP/2 frames ready to be written to the socket.

send_ping($cb)

$engine->send_ping(sub { ... });

Queues an HTTP/2 PING frame if supported by the underlying Protocol::HTTP2::Client.

SEE ALSO

Google::gRPC, Google::gRPC::Engine, Google::gRPC::Engine::NGHTTP2

AUTHOR

C.J. Collier <cjac@google.com>

LICENSE

Apache License 2.0