You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[v15] transform services.SemaphoreLock to satisfy context.Context (#42623)
* transform `services.SemaphoreLock` to satisfy `context.Context`
This PR makes `services.SemaphoreLock` statisfy the `context.Context`
interface. Extending the `services.SemaphoreLock` makes it possible to
use the lease as a context in context propgation.
```go
lease, err:=services.AcquireSemaphore(ctx,...)
if err!=nil{
...
}
ctx, cancel:=context.WithCancel(lease)
```
`lease` is released when the semaphore lock is lost or when the parent
context is cancelled so we can use it as argument to other context
functions without having to carry the parent context.
Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
* use ctx.Done channel from stdlib context to avoid spining a goroutine
* add godoc
---------
Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
0 commit comments