github.com/bazelbuild/rules_webtesting@v0.2.0/go/wtl/proxy/driverhub/drivermu/driver_mu.go (about) 1 // Package drivermu implements a handler that temporally serializes all commands to a session. 2 package drivermu 3 4 import ( 5 "context" 6 "sync" 7 8 "github.com/bazelbuild/rules_webtesting/go/metadata/capabilities" 9 "github.com/bazelbuild/rules_webtesting/go/wtl/proxy/driverhub" 10 ) 11 12 // ProviderFunc provides a handler that temporally serializes all commands to a session. 13 func ProviderFunc(_ *driverhub.WebDriverSession, _ *capabilities.Capabilities, base driverhub.HandlerFunc) (driverhub.HandlerFunc, bool) { 14 var mu sync.Mutex 15 16 return func(ctx context.Context, rq driverhub.Request) (driverhub.Response, error) { 17 mu.Lock() 18 defer mu.Unlock() 19 return base(ctx, rq) 20 }, true 21 }