digraph collapsed_connection {
  accept -> TS_HTTP_POST_REMAP_HOOK;
  TS_HTTP_POST_REMAP_HOOK -> "check request method (and header)";

  "check request method (and header)" -> "get CacheUrl hash_key using MurmurHash3" [label = "GET request (required_header present)"];
  "check request method (and header)" -> "pass request" [label = "others"];
  "get CacheUrl hash_key using MurmurHash3" -> "check hash_key from hashTable";
  "check hash_key from hashTable" -> "lock URL in hashTable" [label = "not found"];
  "check hash_key from hashTable" -> "pass request" [label = "found, but marked pass"];
  "check hash_key from hashTable" -> "check hash_key from hashTable" [label = "locked or unable to get mutex, wait insert_lock_retry_time"];
  "lock URL in hashTable" -> TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK;
  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK -> "remove URL from hashTable(1)" [label = "hit_fresh or skipped"];
  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK -> "request origin server" [label = "miss or stale"];
  "request origin server" -> TS_HTTP_READ_RESPONSE_HDR_HOOK;
  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "remove URL from hashTable(1)" [label = "not 200/OK response"];
  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "check read_while_writer config";
  "check read_while_writer config" -> "remove URL from hashTable(1)" [label = "enabled"];
  "check read_while_writer config" -> TS_HTTP_TXN_CLOSE_HOOK [label = "disabled"];
  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "mark pass in hashTable" [label = "non-cacheable"];
  "remove URL from hashTable(1)" -> TS_HTTP_TXN_CLOSE_HOOK;
  "mark pass in hashTable" -> TS_HTTP_TXN_CLOSE_HOOK;
  "pass request" -> TS_HTTP_TXN_CLOSE_HOOK;
  TS_HTTP_TXN_CLOSE_HOOK -> "remove URL from hashTable(2)";
  TS_HTTP_TXN_CLOSE_HOOK -> "check keep_pass_record_time" [label = "non-cacheable"];
  "check keep_pass_record_time" -> "add into KeepPassList" [label = "> 0"];
  "check keep_pass_record_time" -> "remove URL from hashTable(2)" [label = "= 0"];
  "add into KeepPassList" -> "transaction close";
  "remove URL from hashTable(2)" -> "transaction close";
  "transaction close" -> accept;

  TS_HTTP_POST_REMAP_HOOK [shape = box];
  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK[shape = box];
  TS_HTTP_READ_RESPONSE_HDR_HOOK [shape = box];
  TS_HTTP_TXN_CLOSE_HOOK [shape = box];

  "check request method (and header)" [shape = diamond];
  "check hash_key from hashTable" [shape = diamond];
  "check read_while_writer config" [shape = diamond];
  "check keep_pass_record_time" [shape = diamond];
}
