This commit is contained in:
2024-04-09 00:01:28 +03:00
parent b9d24f45ff
commit 37ea64509a
19 changed files with 54 additions and 174 deletions
-3
View File
@@ -1,3 +0,0 @@
# These are supported funding model platforms
github: alitto
-70
View File
@@ -1,70 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '40 15 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
-41
View File
@@ -1,41 +0,0 @@
on:
push:
branches:
- master
- main
pull_request:
name: Build
jobs:
test:
name: Test
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make test
codecov:
name: Upload coverage report to Codecov
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make coverage
- uses: codecov/codecov-action@v3
with:
files: coverage.out
fail_ci_if_error: true
verbose: true
+7 -5
View File
@@ -4,6 +4,7 @@
<a title="Go Report Card" target="_blank" href="https://goreportcard.com/report/github.com/alitto/pond"><img src="https://goreportcard.com/badge/github.com/alitto/pond"/></a> <a title="Go Report Card" target="_blank" href="https://goreportcard.com/report/github.com/alitto/pond"><img src="https://goreportcard.com/badge/github.com/alitto/pond"/></a>
# pond # pond
Minimalistic and High-performance goroutine worker pool written in Go Minimalistic and High-performance goroutine worker pool written in Go
## Motivation ## Motivation
@@ -40,7 +41,7 @@ Some common scenarios include:
## How to install ## How to install
```bash ```bash
go get -u github.com/alitto/pond go get -u git.company.lan/gopkg/pond
``` ```
## How to use ## How to use
@@ -53,7 +54,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
@@ -83,7 +84,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
@@ -113,7 +114,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
@@ -150,7 +151,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
@@ -260,6 +261,7 @@ As the name suggests, the "Eager" strategy always spawns an extra worker when th
### Stopping a pool ### Stopping a pool
There are 3 methods available to stop a pool and release associated resources: There are 3 methods available to stop a pool and release associated resources:
- `pool.Stop()`: stop accepting new tasks and signal all workers to stop processing new tasks. Tasks being processed by workers will continue until completion unless the process is terminated. - `pool.Stop()`: stop accepting new tasks and signal all workers to stop processing new tasks. Tasks being processed by workers will continue until completion unless the process is terminated.
- `pool.StopAndWait()`: stop accepting new tasks and wait until all running and queued tasks have completed before returning. - `pool.StopAndWait()`: stop accepting new tasks and wait until all running and queued tasks have completed before returning.
- `pool.StopAndWaitFor(deadline time.Duration)`: similar to `StopAndWait` but with a deadline to prevent waiting indefinitely. - `pool.StopAndWaitFor(deadline time.Duration)`: similar to `StopAndWait` but with a deadline to prevent waiting indefinitely.
+1 -1
View File
@@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
+3 -5
View File
@@ -1,9 +1,7 @@
module github.com/alitto/pond/examples/dynamic_size module git.company.lan/gopkg/pond/examples/dynamic_size
go 1.19 go 1.19
require ( require git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
github.com/alitto/pond v1.7.1
)
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+1 -1
View File
@@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
+3 -5
View File
@@ -1,9 +1,7 @@
module github.com/alitto/pond/examples/fixed_size module git.company.lan/gopkg/pond/examples/fixed_size
go 1.19 go 1.19
require ( require git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
github.com/alitto/pond v1.7.1
)
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+3 -5
View File
@@ -1,9 +1,7 @@
module github.com/alitto/pond/examples/group_context module git.company.lan/gopkg/pond/examples/group_context
go 1.19 go 1.19
require ( require git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
github.com/alitto/pond v1.7.1
)
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
+3 -3
View File
@@ -1,7 +1,7 @@
module github.com/alitto/pond/examples/pool_context module git.company.lan/gopkg/pond/examples/pool_context
go 1.19 go 1.19
require github.com/alitto/pond v1.7.1 require git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"os/signal" "os/signal"
"time" "time"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
// Pressing Ctrl+C while this program is running will cause the program to terminate gracefully. // Pressing Ctrl+C while this program is running will cause the program to terminate gracefully.
+3 -3
View File
@@ -1,9 +1,9 @@
module github.com/alitto/pond/examples/fixed_size module git.company.lan/gopkg/pond/examples/fixed_size
go 1.19 go 1.19
require ( require (
github.com/alitto/pond v1.7.1 git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
github.com/prometheus/client_golang v1.11.1 github.com/prometheus/client_golang v1.11.1
) )
@@ -19,4 +19,4 @@ require (
google.golang.org/protobuf v1.33.0 // indirect google.golang.org/protobuf v1.33.0 // indirect
) )
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
) )
+3 -5
View File
@@ -1,9 +1,7 @@
module github.com/alitto/pond/examples/task_group module git.company.lan/gopkg/pond/examples/task_group
go 1.19 go 1.19
require ( require git.company.lan/gopkg/pond v0.0.0-00010101000000-000000000000
github.com/alitto/pond v1.7.1
)
replace github.com/alitto/pond => ../../ replace git.company.lan/gopkg/pond => ../../
+1 -1
View File
@@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func main() { func main() {
+1 -1
View File
@@ -1,3 +1,3 @@
module github.com/alitto/pond module git.company.lan/gopkg/pond
go 1.19 go 1.19
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func TestGroupSubmit(t *testing.T) { func TestGroupSubmit(t *testing.T) {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/alitto/pond" "git.company.lan/gopkg/pond"
) )
func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func assertEqual(t *testing.T, expected interface{}, actual interface{}) {