001/*- 002 * #%L 003 * HAPI FHIR JPA Server - Batch2 Task Processor 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.batch2.api; 021 022import ca.uhn.fhir.model.api.IModelJson; 023import jakarta.annotation.Nonnull; 024 025/** 026 * This interface is implemented by step workers within the Batch2 framework. It will be called 027 * 0..* times depending on the number of work chunks produced by the previous step. It will 028 * always be called once in the case of the first step. It can produce 0..* work chunks that 029 * will be processed in subsequent steps. 030 * 031 * @param <PT> The job parameters type datatype 032 * @param <IT> The step input datatype 033 * @param <OT> The step output datatype 034 */ 035public interface IJobStepWorker<PT extends IModelJson, IT extends IModelJson, OT extends IModelJson> { 036 037 /** 038 * Executes a step 039 * 040 * @param theStepExecutionDetails Contains details about the individual execution 041 * @param theDataSink A data sink for data produced during this step. This may never 042 * be used during the final step of a job. 043 * @return Returns a {@link RunOutcome} containing details about the execution. See the javadoc for that class for details about how to populate it. 044 * @throws JobExecutionFailedException This exception indicates an unrecoverable failure. If a 045 * step worker throws this exception, processing for the 046 * job will be aborted. 047 */ 048 @Nonnull 049 RunOutcome run(@Nonnull StepExecutionDetails<PT, IT> theStepExecutionDetails, @Nonnull IJobDataSink<OT> theDataSink) 050 throws JobExecutionFailedException; 051}