MCPcopy Create free account
hub / github.com/apache/trafficserver / TSRemapNewInstance

Function TSRemapNewInstance

plugins/experimental/rate_limit/rate_limit.cc:81–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81TSReturnCode
82TSRemapNewInstance(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.

Callers

nothing calls this directly

Calls 11

getDescriptionFromUrlFunction · 0.85
rateMethod · 0.80
addBucketMethod · 0.80
max_queueMethod · 0.80
max_ageMethod · 0.80
conntrackMethod · 0.80
setNameMethod · 0.45
initializeMethod · 0.45
limitMethod · 0.45
countMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected