Flag for proto message to signal need to override upon and emit events with message itself (and not its fields)
Opened this issue · 0 comments
ranchalp commented
In some cases it comes handy to have the upon and emit functions directly handle the entire proto message and not receive each of its fields in a separate parameter, for example:
checkpointpbdsl.UponStableCheckpoint(m, func(sn types.SeqNr, snapshot *commonpbtypes.StateSnapshot, cert map[t.NodeID][]uint8) error {
// need to reconstruc stableCheckpoint for the function
chkp := &checkpoint.StableCheckpoint{
Sn: sn,
Snapshot: snapshot,
Cert: cert,
}
if err := appModule.appLogic.Checkpoint(stableCheckpoint); err != nil {
return nil, fmt.Errorf("error handling StableCheckpoint event: %w", err)
}
return nil
})
This function would be greatly simplified if the parameter was the proto message itself (removing boilerplate code).