Skip to content

Commit aae0ece

Browse files
author
Jeff Yanta
committed
Add OnSuccess to SubmitIntentIntegration
1 parent adebf36 commit aae0ece

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/code/server/transaction/intent.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type SubmitIntentIntegration interface {
4141
// AllowCreation determines whether the new intent creation should be allowed
4242
// with app-specific validation rules
4343
AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) error
44+
45+
// OnSuccess is a best-effort callback when an intent has been successfully
46+
// submitted
47+
OnSuccess(ctx context.Context, intentRecord *intent.Record) error
4448
}
4549

4650
type defaultSubmitIntentIntegration struct {
@@ -55,6 +59,10 @@ func (i *defaultSubmitIntentIntegration) AllowCreation(ctx context.Context, inte
5559
return nil
5660
}
5761

62+
func (i *defaultSubmitIntentIntegration) OnSuccess(ctx context.Context, intentRecord *intent.Record) error {
63+
return nil
64+
}
65+
5866
func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_SubmitIntentServer) error {
5967
// Bound the total RPC. Keeping the timeout higher to see where we land because
6068
// there's a lot of stuff happening in this method.
@@ -663,6 +671,13 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm
663671
return handleSubmitIntentError(streamer, err)
664672
}
665673

674+
go func() {
675+
err := s.submitIntentIntegration.OnSuccess(context.Background(), intentRecord)
676+
if err != nil {
677+
log.WithError(err).Warn("failure calling integration success callback")
678+
}
679+
}()
680+
666681
//
667682
// Intent is submitted, and anything beyond this point is best-effort.
668683
// We must send success back to the client. Rolling back the intent is

0 commit comments

Comments
 (0)