diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e3c9e7a5e0d8c19e318955135cbd444f34699531..f0ed4807c03cd63f6e71f5411e06466bbe02f6c1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,9 +4,7 @@ <option name="autoReloadType" value="SELECTIVE" /> </component> <component name="ChangeListManager"> - <list default="true" id="9979eb22-471e-4f2f-b624-fd3edb5e8c6e" name="Changes" comment=""> - <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> - </list> + <list default="true" id="9979eb22-471e-4f2f-b624-fd3edb5e8c6e" name="Changes" comment="" /> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> @@ -26,7 +24,7 @@ <component name="Git.Settings"> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> </component> - <component name="PhpWorkspaceProjectConfiguration" interpreter_name="PHP 8.2" /> + <component name="PhpWorkspaceProjectConfiguration" interpreter_name="PHP 8.3 with extension" /> <component name="ProjectColorInfo">{ "customColor": "", "associatedIndex": 8 @@ -40,54 +38,55 @@ <option name="sortByType" value="true" /> <option name="sortKey" value="BY_TYPE" /> </component> - <component name="PropertiesComponent">{ - "keyToString": { - "DefaultGoTemplateProperty": "Go File", - "Go Test.TestCreateJobAndSchedulerFromInput in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestDummyRunnable in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestJobPersistenceUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestJobPersistenceUnmarshalJSON/Date_and_Time in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestJobPersistenceUnmarshalJSON/RFC3339_Format in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestJobPersistence_MarshalUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestManagerEventHandling in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestReadJsonFile in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestResetStats in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestSchedulerPersistenceUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestSchedulerPersistenceUnmarshalJSON/Date_and_Time_with_Space in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestSchedulerPersistenceUnmarshalJSON/Date_and_Time_with_Space_and_Seconds in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestSetAndGetTimeout in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestUnmarshalSchedulerPersistenceIntervalYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestUnmarshalSchedulerPersistenceYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestUnmarshalYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestWriteToDB2 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.TestWriteToDB4 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "Go Test.go test gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.go.formatter.settings.were.checked": "true", - "RunOnceActivity.go.migrated.go.modules.settings": "true", - "RunOnceActivity.go.modules.automatic.dependencies.download": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "git-widget-placeholder": "master", - "go.import.settings.migrated": "true", - "go.sdk.automatically.set": "true", - "last_opened_file_path": "/home/vs/workspaces/oss/go-libs/job-queues/nix/scripts", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "http.proxy", - "vue.rearranger.settings.migration": "true" + <component name="PropertiesComponent"><![CDATA[{ + "keyToString": { + "DefaultGoTemplateProperty": "Go File", + "Go Test.TestCreateJobAndSchedulerFromInput in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestDummyRunnable in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestJobPersistenceUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestJobPersistenceUnmarshalJSON/Date_and_Time in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestJobPersistenceUnmarshalJSON/RFC3339_Format in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestJobPersistence_MarshalUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestManagerEventHandling in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestReadJsonFile in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestResetStats in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestSchedulerPersistenceUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestSchedulerPersistenceUnmarshalJSON/Date_and_Time_with_Space in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestSchedulerPersistenceUnmarshalJSON/Date_and_Time_with_Space_and_Seconds in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestSetAndGetTimeout in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestUnmarshalJSON in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestUnmarshalSchedulerPersistenceIntervalYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestUnmarshalSchedulerPersistenceYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestUnmarshalYAML in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestWriteToDB2 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestWriteToDB4 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.go test gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.go.formatter.settings.were.checked": "true", + "RunOnceActivity.go.migrated.go.modules.settings": "true", + "RunOnceActivity.go.modules.automatic.dependencies.download": "true", + "SHARE_PROJECT_CONFIGURATION_FILES": "true", + "git-widget-placeholder": "master", + "go.import.settings.migrated": "true", + "go.sdk.automatically.set": "true", + "last_opened_file_path": "/home/vs/workspaces/oss/go-libs/job-queues", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "http.proxy", + "vue.rearranger.settings.migration": "true" } -}</component> +}]]></component> <component name="RecentsManager"> <key name="CopyFile.RECENT_KEYS"> + <recent name="$PROJECT_DIR$" /> <recent name="$PROJECT_DIR$/nix/scripts" /> <recent name="$PROJECT_DIR$/system/scripts" /> </key> @@ -195,6 +194,17 @@ </list> </option> </component> + <component name="Vcs.Log.Tabs.Properties"> + <option name="TAB_STATES"> + <map> + <entry key="MAIN"> + <value> + <State /> + </value> + </entry> + </map> + </option> + </component> <component name="VgoProject"> <settings-migrated>true</settings-migrated> </component> diff --git a/event-bus.go b/event-bus.go index 413c51bff2ee9674e07df8e7eea7ff2891a3e988..fc6988e4dcbb2e6a4b9c1c330c2e4f67451e2490 100644 --- a/event-bus.go +++ b/event-bus.go @@ -21,6 +21,7 @@ const ( JobReady EventName = "JobReady" QueueJob EventName = "QueueJob" JobFinished EventName = "JobFinished" + JobDone EventName = "JobDone" ) type MessageID string diff --git a/manager.go b/manager.go index 4a9e63f58ff3d34316ee5cab88c50972d62c0831..8f095ebb813ba272d63ced66109f20dabf49f394 100644 --- a/manager.go +++ b/manager.go @@ -746,9 +746,11 @@ func (m *Manager) handleJobEvents() { } else { + eventBus := m.GetEventBus() + eventBus.Publish(JobDone, nextJob) + if nextJob.GetScheduler() != nil { if nextJob.GetScheduler().IsAdHoc() { - eventBus := m.GetEventBus() eventBus.Publish(JobFinished, nextJob) } } diff --git a/runnable-counter.go b/runnable-counter.go index 25f8208309ff3ca18d841e8e8b63298ab0d1bbcf..05a39ffdc828df127c8e9e0249107a3dc244a3e6 100644 --- a/runnable-counter.go +++ b/runnable-counter.go @@ -6,6 +6,7 @@ package jobqueue import ( "context" "fmt" + "strconv" "sync" ) @@ -14,6 +15,21 @@ func NewCounterRunnableFromMap(data map[string]any) (*CounterRunnable, error) { // in go numbers are float64 by default floatCount, ok := data["count"].(float64) if !ok { + + intCount, ok := data["count"].(int) + if ok { + return &CounterRunnable{Count: intCount}, nil + } + + stringCount, ok := data["count"].(string) + if ok { + intCount, err := strconv.Atoi(stringCount) + if err != nil { + return nil, fmt.Errorf("%w: Invalid count: %v", ErrInvalidData, data["count"]) + } + return &CounterRunnable{Count: intCount}, nil + } + return nil, fmt.Errorf("%w: Invalid count: %v", ErrInvalidData, data["count"]) }