ms::Graph method async_operation_status (protected)

 <instance of ms::Graph[i]> async_operation_status [ -wait ] \
    [ -donecallback donecallback ] r

Defined in packages/xooauth/tcl/ms-procs.tcl

set context "[:uplevel {current methodpath}] [:uplevel {current args}]"

Switches:
-wait (optional)
-donecallback (optional)
Parameters:
r (required)

Testcases:
No testcase defined.
Source code:
:uplevel [list :expect_status_code $r 202]
set location [ns_set iget [dict get $r headers] location]
set operationStatus [:check_async_operation $location]
ns_log notice "[self] async operation '$location' -> $operationStatus"
#
# Since this is an async operation, it might take a while,
# until "the cloud" has finished. When the flag "-wait"
# was specified, we try up to 10 more times with a backoff
# time strategy. Microsoft recommends to wait >30 seconds
# between checks, but actually, this seems overly
# conservative for most application scenarios.
#
# TODO: If still everything fail until then, we
# we should do a scheduled checking with a finish callback.
#
if {$wait && $operationStatus ne "succeeded"} {
    foreach  i        {1  2  3  4   5   6   7   8   9  10}  interval {1s 1s 3s 5s 10s 30s 30s 30s 30s 30s}  {
            ns_sleep $interval
            set operationStatus [:check_async_operation $location]
            ns_log notice "[self] retry $i: operationStatus $operationStatus"
            if {$operationStatus eq "succeeded"} {
                break
            }
        }
}
if {$donecallback ne ""} {
    #
    # Since we call the callback and its environment via
    # "eval", we have to protect the arguments with "list".
    #
    :schedule_donecallback 60 $location  [list eval [current class] run_donecallback  [list [:serialize]] [list $location] [list $donecallback]]
}
return $operationStatus
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: