Skip to content

Keepalive #13

Open
Open

Activity

  1. thekid commented on Dec 2, 2015

    @thekid
    MemberAuthor

    💡 Idea no. 1

    $conn= new HttpConnection(...);
    $conn->useKeepAlive();  // Use default strategy
    $conn->useKeepAlive(newinstance(KeepAlive::class, [], [
      'timeout' => function($request, $response) {
        if ('example.com' === $request->url->getHost()) {
          return 0.0;   // Close immediately
        } else {
          return 30.0;  // Keep open for 30.0 seconds
        }
      }
    ]));
  2. thekid commented on Dec 2, 2015

    @thekid
    MemberAuthor

    💡 Idea no. 2

    $conn= new HttpConnection(...);
    $conn->usingKeepAlive(function() {
      $r1= $conn->get(...);
      $r1->abort();  // Do not process content until end
    
      $r2= $conn->post(...);
      Streams::readAll($r2->in());
    });
  3. thekid commented on Dec 2, 2015

    @thekid
    MemberAuthor

    💡 Idea no. 3

    $conn= new HttpConnection(...);
    $req= $conn->create(new HttpRequest())->keepAlive();
    $req= $conn->create(new HttpRequest())->keepAlive(newinstance(KeepAlive::class, [], [
      // See idea #1 above
    ])));
    $res= $conn->send($req);
  4. thekid commented on Dec 2, 2015

    @thekid
    MemberAuthor

    💡 Idea no. 4

    $conn= new HttpConnection(...);
    $conn->get(..., function($res) {
      $res->abort();
    
      // or: Streams::readAll($res->in());
    });
  5. thekid commented on Dec 2, 2015

    @thekid
    MemberAuthor

    💡 Idea no. 5

    $conn= new HttpConnection(...);
    $pool= $conn->pool(5);
    $pool->get()->then(function($res) {
      // Uses first socket
    });
    $pool->post()->then(function($res) {
      // Uses first *free* socket within the pool
    });
  6. thekid commented on Oct 3, 2017

    @thekid
    MemberAuthor

    See #22 - this is now implemented by passing Connection: keep-alive to requests. Sockets are reused when all data from a previous response has been consumed, except if the server issues a Connection: close.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions