-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#42624) * 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>
- Loading branch information
Showing
2 changed files
with
61 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters