Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag for proto message to signal need to override upon and emit events with message itself (and not its fields) #429

Open
ranchalp opened this issue May 1, 2023 · 0 comments
Assignees
Labels
backlog To address eventually, not necessarily now cleanup

Comments

@ranchalp
Copy link
Contributor

ranchalp commented May 1, 2023

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).

@ranchalp ranchalp self-assigned this May 1, 2023
@matejpavlovic matejpavlovic added the backlog To address eventually, not necessarily now label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog To address eventually, not necessarily now cleanup
Projects
None yet
Development

No branches or pull requests

2 participants