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
* 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 `services.AcquireSemaphoreLockWithRetry`
This PR introduces `services.AcquireSemaphoreLockWithRetry` function
that only returns if it sucessfully acquired the lock or if the parent
context is cancelled. This function will retry until it sucessfully
acquires the lock before returning.
Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
* Update lib/services/semaphore.go
Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>
---------
Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>
0 commit comments