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

Function initialize_record

src/records/RecordsConfigUtils.cc:33–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31//-------------------------------------------------------------------------
32
33static void
34initialize_record(const RecordElement *record, void *)
35{
36 RecInt tempInt = 0;
37 RecFloat tempFloat = 0.0;
38 RecCounter tempCounter = 0;
39
40 RecUpdateT update;
41 RecCheckT check;
42 RecAccessT access;
43 RecT type;
44
45 // Less typing ...
46 type = record->type;
47 update = record->update;
48 check = record->check;
49 access = record->access;
50
51 if (REC_TYPE_IS_CONFIG(type)) {
52 const char *value = RecConfigOverrideFromEnvironment(record->name, record->value);
53 RecData data = {0};
54 RecSourceT source = value == record->value ? REC_SOURCE_DEFAULT : REC_SOURCE_ENV;
55
56 // If you specify a consistency check, you have to specify a regex expression. We abort here
57 // so that this breaks QA completely.
58 if (record->check != RECC_NULL && record->regex == nullptr) {
59 ink_fatal("%s has a consistency check but no regular expression", record->name);
60 }
61
62 RecDataSetFromString(record->value_type, &data, value);
63 RecErrT reg_status{REC_ERR_FAIL};
64 switch (record->value_type) {
65 case RECD_INT:
66 reg_status = RecRegisterConfigInt(type, record->name, data.rec_int, update, check, record->regex, source, access);
67 break;
68
69 case RECD_FLOAT:
70 reg_status = RecRegisterConfigFloat(type, record->name, data.rec_float, update, check, record->regex, source, access);
71 break;
72
73 case RECD_STRING:
74 reg_status = RecRegisterConfigString(type, record->name, data.rec_string, update, check, record->regex, source, access);
75 break;
76
77 case RECD_COUNTER:
78 reg_status = RecRegisterConfigCounter(type, record->name, data.rec_counter, update, check, record->regex, source, access);
79 break;
80
81 default:
82 ink_assert(true);
83 break;
84 } // switch
85
86 if (reg_status != REC_ERR_OKAY) {
87 ink_fatal("%s cannot be registered. Please check the logs.", record->name);
88 }
89
90 RecDataZero(record->value_type, &data);

Callers

nothing calls this directly

Calls 9

ink_fatalFunction · 0.85
RecDataSetFromStringFunction · 0.85
RecRegisterConfigIntFunction · 0.85
RecRegisterConfigFloatFunction · 0.85
RecRegisterConfigStringFunction · 0.85
RecRegisterConfigCounterFunction · 0.85
RecDataZeroFunction · 0.85
ink_atoi64Function · 0.85

Tested by

no test coverage detected