Skip to content

Commit

Permalink
Support get stats API
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Oct 20, 2023
1 parent 36dd1f5 commit f3e63dd
Show file tree
Hide file tree
Showing 91 changed files with 91,372 additions and 5,458 deletions.
11 changes: 11 additions & 0 deletions dataplane/standalone/apigen/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ func populateTmplDataFromFunc(apis map[string]*protoAPITmplData, docInfo *docpar
ProtoType: "repeated " + strcase.UpperCamelCase("Create "+meta.TypeName+"Response"),
Index: 1,
})
case "get_stats":
req.Fields = append(req.Fields, idField, protoTmplField{
Name: "counter_ids",
ProtoType: "repeated " + strcase.UpperCamelCase(meta.TypeName+" stat"),
Index: 2,
})
resp.Fields = append(resp.Fields, protoTmplField{
Name: "values",
ProtoType: "uint64",
Index: 1,
})
default:
return nil
}
Expand Down
14 changes: 14 additions & 0 deletions dataplane/standalone/apigen/protogen/protogen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,17 @@ service Sample {
}, {
Name: "get_foo_attribute",
Typ: "sai_get_foo_attribute_t",
}, {
Name: "get_foo_stats",
Typ: "sai_get_foo_stats_t",
}},
}},
Funcs: map[string]*saiast.SAIFunc{
"sai_create_foo_t": {Params: []saiast.TypeDecl{{Name: "object_id", Typ: "*sai_object_id_t"}, {Name: "switch_id", Typ: "sai_object_id_t"}}},
"sai_remove_foo_t": {},
"sai_set_foo_attribute_t": {},
"sai_get_foo_attribute_t": {},
"sai_get_foo_stats_t": {},
},
},
inInfo: &docparser.SAIInfo{
Expand Down Expand Up @@ -595,11 +599,21 @@ message GetFooAttributeResponse {
FooAttribute attr = 1;
}
message GetFooStatsRequest {
uint64 oid = 1;
repeated FooStat counter_ids = 2;
}
message GetFooStatsResponse {
uint64 values = 1;
}
service Sample {
rpc CreateFoo (CreateFooRequest) returns (CreateFooResponse) {}
rpc RemoveFoo (RemoveFooRequest) returns (RemoveFooResponse) {}
rpc GetFooAttribute (GetFooAttributeRequest) returns (GetFooAttributeResponse) {}
rpc GetFooStats (GetFooStatsRequest) returns (GetFooStatsResponse) {}
}
`,
},
Expand Down
Loading

0 comments on commit f3e63dd

Please sign in to comment.