Open EluvK opened 1 year ago
working on support real_time metrics unit
some basic principles of 'design && usage' thinking at first thought:
MetricsUnit
and wrapped AlarmWrapper
, that is RealTime
, neither multi category-tag's.following the data flow, sort out what we need to do to support real_time:
types - alarm_type - enum MetricsAlarmType
: Add RealTime
, str: "real_time"
client - log_handler - handler_metrics()
- Regex : need to match category and tag to
match alarm_type {
// match (fulllog, type, category, tag) with REGEX
//...
MetricsAlarmType::RealTime => {
// get exact unittype from category and tag, call type::handle_log
}
}
no much things todo
HANDLE_UNIT!(handle_real_time, RealTimeUnit, MetricsAlarmType::RealTime);
here comes the most difficult part.
The RealTimeUnit
, is struct like CounterUnit
, has members like these
pub struct RealTimeUnit {
send_timestamp: TimeStamp,
public_ip: IpAddress,
category: String,
tag: String,
kvs: HashMap<String, String or I64>
}
And we also need to impl Trait SqlTable
&& UnitJsonLogHandler
for it. Inside which we need to implement different behavior according to category-tag.
which is conflict with these two Trait original design...
So From the Trait side, each real-time need one unique struct, or we can not separate them in database. That means the above principle 0x01-2 is not correct.
Each category-tag' RealTime need one unique Struct that impl Trait SqlTable
&& UnitJsonLogHandler
cognitive correction:
RealTimeUnit
, but multi ones with name like NodeStatusRealTimeUnit
, BroadcastInfoRealTimeUnit
, ..etc.
TODOs: