RedHatInsights / yggdrasil

GNU General Public License v3.0
21 stars 37 forks source link

fix: handle Event signals gracefully #148

Closed subpop closed 1 year ago

subpop commented 1 year ago

Return errors when handling Event signals emitted by workers and handle the optional 'message' parameter gracefully.

Signed-off-by: Link Dupont link@sub-pop.net

subpop commented 1 year ago

I took a different approach towards unpacking a signal into a WorkerEvent. I dropped the two global variables; they weren't useful without adding variability to them, and after that happens, there is no reason to keep global error variables at all. I renamed the unpack error into a more descriptively named "typeConversionError", since that's more accurately describing what the error carries. I dropped the error checking for signal name and parameter length. Looping over the body slice and attempting to convert the interface{} types to their appropriate types will catch any errors that might exist from incorrect signal bodies.