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

Method getInstance

plugins/prefetch/fetch_policy.cc:32–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30#include "fetch_policy_simple.h"
31
32FetchPolicy *
33FetchPolicy::getInstance(const char *parameters)
34{
35 const char *name = parameters;
36 const char *delim = strchr(parameters, ':');
37 size_t len = (nullptr == delim ? strlen(name) : delim - name);
38 const char *params = (nullptr == delim ? nullptr : delim + 1);
39
40 PrefetchDebug("getting '%.*s' policy instance, params: %s", (int)len, name, params);
41 FetchPolicy *p = nullptr;
42 if (6 == len && 0 == strncmp(name, "simple", 6)) {
43 p = new FetchPolicySimple();
44 } else if (3 == len && 0 == strncmp(name, "lru", 3)) {
45 p = new FetchPolicyLru();
46 } else {
47 PrefetchError("unrecognized fetch policy type: %.*s", (int)len, name);
48 return nullptr;
49 }
50
51 if (p->init(params)) {
52 return p;
53 }
54 delete p;
55
56 return nullptr;
57}

Callers

nothing calls this directly

Calls 1

initMethod · 0.45

Tested by

no test coverage detected