Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for parallel requests #3

Closed
user52 opened this issue Oct 4, 2013 · 3 comments
Closed

Implement support for parallel requests #3

user52 opened this issue Oct 4, 2013 · 3 comments
Assignees

Comments

@user52
Copy link
Contributor

user52 commented Oct 4, 2013

Implement support for parallel requests. Use curl_multi_init and see examples of usage

https://github.com/petewarden/ParallelCurl/blob/master/parallelcurl.php
https://github.com/dulao5/parallel-curl
https://github.com/stil/curl-easy
https://github.com/jmathai/php-multi-curl/blob/master/EpiCurl.php
http://php.net/manual/en/function.curl-multi-init.php

@ghost ghost assigned zachborboa Dec 20, 2013
@zachborboa
Copy link
Member

Possible implementation.

Call one url with the multiple data sets (one to many):

$curl = new Curl();
$curl->get(array(
    'https://www.example.com/search',
), array(
    'q' => 'first search',
), array(
    'q' => 'search #2',
), array(
    'q' => '3rd search',
));

Call multiple urls all with the same data (many to one):

$curl = new Curl();
$curl->get(array(
    'https://duckduckgo.com/',
    'https://search.yahoo.com/search',
    'https://www.bing.com/search',
    'http://www.dogpile.com/search/web',
    'https://www.google.com/search',
    'https://www.wolframalpha.com/input/',
), array(
    'q' => 'first search',
));

Call multiple urls with the multiple data sets (many to many).

$curl = new Curl();
$curl->get(array(
    'https://duckduckgo.com/',
    'https://search.yahoo.com/search',
    'https://www.bing.com/search',
    'http://www.dogpile.com/search/web',
    'https://www.google.com/search',
    'https://www.wolframalpha.com/input/',
), array(
    'q' => 'first search',
), array(
    'q' => 'search #2',
), array(
    'q' => '3rd search',
));

Call a url with data (one to one):

$curl = new Curl();
$curl->get('https://www.example.com/search', array(
    'q' => 'keyword',
));

@zachborboa
Copy link
Member

Implementation with success, error, and complete callbacks.

$curl = new Curl();
$curl->success(function($instance) {
    echo 'call was successful.' . "\n";
    echo 'response was' . "\n";
    echo $instance->response . "\n";
});
$curl->error(function($instance) {
    echo 'call was unsuccessful.' . "\n";
    echo 'error code:' . $instance->error_code . "\n";
    echo 'error message:' . $instance->error_message . "\n";
});
$curl->complete(function($instance) {
    echo 'call completed' . "\n";
});
$curl->get(array(
    'https://www.example.com/search',
), array(
    'q' => 'first search',
), array(
    'q' => 'search #2',
), array(
    'q' => '3rd search',
));

@zachborboa
Copy link
Member

Calling get() in parallel is now supported. TODO: Implement post(), put(), patch(), and delete() in parallel #14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants