proxygen
proxygen::TransactionInfo Class Reference

#include <HTTPTransaction.h>

Public Member Functions

 TransactionInfo ()
 
 TransactionInfo (std::chrono::milliseconds ttfb, std::chrono::milliseconds ttlb, uint64_t eHeader, uint64_t inHeader, uint64_t eBody, uint64_t inBody, bool completed)
 

Public Attributes

std::chrono::milliseconds timeToFirstByte {0}
 
std::chrono::milliseconds timeToLastByte {0}
 
uint64_t egressHeaderBytes {0}
 
uint64_t ingressHeaderBytes {0}
 
uint64_t egressBodyBytes {0}
 
uint64_t ingressBodyBytes {0}
 
bool isCompleted {false}
 

Detailed Description

An HTTPTransaction represents a single request/response pair for some HTTP-like protocol. It works with a Transport that performs the network processing and wire-protocol formatting and a Handler that implements some sort of application logic.

The typical sequence of events for a simple application is:

  • The application accepts a connection and creates a Transport.
  • The Transport reads from the connection, parses whatever protocol the client is speaking, and creates a Transaction to represent the first request.
  • Once the Transport has received the full request headers, it creates a Handler, plugs the handler into the Transaction, and calls the Transaction's onIngressHeadersComplete() method.
  • The Transaction calls the Handler's onHeadersComplete() method and the Handler begins processing the request.
  • If there is a request body, the Transport streams it through the Transaction to the Handler.
  • When the Handler is ready to produce a response, it streams the response through the Transaction to the Transport.
  • When the Transaction has seen the end of both the request and the response, it detaches itself from the Handler and Transport and deletes itself.
  • The Handler deletes itself at some point after the Transaction has detached from it.
  • The Transport may, depending on the protocol, process other requests after – or even in parallel with – that first request. Each request gets its own Transaction and Handler.

For some applications, like proxying, a Handler implementation may obtain one or more upstream connections, each represented by another Transport, and create outgoing requests on the upstream connection(s), with each request represented as a new Transaction.

With a multiplexing protocol like SPDY on both sides of a proxy, the cardinality relationship can be:

            +-----------+     +-----------+     +-------+

(Client-side) | Transport |1—*|Transaction|1—1|Handler| +-----——+ +-----——+ +-——+ 1 | | 1 +---——+ +-----——+ (Server-side) |Transport|1—*|Transaction| +---——+ +-----——+

A key design goal of HTTPTransaction is to serve as a protocol- independent abstraction that insulates Handlers from the semantics different of HTTP-like protocols.Info about Transaction running on this session

Definition at line 92 of file HTTPTransaction.h.

Constructor & Destructor Documentation

proxygen::TransactionInfo::TransactionInfo ( )
inline

Definition at line 94 of file HTTPTransaction.h.

94 {}
proxygen::TransactionInfo::TransactionInfo ( std::chrono::milliseconds  ttfb,
std::chrono::milliseconds  ttlb,
uint64_t  eHeader,
uint64_t  inHeader,
uint64_t  eBody,
uint64_t  inBody,
bool  completed 
)
inline

Definition at line 96 of file HTTPTransaction.h.

103  :
104  timeToFirstByte(ttfb),
105  timeToLastByte(ttlb),
106  egressHeaderBytes(eHeader),
107  ingressHeaderBytes(inHeader),
108  egressBodyBytes(eBody),
109  ingressBodyBytes(inBody),
110  isCompleted(completed) {
111  }
std::chrono::milliseconds timeToFirstByte
std::chrono::milliseconds timeToLastByte

Member Data Documentation

uint64_t proxygen::TransactionInfo::egressBodyBytes {0}

Number of bytes send in body

Definition at line 123 of file HTTPTransaction.h.

uint64_t proxygen::TransactionInfo::egressHeaderBytes {0}

Number of bytes send in headers

Definition at line 119 of file HTTPTransaction.h.

uint64_t proxygen::TransactionInfo::ingressBodyBytes {0}

Number of bytes receive in body

Definition at line 125 of file HTTPTransaction.h.

uint64_t proxygen::TransactionInfo::ingressHeaderBytes {0}

Number of bytes receive headers

Definition at line 121 of file HTTPTransaction.h.

bool proxygen::TransactionInfo::isCompleted {false}

Is the transaction was completed without error

Definition at line 128 of file HTTPTransaction.h.

std::chrono::milliseconds proxygen::TransactionInfo::timeToFirstByte {0}

Time to first byte

Definition at line 114 of file HTTPTransaction.h.

std::chrono::milliseconds proxygen::TransactionInfo::timeToLastByte {0}

Time to last byte

Definition at line 116 of file HTTPTransaction.h.


The documentation for this class was generated from the following file: