After days of trying and failed, finally I have succeed in implementing both Grpc and Gatling plugins into one project (embarrassingly long time), now I am looking into phiSgr example (again, sorry for this), and I see there is a part as this:
message GreetRequest {
string username = 1;
string name = 2;
}
and in GrpcExample.scala, he "translate it":
val greetPayload: Expression[GreetRequest] = GreetRequest(name = "World").updateExpr(
_.username :~ $("username")
)
So I just want to know the procedure to translate this chunk:
message Device {
string id = 1[(google.api.field_behavior) = REQUIRED]
}
message StartPairingRequest {
Device device = 1 [(google.api.field_behavior) = REQUIRED]
}
With a body message when I do request
{
"Device": {
"id": "random text"
}
}
What I have tried to do in .scala file:
val greetPayload: Expression[StartPairingRequest] = StartPairingRequest(device = " "theBody" = "random text" ").updateExpr(
_.device:~$("device")
)
it seems that my implementation is not right, so I would wish to learn more about this "translating" procedure, please help.
The extension function updateExpr
and the operator :~
are used to construct dynamic payload with the virtual user's Session
.
Using them requires knowing a concept called lens, which is used in ScalaPB.
Those who lack the prior knowledge are strongly recommended to use the Kotlin binding and write your load tests in Kotlin/Java.
However the payload described in this question has no dynamic value, and can be constructed simply as:
StartPairingRequest(Device("random text"))