Skip to content

feat(api): return job log ID from scheduler start API#3103

Merged
marevol merged 1 commit intomasterfrom
feat/scheduler-api-return-job-log-id
Mar 28, 2026
Merged

feat(api): return job log ID from scheduler start API#3103
marevol merged 1 commit intomasterfrom
feat/scheduler-api-return-job-log-id

Conversation

@marevol
Copy link
Copy Markdown
Contributor

@marevol marevol commented Mar 28, 2026

Summary

Implements #1433: The scheduler start API (PUT /api/admin/scheduler/{id}/start) now returns the associated job log ID in the response, allowing clients to programmatically track job execution without parsing scriptData.

Changes Made

  • Constants.java: Added JOB_LOG_ID constant for the parameter key
  • ScheduledJob.java: Added start(Map<String, Object> params) overload that passes parameters to LastaFlute's launchNow() via LaunchNowOption.param()
  • ScriptExecutorJob.java: Reads JOB_LOG_ID from runtime.getParameterMap() and sets it on the JobLog before persisting to OpenSearch
  • ApiResult.java: Added ApiStartJobResponse inner class with jobLogId field
  • ApiAdminSchedulerAction.java: Generates a UUID when job logging is enabled, passes it to entity.start(Map), and returns it in ApiStartJobResponse

Response format

When logging is enabled:

{"response": {"version": "14.x", "status": 0, "jobLogId": "a1b2c3d4e5f6..."}}

When logging is disabled:

{"response": {"version": "14.x", "status": 0, "jobLogId": null}}

Testing

  • ApiAdminSchedulerActionTest (2 tests): Calls real put$start() with injected mock service, verifies jobLogId is non-null (32-char hex) when logging enabled, and null when disabled
  • ScriptExecutorJobTest (4 tests): Calls real process() via MockJobRuntime, verifies pre-generated ID is set on JobLog when present, null when absent, and not stored when logging disabled
  • ApiResultTest (10 tests): Verifies ApiStartJobResponse DTO construction, fluent API, and Status enum
  • JobLogTest (7 tests): Verifies entity construction, ID pre-setting, and UUID format
  • ScheduledJobTest (16 tests): Verifies entity state methods and start(Map) parameter passing via launchNow

Breaking Changes

None. The existing start() no-arg method is unchanged (used by Admin UI and Wizard). The API response adds a new field (jobLogId) which is additive.

Additional Notes

  • The job log ID is a 32-character hex UUID (no dashes), consistent with OpenSearch document ID format
  • launchNow() is asynchronous, so the job log may not exist immediately after the API returns. The ID is pre-generated and guaranteed to be used when the job executes.
  • Backward compatible: existing API consumers will simply see the new jobLogId field in the response

Pre-generate a UUID for the JobLog document ID in the API action,
pass it to the async job via LastaFlute launchNow params, and
return it in the response so clients can track job execution.
@marevol marevol self-assigned this Mar 28, 2026
@marevol marevol added this to the 15.6.0 milestone Mar 28, 2026
@marevol marevol merged commit 8fc65a4 into master Mar 28, 2026
1 check passed
marevol added a commit to codelibs/fessctl that referenced this pull request Mar 28, 2026
Support the new jobLogId field added in codelibs/fess#3103. When a
scheduler is started and job logging is enabled, the API now returns
a pre-generated job log ID. Display it in text output so users can
track job execution. JSON/YAML output already includes it via raw
response dump. Backward compatible with older Fess versions.
marevol added a commit to codelibs/fessctl that referenced this pull request Mar 28, 2026
)

Support the new jobLogId field added in codelibs/fess#3103. When a
scheduler is started and job logging is enabled, the API now returns
a pre-generated job log ID. Display it in text output so users can
track job execution. JSON/YAML output already includes it via raw
response dump. Backward compatible with older Fess versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant