How to pass multiple base64 encode data from json file as req in gRPC unary service

Unary service expects “data” field in base64 encode, is there a way I can have multiple json files with different set of “data” field value as base64 encode & pass as req ?

 const req = [ {
    "data": "SGVsbG8gV29ybGQ=",
    "fileName": "Sanity_FS",
    "namespace": "fseth",
    "topic": "fsdata"
},

{
    "data": "SG93IGFyZSB5b3UgZG9pbmc=",
    "fileName": "Sanity_FS",
    "namespace": "fseth",
    "topic": "fsdata"
},
{
    "data": "VG9kYXkgaXMgbmljZSBkYXk=",
    "fileName": "Sanity_FS",
    "namespace": "fseth",
    "topic": "fsdata"
}];

  const response = client.invoke('grpc.fileService.FileService/readFile', **req**);

I am not sure I completely understand your use case, but maybe instead of different JSON files, you can have a big JSON file that you open(), JSON.parse(), and put in a SharedArray (to reduce memory usage by not having a copy for every VU)?

Then you can pick an element of this array (at random or according to some specific rules you have) for every iteration? You can see some examples how this can be done here: Data Parameterization

1 Like