(Engine) Bugfix: Unlocking an unlocked mutex PANIC + Increase dispatcher job capacity via commandline (#371)

* Removes lock unlock timer and instead sets unlocks between getting a nonce and sending a payload. Increases dispatch channel buffer to deal with len(enabledCurrencies) > ~100

* Adds additional comments to help explain the situation

* Fixes bug that could unlock mutex too early

* Fixes LIES where Gemini gets a nonce and then proceeds to declare it doesn't get a nonce causing an unrecoverable lock

* Fun new concept! The creation of a tested timed mutex. Unlocking an unlocked mutex cannot occur and response can be checked to verify whether the mutex was unlocked from timeout or command.

* Adds new cmd parameter "dispatchjobbuffer"

* Expands comments and renames benchmark. Makes `Timer` property private

* Happy little linters

* Renames jobBuffer and all related instances to jobs limit

* Tiny error message update

* Grammatical fix and setting dispatch.Start to use defaults
This commit is contained in:
Scott
2019-10-29 14:00:45 +11:00
committed by Adrian Gallagher
parent 1805c40f20
commit 242b02c382
16 changed files with 301 additions and 139 deletions

View File

@@ -12,7 +12,7 @@ import (
var mux *Mux
func TestMain(m *testing.M) {
err := Start(DefaultMaxWorkers)
err := Start(DefaultMaxWorkers, 0)
if err != nil {
fmt.Println(err)
os.Exit(1)
@@ -34,11 +34,10 @@ func TestDispatcher(t *testing.T) {
t.Error("error cannot be nil")
}
err = Start(10)
err = Start(10, 0)
if err == nil {
t.Error("error cannot be nil")
}
if IsRunning() {
t.Error("should be false")
}
@@ -59,7 +58,7 @@ func TestDispatcher(t *testing.T) {
t.Error("should be true")
}
err = Start(10)
err = Start(10, 0)
if err == nil {
t.Error("error cannot be nil")
}
@@ -99,11 +98,13 @@ func TestDispatcher(t *testing.T) {
t.Error("error cannot be nil")
}
err = Start(0)
err = Start(0, 20)
if err != nil {
t.Error(err)
}
if cap(dispatcher.jobs) != 20 {
t.Errorf("Expected jobs limit to be %v, is %v", 20, cap(dispatcher.jobs))
}
payload := "something"
err = dispatcher.publish(uuid.UUID{}, &payload)
@@ -141,11 +142,13 @@ func TestDispatcher(t *testing.T) {
t.Error("error cannot be nil")
}
err = dispatcher.start(10)
err = dispatcher.start(10, -1)
if err != nil {
t.Error(err)
}
if cap(dispatcher.jobs) != DefaultJobsLimit {
t.Errorf("Expected jobs limit to be %v, is %v", DefaultJobsLimit, cap(dispatcher.jobs))
}
someID, err := uuid.NewV4()
if err != nil {
t.Error(err)