From e0f3418e802da3ecc2185e7c16ef32802442eec8 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Thu, 28 Nov 2024 01:26:41 +0700 Subject: [PATCH 01/10] Update store --- store/store.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/store/store.go b/store/store.go index 896c1350..db69f9f6 100644 --- a/store/store.go +++ b/store/store.go @@ -6,6 +6,14 @@ import ( "errors" ) +type EventType int + +const ( + EventTypeUnknown = iota + EventTypeConnect + EventTypeDisconnect +) + var ( // ErrNotFound is returned when a key doesn't exist ErrNotFound = errors.New("not found") @@ -17,6 +25,11 @@ var ( DefaultSeparator = "/" ) +type Event interface { + Error() error + Type() EventType +} + // Store is a data storage interface type Store interface { Name() string @@ -41,3 +54,12 @@ type Store interface { // String returns the name of the implementation. String() string } + +type Watcher interface { + // Next is a blocking call + Next() (Event, error) + // Stop stops the watcher + Stop() +} + +func Watch(context.Context) (Watcher, error) -- 2.45.2 From d04314b472083ef63686fb117bb077d88e953740 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Thu, 5 Dec 2024 23:55:31 +0700 Subject: [PATCH 02/10] Test actions --- .gitea/workflows/lint.yml | 8 +++----- .gitea/workflows/pr.yml | 8 +++++--- service_test.go | 2 +- store/store.go | 4 +++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index 1cc293dc..c2b17575 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -10,15 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - name: setup-go - uses: actions/setup-go@v3 - with: - go-version: 1.21 + uses: actions/setup-go@v5 - name: checkout uses: actions/checkout@v3 - name: deps run: go get -v -d ./... - name: lint - uses: https://github.com/golangci/golangci-lint-action@v3.4.0 + uses: https://github.com/golangci/golangci-lint-action@v6 continue-on-error: true with: - version: v1.52 + version: v1.58 diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index b3e67b06..e03fd52c 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -12,11 +12,13 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: setup-go - uses: actions/setup-go@v3 - with: - go-version: 1.21 + uses: actions/setup-go@v5 - name: deps run: go get -v -t -d ./... + - name: lint + uses: https://github.com/golangci/golangci-lint-action@v6 + with: + version: v1.58 - name: test env: INTEGRATION_TESTS: yes diff --git a/service_test.go b/service_test.go index b6bca118..270330da 100644 --- a/service_test.go +++ b/service_test.go @@ -28,7 +28,7 @@ func TestClient(t *testing.T) { } x1 := svc.Client("test2") - if x1.Name() != "test2" { + if x1.Name() == "test2" { t.Fatalf("invalid client %#+v", svc.Options().Clients) } } diff --git a/store/store.go b/store/store.go index db69f9f6..5caa6c1f 100644 --- a/store/store.go +++ b/store/store.go @@ -62,4 +62,6 @@ type Watcher interface { Stop() } -func Watch(context.Context) (Watcher, error) +func Watch(context.Context) (Watcher, error) { + return nil, nil +} -- 2.45.2 From 64c8ae6b495305639406d0008da2f1ead2a2c5ee Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Thu, 5 Dec 2024 23:59:15 +0700 Subject: [PATCH 03/10] Fix yml --- .gitea/workflows/lint.yml | 2 ++ .gitea/workflows/pr.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index c2b17575..bbc6cab7 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -11,6 +11,8 @@ jobs: steps: - name: setup-go uses: actions/setup-go@v5 + with: + go-version: 'stable' - name: checkout uses: actions/checkout@v3 - name: deps diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index e03fd52c..01e113b6 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -13,6 +13,8 @@ jobs: uses: actions/checkout@v3 - name: setup-go uses: actions/setup-go@v5 + with: + go-version: 'stable' - name: deps run: go get -v -t -d ./... - name: lint -- 2.45.2 From 835d5f462160f4173be8248a21e6b55b7bfb43f8 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 00:10:44 +0700 Subject: [PATCH 04/10] Deleted golangci.yml --- .golangci.yml | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 524fc7f8..00000000 --- a/.golangci.yml +++ /dev/null @@ -1,44 +0,0 @@ -run: - concurrency: 4 - deadline: 5m - issues-exit-code: 1 - tests: true - -linters-settings: - govet: - check-shadowing: true - enable: - - fieldalignment - -linters: - enable: - - govet - - deadcode - - errcheck - - govet - - ineffassign - - staticcheck - - structcheck - - typecheck - - unused - - varcheck - - bodyclose - - gci - - goconst - - gocritic - - gosimple - - gofmt - - gofumpt - - goimports - - revive - - gosec - - makezero - - misspell - - nakedret - - nestif - - nilerr - - noctx - - prealloc - - unconvert - - unparam - disable-all: false -- 2.45.2 From 43599cf3088a8b3230c7b509a9f0cc87be1b3e4f Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 00:42:03 +0700 Subject: [PATCH 05/10] Edited ymls --- .gitea/workflows/lint_copy.yml | 38 ++++++++++++++++++++++++++++++++++ .gitea/workflows/pr.yml | 8 +++---- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/lint_copy.yml diff --git a/.gitea/workflows/lint_copy.yml b/.gitea/workflows/lint_copy.yml new file mode 100644 index 00000000..0848872c --- /dev/null +++ b/.gitea/workflows/lint_copy.yml @@ -0,0 +1,38 @@ +name: lint_copy +on: + pull_request: + branches: + - master + - v3 +jobs: + setup: + name: setup + runs-on: ubuntu-latest + steps: + - name: setup-go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: checkout + uses: actions/checkout@v3 + - name: deps + run: go get -v -d ./... + lint: + name: lint + runs-on: ubuntu-latest + needs: setup + steps: + - name: lint + uses: https://github.com/golangci/golangci-lint-action@v6 + continue-on-error: true + with: + version: v1.58 + test: + name: lint + runs-on: ubuntu-latest + needs: setup + steps: + - name: test + env: + INTEGRATION_TESTS: yes + run: go test -mod readonly -v ./... diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index 01e113b6..8dd569e9 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -21,7 +21,7 @@ jobs: uses: https://github.com/golangci/golangci-lint-action@v6 with: version: v1.58 - - name: test - env: - INTEGRATION_TESTS: yes - run: go test -mod readonly -v ./... + # - name: test + # env: + # INTEGRATION_TESTS: yes + # run: go test -mod readonly -v ./... -- 2.45.2 From 3dd55354cfd0078b0bc667512c6f85d6aea43c0c Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 01:48:15 +0700 Subject: [PATCH 06/10] Upd ymls --- .gitea/workflows/lint.yml | 24 ----------------- .../workflows/{lint_copy.yml => pipeline.yml} | 19 +++++++------ .gitea/workflows/pr.yml | 27 ------------------- 3 files changed, 9 insertions(+), 61 deletions(-) delete mode 100644 .gitea/workflows/lint.yml rename .gitea/workflows/{lint_copy.yml => pipeline.yml} (66%) delete mode 100644 .gitea/workflows/pr.yml diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml deleted file mode 100644 index bbc6cab7..00000000 --- a/.gitea/workflows/lint.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: lint -on: - pull_request: - branches: - - master - - v3 -jobs: - lint: - name: lint - runs-on: ubuntu-latest - steps: - - name: setup-go - uses: actions/setup-go@v5 - with: - go-version: 'stable' - - name: checkout - uses: actions/checkout@v3 - - name: deps - run: go get -v -d ./... - - name: lint - uses: https://github.com/golangci/golangci-lint-action@v6 - continue-on-error: true - with: - version: v1.58 diff --git a/.gitea/workflows/lint_copy.yml b/.gitea/workflows/pipeline.yml similarity index 66% rename from .gitea/workflows/lint_copy.yml rename to .gitea/workflows/pipeline.yml index 0848872c..c23479dd 100644 --- a/.gitea/workflows/lint_copy.yml +++ b/.gitea/workflows/pipeline.yml @@ -1,4 +1,4 @@ -name: lint_copy +name: pipeline on: pull_request: branches: @@ -7,7 +7,7 @@ on: jobs: setup: name: setup - runs-on: ubuntu-latest + runs-on: ubuntu-latest-slim steps: - name: setup-go uses: actions/setup-go@v5 @@ -19,20 +19,19 @@ jobs: run: go get -v -d ./... lint: name: lint - runs-on: ubuntu-latest + runs-on: ubuntu-latest-slim needs: setup steps: - name: lint uses: https://github.com/golangci/golangci-lint-action@v6 - continue-on-error: true with: version: v1.58 test: - name: lint - runs-on: ubuntu-latest + name: test + runs-on: ubuntu-latest-slim needs: setup steps: - - name: test - env: - INTEGRATION_TESTS: yes - run: go test -mod readonly -v ./... + - name: test + env: + INTEGRATION_TESTS: yes + run: go test -mod readonly -v ./... diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml deleted file mode 100644 index 8dd569e9..00000000 --- a/.gitea/workflows/pr.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: pr -on: - pull_request: - branches: - - master - - v3 -jobs: - test: - name: test - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - name: setup-go - uses: actions/setup-go@v5 - with: - go-version: 'stable' - - name: deps - run: go get -v -t -d ./... - - name: lint - uses: https://github.com/golangci/golangci-lint-action@v6 - with: - version: v1.58 - # - name: test - # env: - # INTEGRATION_TESTS: yes - # run: go test -mod readonly -v ./... -- 2.45.2 From 90c6d48c82a1f879ac9fb79bd176c148573f9f7d Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 01:50:45 +0700 Subject: [PATCH 07/10] Fix yml --- .gitea/workflows/pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index c23479dd..074dc2bb 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -7,7 +7,7 @@ on: jobs: setup: name: setup - runs-on: ubuntu-latest-slim + runs-on: ubuntu-latest steps: - name: setup-go uses: actions/setup-go@v5 @@ -19,7 +19,7 @@ jobs: run: go get -v -d ./... lint: name: lint - runs-on: ubuntu-latest-slim + runs-on: ubuntu-latest needs: setup steps: - name: lint @@ -28,7 +28,7 @@ jobs: version: v1.58 test: name: test - runs-on: ubuntu-latest-slim + runs-on: ubuntu-latest needs: setup steps: - name: test -- 2.45.2 From cba9d6849e28f8c861b2b46c7e86f84f91dabea6 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 02:33:34 +0700 Subject: [PATCH 08/10] Upd test in yml --- .gitea/workflows/pipeline.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 074dc2bb..d15484b8 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -29,9 +29,14 @@ jobs: test: name: test runs-on: ubuntu-latest - needs: setup + # needs: setup steps: - name: test env: INTEGRATION_TESTS: yes run: go test -mod readonly -v ./... + with: + checkout: actions/checkout@v3 + deps: go get -v -d ./... + setup-go: actions/setup-go@v5 + go-version: 'stable' -- 2.45.2 From 7ac942e4b1dca395db984cbb8bee4987e9836762 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 02:39:08 +0700 Subject: [PATCH 09/10] Upd test and yml --- .gitea/workflows/pipeline.yml | 23 ++++++++++------------- service_test.go | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index d15484b8..3735ce52 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -5,8 +5,8 @@ on: - master - v3 jobs: - setup: - name: setup + lint: + name: lint runs-on: ubuntu-latest steps: - name: setup-go @@ -17,11 +17,6 @@ jobs: uses: actions/checkout@v3 - name: deps run: go get -v -d ./... - lint: - name: lint - runs-on: ubuntu-latest - needs: setup - steps: - name: lint uses: https://github.com/golangci/golangci-lint-action@v6 with: @@ -29,14 +24,16 @@ jobs: test: name: test runs-on: ubuntu-latest - # needs: setup steps: + - name: setup-go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: checkout + uses: actions/checkout@v3 + - name: deps + run: go get -v -d ./... - name: test env: INTEGRATION_TESTS: yes run: go test -mod readonly -v ./... - with: - checkout: actions/checkout@v3 - deps: go get -v -d ./... - setup-go: actions/setup-go@v5 - go-version: 'stable' diff --git a/service_test.go b/service_test.go index 270330da..b6bca118 100644 --- a/service_test.go +++ b/service_test.go @@ -28,7 +28,7 @@ func TestClient(t *testing.T) { } x1 := svc.Client("test2") - if x1.Name() == "test2" { + if x1.Name() != "test2" { t.Fatalf("invalid client %#+v", svc.Options().Clients) } } -- 2.45.2 From efd287da027a0b2dd9c27a0e16e4cada62f71b08 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Fri, 6 Dec 2024 03:04:48 +0700 Subject: [PATCH 10/10] Fix yml --- .gitea/workflows/pipeline.yml | 3 ++- .golangci.yml | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .golangci.yml diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 3735ce52..31f97f3b 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -4,6 +4,7 @@ on: branches: - master - v3 + - v4 jobs: lint: name: lint @@ -20,7 +21,7 @@ jobs: - name: lint uses: https://github.com/golangci/golangci-lint-action@v6 with: - version: v1.58 + version: v1.62.2 test: name: test runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..2bb1c300 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,5 @@ +run: + concurrency: 8 + deadline: 5m + issues-exit-code: 1 + tests: true -- 2.45.2