Skip to content

callbackserializer: add a method to execute a callback in a blocking fashion #8501

@easwars

Description

@easwars

Currently, we have a couple of ways to schedule callbacks for execution with the serializer:

  • TrySchedule: which is a best effort option to schedule a callback
  • ScheduleOr: which provides a way for the caller to supply a function that is executed if the callback is not successfully scheduled on the serializer.

See: https://github.com/grpc/grpc-go/blob/master/internal/grpcsync/callback_serializer.go

We have a whole bunch of places which have the following pattern (where the caller wants to wait for the scheduled callback to run, before proceeding):

	done := make(chan struct{})
	serializer.ScheduleOr(func(context.Context) {
		// Do stuff
		close(done)
	}, func() {
		// Set an error somewhere or throw a log message
		close(done)
    })
	<-done

We could introduce a new method to the serializer which supports this pattern of blocking until the provided callback is run. This review thread has some ideas to get started on this: #8499 (comment)

Metadata

Metadata

Assignees

Labels

Type: FeatureNew features or improvements in behavior

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions