From b8590c71206debd6011d154c287fbddcb814e6ef Mon Sep 17 00:00:00 2001 From: Artem Date: Sun, 13 Nov 2022 23:32:15 +0400 Subject: [PATCH] workflow --- .github/workflows/tests.yml | 34 ++++++++++++++++++++++++++++++++++ .golangci.yml | 14 ++++++++++++++ README.md | 6 ++++-- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tests.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c26c564 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +on: + push: + +name: Tests +jobs: + golangci: + name: Linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2.3.0 + with: + version: v1.49.0 + args: --timeout=2m --go=1.19 + security: + name: Security Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: 'go' + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..a234555 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,14 @@ +linters: + enable: + - goconst + - gocritic + - gofmt + - govet + - prealloc + - unconvert + - unused + - errcheck + - ineffassign + - containedctx + - tenv + diff --git a/README.md b/README.md index ec89f27..0896c60 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ func dispatcher(ctx context.Context) ([]string, error) { } ``` -`NewTimedPool` receives as arguments 3 handlers: `Dispatcher`, `Worker` and `ErrorHandler`. It's declared like this: +`NewTimedPool` receives as arguments 3 handlers: `Dispatcher`, `Worker` and `ErrorHandler`. ```go // Worker - worker handler. Calls on task arriving. @@ -117,4 +117,6 @@ type Dispatcher[Task any] func(ctx context.Context) ([]Task, error) // ErrorHandler - the function is called when error occured in dispatcher type ErrorHandler[Task any] func(ctx context.Context, err error) -``` \ No newline at end of file +``` + +Also it receives 2 integers: workers count and time between dispatcher calls in milliseconds. \ No newline at end of file