… | |
… | |
136 | =item on_error => $callback->($fcp, $message) |
136 | =item on_error => $callback->($fcp, $message) |
137 | |
137 | |
138 | Invoked on any (fatal) errors, such as unexpected connection close. The |
138 | Invoked on any (fatal) errors, such as unexpected connection close. The |
139 | callback receives the FCP object and a textual error message. |
139 | callback receives the FCP object and a textual error message. |
140 | |
140 | |
141 | =item on_failure => $callback->($fcp, $type, $backtrace, $args, $error) |
141 | =item on_failure => $callback->($fcp, $type, $args, $backtrace, $error) |
142 | |
142 | |
143 | Invoked when an FCP request fails that didn't have a failure callback. See |
143 | Invoked when an FCP request fails that didn't have a failure callback. See |
144 | L<FCP REQUESTS> for details. |
144 | L<FCP REQUESTS> for details. |
145 | |
145 | |
146 | =back |
146 | =back |
… | |
… | |
445 | |
445 | |
446 | This is a popular choice, but it makes handling errors hard - make sure |
446 | This is a popular choice, but it makes handling errors hard - make sure |
447 | you never generate protocol errors! |
447 | you never generate protocol errors! |
448 | |
448 | |
449 | In the failure case, if an C<on_failure> hook exists, it will be invoked |
449 | In the failure case, if an C<on_failure> hook exists, it will be invoked |
450 | with the FCP object, the request type (the name of the method), a |
450 | with the FCP object, the request type (the name of the method, an arrayref |
451 | (textual) backtrace as generated by C<Carp::longmess>, and arrayref |
|
|
452 | containing the arguments from the original request invocation and the |
451 | containing the arguments from the original request invocation, a (textual) |
453 | error object from the server, in this order, e.g.: |
452 | backtrace as generated by C<Carp::longmess>, and the error object from the |
|
|
453 | server, in this order, e.g.: |
454 | |
454 | |
455 | on_failure => sub { |
455 | on_failure => sub { |
456 | my ($fcp, $request_type, $backtrace, $orig_args, $error_object) = @_; |
456 | my ($fcp, $request_type, $orig_args, $backtrace, $error_object) = @_; |
457 | |
457 | |
458 | warn "FCP failure ($type), $error_object->{code_description} ($error_object->{extra_description})$backtrace"; |
458 | warn "FCP failure ($type @$args), $error_object->{code_description} ($error_object->{extra_description})$backtrace"; |
459 | exit 1; |
459 | exit 1; |
460 | }, |
460 | }, |
461 | |
461 | |
462 | =item A condvar (as returned by e.g. C<< AnyEvent->condvar >>) |
462 | =item A condvar (as returned by e.g. C<< AnyEvent->condvar >>) |
463 | |
463 | |
… | |
… | |
737 | }); |
737 | }); |
738 | }; |
738 | }; |
739 | |
739 | |
740 | =item $status = $fcp->remove_request ($identifier[, $global]) |
740 | =item $status = $fcp->remove_request ($identifier[, $global]) |
741 | |
741 | |
742 | Remove the request with the given isdentifier. Returns true if successful, |
742 | Remove the request with the given identifier. Returns true if successful, |
743 | false on error. |
743 | false on error. |
744 | |
744 | |
745 | =cut |
745 | =cut |
746 | |
746 | |
747 | _txn remove_request => sub { |
747 | _txn remove_request => sub { |
… | |
… | |
792 | |
792 | |
793 | C<$want_read> and C<$want_write> should be set to a true value when you |
793 | C<$want_read> and C<$want_write> should be set to a true value when you |
794 | want to read (get) files or write (put) files, respectively. |
794 | want to read (get) files or write (put) files, respectively. |
795 | |
795 | |
796 | On error, an exception is thrown. Otherwise, C<$can_read> and |
796 | On error, an exception is thrown. Otherwise, C<$can_read> and |
797 | C<$can_write> indicate whether you can reaqd or write to freenet via the |
797 | C<$can_write> indicate whether you can read or write to freenet via the |
798 | directory. |
798 | directory. |
799 | |
799 | |
800 | =cut |
800 | =cut |
801 | |
801 | |
802 | _txn test_dda => sub { |
802 | _txn test_dda => sub { |
… | |
… | |
923 | on every change, which will be called as C<< $cb->($fcp, $kv, $type) >>, where C<$type> |
923 | on every change, which will be called as C<< $cb->($fcp, $kv, $type) >>, where C<$type> |
924 | is the type of the original message triggering the change, |
924 | is the type of the original message triggering the change, |
925 | |
925 | |
926 | To fill this cache with the global queue and keep it updated, |
926 | To fill this cache with the global queue and keep it updated, |
927 | call C<watch_global> to subscribe to updates, followed by |
927 | call C<watch_global> to subscribe to updates, followed by |
928 | C<list_persistent_requests_sync>. |
928 | C<list_persistent_requests>. |
929 | |
929 | |
930 | $fcp->watch_global_sync_; # do not wait |
930 | $fcp->watch_global_; # do not wait |
931 | $fcp->list_persistent_requests; # wait |
931 | $fcp->list_persistent_requests; # wait |
932 | |
932 | |
933 | To get a better idea of what is stored in the cache, here is an example of |
933 | To get a better idea of what is stored in the cache, here is an example of |
934 | what might be stored in C<< $fcp->{req}{"Frost-gpl.txt"} >>: |
934 | what might be stored in C<< $fcp->{req}{"Frost-gpl.txt"} >>: |
935 | |
935 | |
… | |
… | |
1044 | if 0.1 > rand; |
1044 | if 0.1 > rand; |
1045 | } |
1045 | } |
1046 | } |
1046 | } |
1047 | |
1047 | |
1048 | # see if the dummy plugin is loaded, to ensure all previous requests have finished. |
1048 | # see if the dummy plugin is loaded, to ensure all previous requests have finished. |
1049 | $fcp->get_plugin_info_sync ("dummy"); |
1049 | $fcp->get_plugin_info ("dummy"); |
1050 | |
1050 | |
1051 | =head1 SEE ALSO |
1051 | =head1 SEE ALSO |
1052 | |
1052 | |
1053 | L<http://wiki.freenetproject.org/FreenetFCPSpec2Point0>, L<Net::FCP>. |
1053 | L<http://wiki.freenetproject.org/FreenetFCPSpec2Point0>, L<Net::FCP>. |
1054 | |
1054 | |