FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

dataconnect(chore): DataConnectGrpcRPCs.kt: fix wasteful conversion to Struct only used for debug logging by dconeybe · Pull Request #8126 · firebase/firebase-android-sdk · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .kt  (1) .md  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions firebase-dataconnect/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
([#8027](https://github.com/firebase/firebase-android-sdk/pull/8027))
- [changed] Internal change to add protos for realtime query updates.
([#8081](https://github.com/firebase/firebase-android-sdk/pull/8081))
- [changed] Fixed wasteful computation that is only for debug logging.
([#8126](https://github.com/firebase/firebase-android-sdk/pull/8126))

# 17.2.1

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ internal class DataConnectGrpcRPCs(
kotlinMethodName = kotlinMethodName,
grpcMethod = ConnectorServiceGrpc.getExecuteMutationMethod(),
metadata = metadata,
request = request.toStructProto(),
request = { request.toStructProto() },
requestTypeName = "ExecuteMutationRequest",
authUid = authToken?.authUid,
)
Expand All @@ -185,7 +185,7 @@ internal class DataConnectGrpcRPCs(
logger.logGrpcReceived(
requestId = requestId,
kotlinMethodName = kotlinMethodName,
response = it.toStructProto(),
response = { it.toStructProto() },
responseTypeName = "ExecuteMutationResponse",
)
}
Expand Down Expand Up @@ -242,7 +242,7 @@ internal class DataConnectGrpcRPCs(
kotlinMethodName = kotlinMethodName,
grpcMethod = ConnectorServiceGrpc.getExecuteQueryMethod(),
metadata = metadata,
request = request.toStructProto(),
request = { request.toStructProto() },
requestTypeName = "ExecuteQueryRequest",
authUid = authToken?.authUid,
)
Expand All @@ -267,7 +267,7 @@ internal class DataConnectGrpcRPCs(
logger.logGrpcReceived(
requestId = requestId,
kotlinMethodName = kotlinMethodName,
response = response.toStructProto(),
response = { response.toStructProto() },
responseTypeName = "ExecuteQueryResponse",
)

Expand Down Expand Up @@ -358,7 +358,7 @@ internal class DataConnectGrpcRPCs(
logger.logGrpcReceived(
requestId = requestId,
kotlinMethodName = kotlinMethodName,
response = it.toStructProto(),
response = { it.toStructProto() },
responseTypeName = "EmulatorInfo",
)
}
Expand Down Expand Up @@ -394,7 +394,7 @@ internal class DataConnectGrpcRPCs(
logger.logGrpcReceived(
requestId = requestId,
kotlinMethodName = kotlinMethodName,
response = response.toStructProto(),
response = { response.toStructProto() },
responseTypeName = "EmulatorIssuesResponse"
)
}
Expand Down Expand Up @@ -489,19 +489,20 @@ internal class DataConnectGrpcRPCs(
}
}

private fun Logger.logGrpcSending(
private inline fun Logger.logGrpcSending(
requestId: String,
kotlinMethodName: String,
grpcMethod: MethodDescriptor<*, *>,
metadata: Metadata,
request: Struct,
request: () -> Struct,
requestTypeName: String,
authUid: String?,
) = debug {
val requestStruct = request()
val struct = buildStructProto {
put("RPC", grpcMethod.fullMethodName)
put("Metadata", metadata.toStructProto(authUid))
put(requestTypeName, request)
put(requestTypeName, requestStruct)
}
// Sort the keys in the output string to be more meaningful than alphabetical.
val keySortSelector: (String) -> String = {
Expand Down Expand Up @@ -545,13 +546,14 @@ internal class DataConnectGrpcRPCs(
kotlinMethodName: String,
) = debug { "$kotlinMethodName [rid=$requestId] completed" }

private fun Logger.logGrpcReceived(
private inline fun Logger.logGrpcReceived(
requestId: String,
kotlinMethodName: String,
response: Struct,
response: () -> Struct,
responseTypeName: String
) = debug {
val struct = buildStructProto { put(responseTypeName, response) }
val responseStruct = response()
val struct = buildStructProto { put(responseTypeName, responseStruct) }
"$kotlinMethodName [rid=$requestId] received: ${struct.toCompactString()}"
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL