volcano0dr commented on code in PR #678: URL: https://github.com/apache/incubator-teaclave/pull/678#discussion_r1139931955
########## services/proto/src/teaclave_frontend_service.rs: ########## @@ -1298,6 +1346,47 @@ impl From<GetFunctionRequest> for proto::GetFunctionRequest { } } +impl From<GetFunctionUsageStatsRequest> for proto::GetFunctionUsageStatsRequest { + fn from(request: GetFunctionUsageStatsRequest) -> Self { + Self { + function_id: request.function_id.to_string(), + } + } +} + +impl std::convert::TryFrom<proto::GetFunctionUsageStatsRequest> for GetFunctionUsageStatsRequest { + type Error = Error; + + fn try_from(proto: proto::GetFunctionUsageStatsRequest) -> Result<Self> { + let function_id: ExternalID = proto.function_id.try_into()?; + let ret = Self { function_id }; + + Ok(ret) + } +} + +impl From<GetFunctionUsageStatsResponse> for proto::GetFunctionUsageStatsResponse { + fn from(request: GetFunctionUsageStatsResponse) -> Self { + Self { + function_quota: request.function_quota, + current_usage: request.current_usage, + } + } +} + +impl std::convert::TryFrom<proto::GetFunctionUsageStatsResponse> for GetFunctionUsageStatsResponse { + type Error = Error; + + fn try_from(proto: proto::GetFunctionUsageStatsResponse) -> Result<Self> { + let ret = Self { Review Comment: ``` Ok(Self { function_quota: proto.function_quota, current_usage: proto.current_usage, }) ``` ########## services/proto/src/teaclave_frontend_service.rs: ########## @@ -1122,6 +1156,11 @@ impl std::convert::TryFrom<proto::RegisterFunctionRequest> for RegisterFunctionR .into_iter() .map(FunctionArgument::try_from) .collect(); + let usage_quota = if proto.usage_quota < 0 { Review Comment: `let usage_quota = (proto.usage_quota >=0).then_some(proto.usage_quota)` ########## services/proto/src/teaclave_frontend_service.rs: ########## @@ -1210,6 +1251,11 @@ impl std::convert::TryFrom<proto::UpdateFunctionRequest> for UpdateFunctionReque .into_iter() .map(FunctionArgument::try_from) .collect(); + let usage_quota = if proto.usage_quota < 0 { Review Comment: let usage_quota = (proto.usage_quota >=0).then_some(proto.usage_quota) ########## services/proto/src/teaclave_frontend_service.rs: ########## @@ -1298,6 +1346,47 @@ impl From<GetFunctionRequest> for proto::GetFunctionRequest { } } +impl From<GetFunctionUsageStatsRequest> for proto::GetFunctionUsageStatsRequest { + fn from(request: GetFunctionUsageStatsRequest) -> Self { + Self { + function_id: request.function_id.to_string(), + } + } +} + +impl std::convert::TryFrom<proto::GetFunctionUsageStatsRequest> for GetFunctionUsageStatsRequest { + type Error = Error; + + fn try_from(proto: proto::GetFunctionUsageStatsRequest) -> Result<Self> { + let function_id: ExternalID = proto.function_id.try_into()?; + let ret = Self { function_id }; Review Comment: ``` Ok(Self { function_id }) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org For additional commands, e-mail: notifications-h...@teaclave.apache.org