mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor cleanup: remove unused,non-go and test files
This commit is contained in:
1
vendor/github.com/modern-go/concurrent/.gitignore
generated
vendored
1
vendor/github.com/modern-go/concurrent/.gitignore
generated
vendored
@ -1 +0,0 @@
|
||||
/coverage.txt
|
14
vendor/github.com/modern-go/concurrent/.travis.yml
generated
vendored
14
vendor/github.com/modern-go/concurrent/.travis.yml
generated
vendored
@ -1,14 +0,0 @@
|
||||
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
49
vendor/github.com/modern-go/concurrent/README.md
generated
vendored
@ -1,49 +0,0 @@
|
||||
# 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
|
18
vendor/github.com/modern-go/concurrent/map_test.go
generated
vendored
18
vendor/github.com/modern-go/concurrent/map_test.go
generated
vendored
@ -1,18 +0,0 @@
|
||||
package concurrent_test
|
||||
|
||||
import (
|
||||
"github.com/modern-go/concurrent"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMap_Load(t *testing.T) {
|
||||
m := concurrent.NewMap()
|
||||
m.Store("hello", "world")
|
||||
value, found := m.Load("hello")
|
||||
if !found {
|
||||
t.Fail()
|
||||
}
|
||||
if value != "world" {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
12
vendor/github.com/modern-go/concurrent/test.sh
generated
vendored
12
vendor/github.com/modern-go/concurrent/test.sh
generated
vendored
@ -1,12 +0,0 @@
|
||||
#!/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
|
54
vendor/github.com/modern-go/concurrent/unbounded_executor_test.go
generated
vendored
54
vendor/github.com/modern-go/concurrent/unbounded_executor_test.go
generated
vendored
@ -1,54 +0,0 @@
|
||||
package concurrent_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/modern-go/concurrent"
|
||||
)
|
||||
|
||||
func ExampleUnboundedExecutor_Go() {
|
||||
executor := concurrent.NewUnboundedExecutor()
|
||||
executor.Go(func(ctx context.Context) {
|
||||
fmt.Println("abc")
|
||||
})
|
||||
time.Sleep(time.Second)
|
||||
// output: abc
|
||||
}
|
||||
|
||||
func ExampleUnboundedExecutor_StopAndWaitForever() {
|
||||
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")
|
||||
// output:
|
||||
// goroutine exited
|
||||
// executor stopped
|
||||
}
|
||||
|
||||
func ExampleUnboundedExecutor_Go_panic() {
|
||||
concurrent.HandlePanic = func(recovered interface{}, funcName string) {
|
||||
fmt.Println(funcName)
|
||||
}
|
||||
executor := concurrent.NewUnboundedExecutor()
|
||||
executor.Go(willPanic)
|
||||
time.Sleep(time.Second)
|
||||
// output:
|
||||
// github.com/modern-go/concurrent_test.willPanic
|
||||
}
|
||||
|
||||
func willPanic(ctx context.Context) {
|
||||
panic("!!!")
|
||||
}
|
Reference in New Issue
Block a user