-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New events client to support Streaming structured events. #3
Conversation
gnmi_cli -client_types=gnmi -a 127.0.0.1:50051 -t EVENTS -logtostderr -insecure -v 7 -streaming_type ON_CHANGE -q aaa/bbb -qt s
Adding client to receive & send to subscribing clients
// Stats counter | ||
counters map[string]uint64 | ||
|
||
last_latencies [LATENCT_LIST_SIZE]int64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not matching spelling on line 30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update is not reflecting. Let me check
var total uint64 = 0 | ||
var cnt int = 0 | ||
|
||
for _ v := range evtc.last_latencies { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing comma. for _, v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid one letter var names
cnt++ | ||
} | ||
} | ||
evtc.counters[LATENCY] = (int64) (total/cnt/1000/1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if last_latencies are all 0, wouldnt this be divide by 0 error?
/* Init current values for cumulative keys and clear for absolute */ | ||
for _, key := range STATS_CUMULATIVE_KEYS { | ||
fv, err := rclient.HGetAll(key).Result() | ||
db_counters[key] = fv[STATS_FIELD_NAME] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deal with error case
}) | ||
|
||
var db_counters map[string]uint64 | ||
var wr_counters *map[string]uint64 = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No semicolon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uninitialized value is nil by default
db_counters[key] = fv[STATS_FIELD_NAME] | ||
} | ||
for _, key := range STATS_ABSOLUTE_KEYS { | ||
db_counters[key] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No semicolon
} | ||
tmp_counters[DROPPED] += evtc.last_errors | ||
|
||
if (wr_counters != nil) && !reflect.DeepEqual(tmp_counters, *wr_counters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comments for this block of code? When is wr_counters not nil? Is line 157 supposed to be outside of this block?
Refer HLD #954