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

Function TSPluginInit

example/plugins/c-api/statistic/statistic.cc:43–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43void
44TSPluginInit(int /* argc */, const char * /* argv */[])
45{
46 TSPluginRegistrationInfo info;
47
48 info.plugin_name = PLUGIN_NAME;
49 info.vendor_name = "Apache Software Foundation";
50 info.support_email = "dev@trafficserver.apache.org";
51
52 int id;
53 const char name[] = "plugin." PLUGIN_NAME ".now";
54
55 if (TSStatFindName(name, &id) == TS_ERROR) {
56 id = TSStatCreate(name, TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
57 if (id == TS_ERROR) {
58 TSError("[%s] failed to register '%s'", PLUGIN_NAME, name);
59 return;
60 }
61 }
62
63 TSError("[%s] %s registered with id %d", PLUGIN_NAME, name, id);
64
65#if DEBUG
66 TSReleaseAssert(id != TS_ERROR);
67#endif
68
69 // Set an initial value for our statistic.
70 TSStatIntSet(id, time(nullptr));
71
72 // Increment the statistic as time passes.
73 TSStatIntIncrement(id, 1);
74
75 Dbg(dbg_ctl, "%s is set to %" PRId64, name, TSStatIntGet(id));
76 TSReleaseAssert(TSPluginRegister(&info) == TS_SUCCESS);
77}

Callers

nothing calls this directly

Calls 7

TSStatFindNameFunction · 0.85
TSStatCreateFunction · 0.85
TSStatIntSetFunction · 0.85
TSStatIntIncrementFunction · 0.85
TSStatIntGetFunction · 0.85
TSPluginRegisterFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected