-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9779: 9725 rename and improve interfaces r=pihme a=pihme ## Description - Renames interfaces to make it clearer that there could be multiple `RecordProcessor` implementations - Define interfaces for `ProcessingResultBuilder` and `ProcessingResult` ## Related issues <!-- Which issues are closed by this PR or are related --> related to #9725 Co-authored-by: pihme <pihme@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
202 additions
and
88 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
23 changes: 0 additions & 23 deletions
23
engine/src/main/java/io/camunda/zeebe/engine/api/Engine.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
engine/src/main/java/io/camunda/zeebe/engine/api/EngineContext.java
This file was deleted.
Oops, something went wrong.
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
76 changes: 76 additions & 0 deletions
76
engine/src/main/java/io/camunda/zeebe/engine/api/RecordProcessor.java
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,76 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.engine.api; | ||
|
||
/** | ||
* Interface for record processors. A record processor is responsible for handling a single record. | ||
* (The class {@code StreamProcessor} in turn is responsible for handling a stream of records. | ||
*/ | ||
public interface RecordProcessor { | ||
|
||
/** | ||
* Called by platform to initialize the processor | ||
* | ||
* @param recordProcessorContext context object to initialize the processor | ||
*/ | ||
void init(RecordProcessorContext recordProcessorContext); | ||
|
||
/** | ||
* Called by platform in order to replay a single record | ||
* | ||
* <p><em>Contract</em> | ||
* | ||
* <ul> | ||
* <li>Record will be an event | ||
* <li>Will be called before processing is called | ||
* <li>Implementors can write to the database. Transaction is provided by platform, which also | ||
* takes care of lifecycle of the transaction | ||
* <li>Implementors must not write to the log stream | ||
* <li>Implementors must not schedule post commit tasks | ||
* </ul> | ||
* | ||
* @param record the record to replay | ||
*/ | ||
void replay(TypedRecord record); | ||
|
||
/** | ||
* Called by platform to process a single record | ||
* | ||
* <p><em>Contract</em> * * | ||
* | ||
* <ul> | ||
* * | ||
* <li>Record will be a command | ||
* <li>Will be called after replay is called | ||
* <li>Implementors can write to the database. Transaction is provided by platform, which also * | ||
* takes care of lifecycle of the transaction | ||
* <li>Implementors must ensure that if they generate follow up events, these are applied to the | ||
* database while this method is called | ||
* <li>Implementors can produce follow up commands and events, client responses and on commit | ||
* tasks via {@code * processingContext.getProcessingResultBuilder(). ... .build()} | ||
* </ul> | ||
* | ||
* @param record | ||
* @param processingContext | ||
* @return the result of the processing; must be generated via {@code | ||
* processingContext.getProcessingResultBuilder().build()} | ||
*/ | ||
ProcessingResult process(TypedRecord record, ProcessingContext processingContext); | ||
|
||
/** | ||
* Called by platform when a processing error occurred | ||
* | ||
* @param processingException the exception that was thrown | ||
* @param record the record for which the exception was thrown | ||
* @param errorHandlingContext tbd | ||
* @return the result of the processing; must be generated via {@code * | ||
* processingContext.getProcessingResultBuilder().build()} | ||
*/ | ||
ProcessingResult onProcessingError( | ||
Throwable processingException, TypedRecord record, ErrorHandlingContext errorHandlingContext); | ||
} |
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
28 changes: 28 additions & 0 deletions
28
.../java/io/camunda/zeebe/engine/processing/streamprocessor/TypedRecordProcessorContext.java
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,28 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.engine.processing.streamprocessor; | ||
|
||
import io.camunda.zeebe.engine.api.ProcessingScheduleService; | ||
import io.camunda.zeebe.engine.processing.streamprocessor.writers.Writers; | ||
import io.camunda.zeebe.engine.state.immutable.LastProcessedPositionState; | ||
import io.camunda.zeebe.engine.state.mutable.MutableZeebeState; | ||
|
||
public interface TypedRecordProcessorContext { | ||
|
||
int getPartitionId(); | ||
|
||
ProcessingScheduleService getScheduleService(); | ||
|
||
MutableZeebeState getZeebeState(); | ||
|
||
Writers getWriters(); | ||
|
||
LastProcessedPositionState getLastProcessedPositionState(); | ||
|
||
TypedRecordProcessorContext listener(StreamProcessorListener streamProcessorListener); | ||
} |
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.