Skip to content

Commit b90500b

Browse files
authored
Add support for Shared memory data (#51)
1 parent eb8abdb commit b90500b

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

src/proto/FunctionRpc.proto

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ message StreamingMessage {
7171
FunctionEnvironmentReloadRequest function_environment_reload_request = 25;
7272

7373
FunctionEnvironmentReloadResponse function_environment_reload_response = 26;
74+
75+
// Ask the worker to close any open shared memory resources for a given invocation
76+
CloseSharedMemoryResourcesRequest close_shared_memory_resources_request = 27;
77+
CloseSharedMemoryResourcesResponse close_shared_memory_resources_response = 28;
7478
}
7579
}
7680

@@ -201,6 +205,17 @@ message FunctionEnvironmentReloadResponse {
201205
StatusResult result = 3;
202206
}
203207

208+
// Tell the out-of-proc worker to close any shared memory maps it allocated for given invocation
209+
message CloseSharedMemoryResourcesRequest {
210+
repeated string map_names = 1;
211+
}
212+
213+
// Response from the worker indicating which of the shared memory maps have been successfully closed and which have not been closed
214+
// The key (string) is the map name and the value (bool) is true if it was closed, false if not
215+
message CloseSharedMemoryResourcesResponse {
216+
map<string, bool> close_map_results = 1;
217+
}
218+
204219
// Host tells the worker to load a Function
205220
message FunctionLoadRequest {
206221
// unique function identifier (avoid name collisions, facilitate reload case)
@@ -318,6 +333,34 @@ message TypedData {
318333
}
319334
}
320335

336+
// Specify which type of data is contained in the shared memory region being read
337+
enum RpcDataType {
338+
unknown = 0;
339+
string = 1;
340+
json = 2;
341+
bytes = 3;
342+
stream = 4;
343+
http = 5;
344+
int = 6;
345+
double = 7;
346+
collection_bytes = 8;
347+
collection_string = 9;
348+
collection_double = 10;
349+
collection_sint64 = 11;
350+
}
351+
352+
// Used to provide metadata about shared memory region to read data from
353+
message RpcSharedMemory {
354+
// Name of the shared memory map containing data
355+
string name = 1;
356+
// Offset in the shared memory map to start reading data from
357+
int64 offset = 2;
358+
// Number of bytes to read (starting from the offset)
359+
int64 count = 3;
360+
// Final type to which the read data (in bytes) is to be interpreted as
361+
RpcDataType type = 4;
362+
}
363+
321364
// Used to encapsulate collection string
322365
message CollectionString {
323366
repeated string string = 1;
@@ -343,8 +386,13 @@ message ParameterBinding {
343386
// Name for the binding
344387
string name = 1;
345388

346-
// Data for the binding
347-
TypedData data = 2;
389+
oneof rpc_data {
390+
// Data for the binding
391+
TypedData data = 2;
392+
393+
// Metadata about the shared memory region to read data from
394+
RpcSharedMemory rpc_shared_memory = 3;
395+
}
348396
}
349397

350398
// Used to describe a given binding on load

0 commit comments

Comments
 (0)