Skip to content

Commit

Permalink
feat(boost): cancel parent on send timeout; not resolved (#68)
Browse files Browse the repository at this point in the history
ref(boost): minor refactorings (#68)

feat(boost): return a pool result (#68)

feat(boost): invoke parent cancel on output timeout (#68)

feat(boost): fix up 18n (#68)
  • Loading branch information
plastikfan committed Sep 22, 2023
1 parent 7034927 commit 1a4b397
Show file tree
Hide file tree
Showing 22 changed files with 474 additions and 384 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -20,7 +20,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19]
go-version: [1.21]
platform: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.platform }}
Expand Down
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ linters:
enable:
- bodyclose
# - deadcode
- depguard
# depguard needs to be reviewed properly and then configured, before
# it can be re-enabled.
# https://github.com/OpenPeeDeeP/depguard#example-configs
# - depguard
- dogsled
# - dupl
- errcheck
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
rev: v1.54.2
hooks:
- id: golangci-lint

Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"cSpell.words": [
"Assistable",
"astrolib",
"bodyclose",
"coverpkg",
"cubiest",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/snivilised/lorax.svg)](https://pkg.go.dev/github.com/snivilised/lorax)
[![Go report](https://goreportcard.com/badge/github.com/snivilised/lorax)](https://goreportcard.com/report/github.com/snivilised/lorax)
[![Coverage Status](https://coveralls.io/repos/github/snivilised/lorax/badge.svg?branch=master)](https://coveralls.io/github/snivilised/lorax?branch=master&kill_cache=1)
[![Astrolib Continuous Integration](https://github.com/snivilised/lorax/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/lorax/actions/workflows/ci-workflow.yml)
[![lorax Continuous Integration](https://github.com/snivilised/lorax/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/lorax/actions/workflows/ci-workflow.yml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![A B](https://img.shields.io/badge/commit-conventional-commits?style=flat)](https://www.conventionalcommits.org/)

Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ tasks:
- goi18n extract
-format json
-sourceLanguage "en-GB"
-outdir ./i18n/out/l10n
-outdir ./i18n/out

# new translation
newt:
deps: [extract]
cmds:
- touch ./i18n/out/l10n/translate.en-US.json
- touch ./i18n/out/translate.en-US.json

# derive a translation from the default
merge:
Expand All @@ -128,7 +128,7 @@ tasks:
-format json
-sourceLanguage "en-GB"
-outdir ./i18n/out
./i18n/out/active.en-GB.json ./i18n/out/l10n/translate.en-US.json
./i18n/out/active.en-GB.json ./i18n/out/translate.en-US.json

# update existing translations
# after running this task, the translation file generated will
Expand Down
59 changes: 32 additions & 27 deletions boost/boost-public-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,41 @@ const (
MaxWorkers = 100
)

type Job[I any] struct {
ID string
Input I
SequenceNo int
}
type (
Job[I any] struct {
ID string
Input I
SequenceNo int
}

JobOutput[O any] struct {
Payload O
}

JobStream[I any] chan Job[I]
JobStreamR[I any] <-chan Job[I]
JobStreamW[I any] chan<- Job[I]

OutputStream[O any] chan JobOutput[O]
OutputStreamR[O any] <-chan JobOutput[O]
OutputStreamW[O any] chan<- JobOutput[O]

CancelWorkSignal struct{}
CancelStream = chan CancelWorkSignal
CancelStreamR = <-chan CancelWorkSignal
CancelStreamW = chan<- CancelWorkSignal

PoolResult struct {
Error error
}

PoolResultStream = chan *PoolResult
PoolResultStreamR = <-chan *PoolResult
PoolResultStreamW = chan<- *PoolResult
)

type ExecutiveFunc[I, O any] func(j Job[I]) (JobOutput[O], error)

func (f ExecutiveFunc[I, O]) Invoke(j Job[I]) (JobOutput[O], error) {
return f(j)
}

type JobOutput[O any] struct {
Payload O
}

type JobStream[I any] chan Job[I]
type JobStreamR[I any] <-chan Job[I]
type JobStreamW[I any] chan<- Job[I]

type OutputStream[O any] chan JobOutput[O]
type OutputStreamR[O any] <-chan JobOutput[O]
type OutputStreamW[O any] chan<- JobOutput[O]

type CancelWorkSignal struct{}
type CancelStream = chan CancelWorkSignal
type CancelStreamR = <-chan CancelWorkSignal
type CancelStreamW = chan<- CancelWorkSignal

type WorkerID string
type FinishedStream = chan WorkerID
type FinishedStreamR = <-chan WorkerID
type FinishedStreamW = chan<- WorkerID
22 changes: 17 additions & 5 deletions boost/pool-defs-internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ const (
DefaultChSize = 100
)

type workerWrapper[I any, O any] struct {
cancelChOut chan<- CancelWorkSignal
core *worker[I, O]
}
type (
workerID string
workerFinishedResult struct {
id workerID
err error
}

type workersCollection[I, O any] map[WorkerID]*workerWrapper[I, O]
finishedStream = chan *workerFinishedResult
finishedStreamR = <-chan *workerFinishedResult
finishedStreamW = chan<- *workerFinishedResult

workerWrapper[I any, O any] struct {
cancelChOut CancelStreamW
core *worker[I, O]
}

workersCollection[I, O any] map[workerID]*workerWrapper[I, O]
)
Loading

0 comments on commit 1a4b397

Please sign in to comment.