-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support consuming N message in a single command (#198)
Co-authored-by: Kaili Zhu <[email protected]>
- Loading branch information
Showing
12 changed files
with
477 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.iworkflow.core.command; | ||
|
||
import io.iworkflow.core.communication.InternalChannelCommand; | ||
import io.iworkflow.core.communication.SignalCommand; | ||
import org.immutables.value.Value; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Value.Immutable | ||
public abstract class SuperCommand implements BaseCommand { | ||
|
||
public enum Type { | ||
SIGNAL_CHANNEL, | ||
INTERNAL_CHANNEL, | ||
} | ||
|
||
public abstract String getName(); | ||
public abstract int getCount(); | ||
public abstract Type getType(); | ||
|
||
public static List<BaseCommand> toList(final SuperCommand superCommand) { | ||
final List<BaseCommand> commands = new ArrayList<>(); | ||
|
||
final boolean hasCommandId = superCommand.getCommandId().isPresent(); | ||
for (int i = 0; i < superCommand.getCount(); i ++) { | ||
final BaseCommand command; | ||
if (superCommand.getType() == Type.INTERNAL_CHANNEL) { | ||
if (hasCommandId) { | ||
command = InternalChannelCommand.create(superCommand.getCommandId().get(), superCommand.getName()); | ||
} else { | ||
command = InternalChannelCommand.create(superCommand.getName()); | ||
} | ||
} else { | ||
if (hasCommandId) { | ||
command = SignalCommand.create(superCommand.getCommandId().get(), superCommand.getName()); | ||
} else { | ||
command = SignalCommand.create(superCommand.getName()); | ||
} | ||
} | ||
|
||
commands.add(command); | ||
} | ||
|
||
return commands; | ||
} | ||
} |
51 changes: 49 additions & 2 deletions
51
src/main/java/io/iworkflow/core/communication/InternalChannelCommand.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
53 changes: 50 additions & 3 deletions
53
src/main/java/io/iworkflow/core/communication/SignalCommand.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
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
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
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.