-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from enriquebris/development
v0.10.0
- Loading branch information
Showing
24 changed files
with
4,228 additions
and
1,271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Enrique Bris | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ** goworkerpool.com ********************************************************************************************** | ||
// ** github.com/enriquebris/goworkerpool ** | ||
// ** v0.10.0 ******************************************************************************************************* | ||
|
||
package goworkerpool | ||
|
||
const ( | ||
actionKillWorker = "kill.worker" | ||
actionLateKillWorker = "late.kill.worker" // late kill worker | ||
actionLateKillAllWorkers = "late.kill.all.workers" | ||
actionLateKillWorkers = "late.kill.workers" | ||
actionPauseAllWorkers = "pause.all.workers" | ||
) | ||
|
||
// action represents an action | ||
// An action would be normally sent to a worker, unless SendToWorker was false. | ||
// The PreExternalFunc function (if any) would be executed by the dispatcher just before send the action to a worker. In | ||
// case that SendToWorker was false, the dispatcher would execute the function and continue to the next iteration. | ||
type action struct { | ||
// action code | ||
Code string | ||
// to let the dispatcher knows whether the action should be sent to a worker. The dispatcher would process actions | ||
// if they are not sent to workers. | ||
SendToWorker bool | ||
// to be executed by the dispatcher just before send the action to a worker (in case the action was to be sent to the worker) | ||
PreExternalFunc dispatcherGeneralFunc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// ** goworkerpool.com ********************************************************************************************** | ||
// ** github.com/enriquebris/goworkerpool ** | ||
// ** v0.10.0 ******************************************************************************************************* | ||
|
||
package goworkerpool | ||
|
||
const ( | ||
ErrorEmbeddedErrors = "embedded.errors" | ||
ErrorData = "wrong.data" | ||
ErrorKillAllWorkersInProgress = "action.kill.all.workers.in.progress" | ||
ErrorWaitInProgress = "action.wait.in.progress" | ||
ErrorWaitUntilInitialWorkersAreUpInProgress = "action.wait.until.initial.workers.are.up.in.progress" | ||
ErrorDispatcherNoActionNoTask = "dispatcher.no.action.no.task" | ||
ErrorDispatcherWorkerCouldNotBeEnqueued = "dispatcher.worker.couldnt.be.enqueued" | ||
ErrorNoDefaultWorkerFunction = "no.default.worker.function" | ||
ErrorDispatcherChannelFull = "dispatcher.channel.at.full.capacity" | ||
ErrorFullCapacityChannel = "full.capacity.channel" | ||
ErrorWorkerNotFound = "worker.not.found" | ||
ErrorWorkerType = "worker.wrong.type" | ||
ErrorWorkerMaxTimeExceeded = "worker.max.time.exceeded" | ||
ErrorWorkerFuncPanic = "worker.func.panic" | ||
) | ||
|
||
type PoolError struct { | ||
code string | ||
message string | ||
embeddedErrors []error | ||
} | ||
|
||
func newPoolError(code string, message string) *PoolError { | ||
return &PoolError{ | ||
code: code, | ||
message: message, | ||
} | ||
} | ||
|
||
func (st *PoolError) Error() string { | ||
return st.message | ||
} | ||
|
||
func (st *PoolError) Code() string { | ||
return st.code | ||
} | ||
|
||
// AddEmbeddedErrors adds a slice of errors | ||
func (st *PoolError) AddEmbeddedErrors(errors []error) { | ||
st.embeddedErrors = errors | ||
} | ||
|
||
func (st *PoolError) GetEmbeddedErrors() []error { | ||
return st.embeddedErrors | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ** goworkerpool.com ********************************************************************************************** | ||
// ** github.com/enriquebris/goworkerpool ** | ||
// ** v0.10.0 ******************************************************************************************************* | ||
|
||
package goworkerpool | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type PoolErrorTestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
// *************************************************************************************** | ||
// ** Initialization | ||
// *************************************************************************************** | ||
|
||
// no elements at initialization | ||
func (suite *PoolErrorTestSuite) TestInitialization() { | ||
queueError := newPoolError("code", "message") | ||
|
||
suite.Equal("code", queueError.Code()) | ||
suite.Equal("message", queueError.Error()) | ||
} | ||
|
||
// *************************************************************************************** | ||
// ** Run suite | ||
// *************************************************************************************** | ||
|
||
func TestQueueErrorTestSuite(t *testing.T) { | ||
suite.Run(t, new(PoolErrorTestSuite)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.