grpc-labview icon indicating copy to clipboard operation
grpc-labview copied to clipboard

Single User Event for multiple gRPC

Open drjdpowell opened this issue 3 years ago • 5 comments

Currently, you have a separate User Event (UE) for each gRCP call type. This requires a lot of extra "boilerplate" to set up each UE, as shown in this image: 2022-12-06 13_02_20-route_guide_server lvlib_RouteGuide lvclass_Register gRPC Methods vi Block Diagr

Normally, the value of separate UEs is strong typing, in that each can have a different type. However, here all UEs have the same type, a single U64 that identifies the gRPC specific call. Typedefs are used to convert, with no strong typing. Thus one gains no benefit from all the extra boilerplate.

Instead, consider having only one User Event for all gRPC names, containing a cluster of two things: the U64 gRPC, plus a string containing the RPC name. This single UE then carries all gRPC calls, with the string being fed into a case structure.

Then adding a new gRPC message just involves two message typedefs, a call to RegisterServerEvent (with tha existing UA), and a new frame in the case structure.

drjdpowell avatar Dec 06 '22 13:12 drjdpowell

Related to #199

drjdpowell avatar Dec 06 '22 13:12 drjdpowell

Actually, one can get close to what i would like, but combining all the UE into an array, and then looking up the Event Ref in a Map to get the RPC Name. Like this:

2022-12-07 12_11_52-JDP NewTest Server vi Block Diagram on JDP lvproj_My Computer _

drjdpowell avatar Dec 07 '22 12:12 drjdpowell

See #206 for this example code

drjdpowell avatar Dec 07 '22 13:12 drjdpowell

I would disagree with this change. I think the ability to handle requests in different event loops may be necessary in many projects so different requests don't block each other (The async version of the current server template)

JamesWiresmith avatar Dec 12 '22 05:12 JamesWiresmith

Handling requests in parallel would be best done using a well rested and capable framework. A user of Actor Framework would use nested actors for parallel handling, for example. However, as long you aren't hindering such users then I don't mind multiple User Events. It can be worked around, as I show in my example.

drjdpowell avatar Dec 12 '22 10:12 drjdpowell