mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
Migrate from dep to go module
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
a9174dd953
commit
d5a0606c33
1
vendor/github.com/modern-go/concurrent/.gitignore
generated
vendored
Normal file
1
vendor/github.com/modern-go/concurrent/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
/coverage.txt
|
14
vendor/github.com/modern-go/concurrent/.travis.yml
generated
vendored
Normal file
14
vendor/github.com/modern-go/concurrent/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.8.x
|
||||
- 1.x
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
script:
|
||||
- ./test.sh
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
49
vendor/github.com/modern-go/concurrent/README.md
generated
vendored
Normal file
49
vendor/github.com/modern-go/concurrent/README.md
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
# concurrent
|
||||
|
||||
[](https://sourcegraph.com/github.com/modern-go/concurrent?badge)
|
||||
[](http://godoc.org/github.com/modern-go/concurrent)
|
||||
[](https://travis-ci.org/modern-go/concurrent)
|
||||
[](https://codecov.io/gh/modern-go/concurrent)
|
||||
[](https://goreportcard.com/report/github.com/modern-go/concurrent)
|
||||
[](https://raw.githubusercontent.com/modern-go/concurrent/master/LICENSE)
|
||||
|
||||
* concurrent.Map: backport sync.Map for go below 1.9
|
||||
* concurrent.Executor: goroutine with explicit ownership and cancellable
|
||||
|
||||
# concurrent.Map
|
||||
|
||||
because sync.Map is only available in go 1.9, we can use concurrent.Map to make code portable
|
||||
|
||||
```go
|
||||
m := concurrent.NewMap()
|
||||
m.Store("hello", "world")
|
||||
elem, found := m.Load("hello")
|
||||
// elem will be "world"
|
||||
// found will be true
|
||||
```
|
||||
|
||||
# concurrent.Executor
|
||||
|
||||
```go
|
||||
executor := concurrent.NewUnboundedExecutor()
|
||||
executor.Go(func(ctx context.Context) {
|
||||
everyMillisecond := time.NewTicker(time.Millisecond)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Println("goroutine exited")
|
||||
return
|
||||
case <-everyMillisecond.C:
|
||||
// do something
|
||||
}
|
||||
}
|
||||
})
|
||||
time.Sleep(time.Second)
|
||||
executor.StopAndWaitForever()
|
||||
fmt.Println("executor stopped")
|
||||
```
|
||||
|
||||
attach goroutine to executor instance, so that we can
|
||||
|
||||
* cancel it by stop the executor with Stop/StopAndWait/StopAndWaitForever
|
||||
* handle panic by callback: the default behavior will no longer crash your application
|
12
vendor/github.com/modern-go/concurrent/test.sh
generated
vendored
Normal file
12
vendor/github.com/modern-go/concurrent/test.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
echo "" > coverage.txt
|
||||
|
||||
for d in $(go list ./... | grep -v vendor); do
|
||||
go test -coverprofile=profile.out -coverpkg=github.com/modern-go/concurrent $d
|
||||
if [ -f profile.out ]; then
|
||||
cat profile.out >> coverage.txt
|
||||
rm profile.out
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user