From 0dd88392674647e8373b8c19fa1ca812ad73c108 Mon Sep 17 00:00:00 2001 From: CC11001100 Date: Mon, 7 Aug 2023 02:12:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/golang.yaml | 23 +++++++++++++++++++++++ README.md | 7 ++++++- go.mod | 14 +++++++++----- go.sum | 26 ++++++++++++++++---------- storage_lock_factory.go | 8 ++++---- 5 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/golang.yaml diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml new file mode 100644 index 0000000..1d0c8de --- /dev/null +++ b/.github/workflows/golang.yaml @@ -0,0 +1,23 @@ +name: Go package + +on: + pull_request: + push: + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.19' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... diff --git a/README.md b/README.md index 1e7a2e4..bb637b8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ # Storage Lock Factory +# 一、这是什么 + +把Storage Lock的创建过程工厂化 + +# 二、安装依赖 + ```bash go get -u github.com/storage-lock/go-storage-lock-factory ``` - diff --git a/go.mod b/go.mod index 745f60e..241b2ad 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,11 @@ module github.com/storage-lock/go-storage-lock-factory go 1.19 +require ( + github.com/storage-lock/go-storage v0.0.1 + github.com/storage-lock/go-storage-lock v0.0.1 +) + require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-infrastructure/go-goroutine-id v0.0.0-20230331174358-98b48a64077b // indirect @@ -9,12 +14,11 @@ require ( github.com/golang-infrastructure/go-pointer v0.0.5 // indirect github.com/golang-infrastructure/go-reflect-utils v0.0.0-20221130143747-965ef2eb09c3 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/storage-lock/go-events v0.0.0-20230805113632-ff4385b14030 // indirect - github.com/storage-lock/go-storage v0.0.0-20230805070648-ce1105955864 // indirect - github.com/storage-lock/go-storage-events v0.0.0-20230805074431-3c9e83cd7acb // indirect - github.com/storage-lock/go-storage-lock v0.0.0-20230806063848-33d8f297b1c7 // indirect - github.com/storage-lock/go-utils v0.0.0-20230804131655-6dbe431cdc1a // indirect + github.com/storage-lock/go-events v0.0.1 // indirect + github.com/storage-lock/go-storage-events v0.0.1 // indirect + github.com/storage-lock/go-utils v0.0.2 // indirect github.com/stretchr/testify v1.8.4 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index aa191a6..b819661 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang-infrastructure/go-goroutine-id v0.0.0-20230331174358-98b48a64077b h1:kt3zNiijgkfPm47YaL4MaQJkw0T7ukEEttnCQMOcWxo= @@ -10,20 +11,25 @@ github.com/golang-infrastructure/go-reflect-utils v0.0.0-20221130143747-965ef2eb github.com/golang-infrastructure/go-reflect-utils v0.0.0-20221130143747-965ef2eb09c3/go.mod h1:zqXYxqOBa1mL2ilBK6PuH/Wb/Iego7en6XhiKWdZQHI= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/storage-lock/go-events v0.0.0-20230805113632-ff4385b14030 h1:ET3kiNlDgAMW/8WKHUGcpb4GzeQSuGnW4xta2Ri/jgY= -github.com/storage-lock/go-events v0.0.0-20230805113632-ff4385b14030/go.mod h1:LGZzW3f+td+b+i1pphoI9Dge0kDsguFza/YkXLADet0= -github.com/storage-lock/go-storage v0.0.0-20230805070648-ce1105955864 h1:0lsu6eydV3zLSPdH4aYrQ3kJ2Tjllac8xzOhIQ5xud0= -github.com/storage-lock/go-storage v0.0.0-20230805070648-ce1105955864/go.mod h1:zJZ0g3C6YyDLxX0T/+vxTiVVXZ449LNiFLNBs535a6E= -github.com/storage-lock/go-storage-events v0.0.0-20230805074431-3c9e83cd7acb h1:GuAN/qYQi03ucN7QEUxZvo8Q+CAF5N53HoWAwUBGxmk= -github.com/storage-lock/go-storage-events v0.0.0-20230805074431-3c9e83cd7acb/go.mod h1:6a+wteTwNtzVLBEUA8pECe2/2UtkK+wS0tjlnrEHp9k= -github.com/storage-lock/go-storage-lock v0.0.0-20230806063848-33d8f297b1c7 h1:0i+jz+Dr2xON3CjM975qyzGMv75fJHqiyLRrtFDMt/w= -github.com/storage-lock/go-storage-lock v0.0.0-20230806063848-33d8f297b1c7/go.mod h1:mtvTCnwMiwIHctDYkUNOIUKEJSJyIefPuPPUFLJtt0c= -github.com/storage-lock/go-utils v0.0.0-20230804131655-6dbe431cdc1a h1:6nSZOPYmogTELlp3ZUmzTbOupdrH7OomezDMKHnSAzA= -github.com/storage-lock/go-utils v0.0.0-20230804131655-6dbe431cdc1a/go.mod h1:V0M52rFAkNt77MA3odRqwkl1xRkswsEcX/neFbgmhZY= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/storage-lock/go-events v0.0.1 h1:8abGhlhmJGzn8Pq/LjAbPfAyGs70ZNjwoc7/OITMmUg= +github.com/storage-lock/go-events v0.0.1/go.mod h1:DKwPgfuq8T8CyPLipH+0XHsNt8hEN4g9krUGfosU2oY= +github.com/storage-lock/go-storage v0.0.1 h1:BmIoykW2elNnw5EircFroo353YoIudLXO6LhOuk3xYs= +github.com/storage-lock/go-storage v0.0.1/go.mod h1:tfqgPpnU+NQrcor2WQL4XIbhux4vfue9XzT9ETTd5Ig= +github.com/storage-lock/go-storage-events v0.0.1 h1:NIwf0u8HEzY6Azw2wukvMQLglN5r4xPS/AcjUJiZ1qc= +github.com/storage-lock/go-storage-events v0.0.1/go.mod h1:Ph6p2Nbi5VuB0aGRRIBNkn5G3xvSyhZIEqhRf3gc12Y= +github.com/storage-lock/go-storage-lock v0.0.1 h1:60lvEHQkSqbn0kJY930ZyaygHRz8aIbxHWNSST32ctg= +github.com/storage-lock/go-storage-lock v0.0.1/go.mod h1:SVAbvdYubsZHm8/MgPHKjsHuKLSERB00+clT/QLzoMM= +github.com/storage-lock/go-utils v0.0.2 h1:pdacTOlD+AHqwWVmDqZLcjKF+7p8TjsmlvZ9bmmkIfE= +github.com/storage-lock/go-utils v0.0.2/go.mod h1:tx8ATHL7yOC0Nyjpba7hJNk0+QNt2XEnMr8NcGm9Gak= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/storage_lock_factory.go b/storage_lock_factory.go index 443da40..651effe 100644 --- a/storage_lock_factory.go +++ b/storage_lock_factory.go @@ -28,13 +28,13 @@ func (x *StorageLockFactory[Connection]) CreateLockWithOptions(lockId string, op func (x *StorageLockFactory[Connection]) Shutdown(ctx context.Context) error { - // 关闭连接管理器 - if err := x.ConnectionManager.Shutdown(ctx); err != nil { + // 关闭Storage + if err := x.Storage.Close(ctx); err != nil { return err } - // 关闭Storage - if err := x.Storage.Close(ctx); err != nil { + // 关闭连接管理器 + if err := x.ConnectionManager.Shutdown(ctx); err != nil { return err }