NAME

Azure::SDK::Core::Context - per-request metadata bag for the Perl Azure SDK core

SYNOPSIS

my $context = Azure::SDK::Core::Context->new(
    options => { timeout => 30 },
);

$context->set_request_id('a-guid');
my $timeout = $context->options_for('timeout', 60);

DESCRIPTION

Azure::SDK::Core::Context carries request-scoped metadata through the pipeline: the client request id, per-call options, and the current retry attempt counter. Policies read and update the context as a request flows through the pipeline.

CONSTRUCTOR

new

Named parameters:

request_id

Optional client request id. Defaults to undef until a diagnostics policy assigns one.

options

Optional hashref of per-call options. Defaults to an empty hashref.

METHODS

request_id

Returns the current client request id.

attempt

Returns the current retry attempt count.

options_for

my $value = $context->options_for($key, $default);

Returns the per-call option for $key, or $default when it is absent.

set_request_id

Sets the client request id and returns the context for chaining.

begin_attempt

Increments and returns the retry attempt counter. The retry policy calls this before each transport attempt.

SEE ALSO

Azure::SDK::Core::Pipeline, Azure::SDK::Core::Policy::Diagnostics