| 79 | } |
| 80 | |
| 81 | TSReturnCode |
| 82 | TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */) |
| 83 | { |
| 84 | auto *limiter = new TxnRateLimiter(); |
| 85 | |
| 86 | // set the name based on the pristine remap URL prior to advancing the pointer below |
| 87 | limiter->setName(getDescriptionFromUrl(argv[0])); |
| 88 | |
| 89 | // argv contains the "to" and "from" URLs. Skip the first so that the |
| 90 | // second one poses as the program name. |
| 91 | --argc; |
| 92 | ++argv; |
| 93 | |
| 94 | TSReleaseAssert(limiter); |
| 95 | limiter->initialize(argc, const_cast<const char **>(argv)); |
| 96 | *ih = static_cast<void *>(limiter); |
| 97 | |
| 98 | if (limiter->rate() > 0) { |
| 99 | // Setup rate based limit, if configured (this is rate as in "requests per second") |
| 100 | limiter->addBucket(); |
| 101 | } |
| 102 | |
| 103 | Dbg(dbg_ctl, "Added active_in limiter rule (limit=%u, rate=%u, queue=%u, max-age=%ldms, error=%u, conntrack=%s)", |
| 104 | limiter->limit(), limiter->rate(), limiter->max_queue(), static_cast<long>(limiter->max_age().count()), limiter->error(), |
| 105 | limiter->conntrack() ? "yes" : "no"); |
| 106 | |
| 107 | return TS_SUCCESS; |
| 108 | } |
| 109 | |
| 110 | /////////////////////////////////////////////////////////////////////////////// |
| 111 | // This is the main "entry" point for the plugin, called for every request. |
nothing calls this directly
no test coverage detected