Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add new ReactiveActions to StateMachineConfiguration? #1134

Open
davefarrelly opened this issue Jan 15, 2024 · 0 comments
Open

How to add new ReactiveActions to StateMachineConfiguration? #1134

davefarrelly opened this issue Jan 15, 2024 · 0 comments
Labels
status/need-triage Team needs to triage and take a first look

Comments

@davefarrelly
Copy link

Hi, I am looking to upgrade to v4.0.0 and switch to the new ReactiveActions , however I am not entirely sure how to migrate my project.

Currently I have a StateMachineConfiguration and I add the Actions to the states using the StateMachineStateConfigurer

@Override
public void configure(StateMachineStateConfigurer<CommitState, CommitEvent> states) throws Exception {
	states.withStates()
			.initial(CommitState.BEFORE_COMMIT)
			.state(CommitState.COMMIT_BLOCKS, commitStateService.commitBlocks())
			.end(CommitState.COMPLETE);
}

Where the Action is defined as:

public Action<CommitState, CommitEvent> commitBlocks() {
	return context -> {
	  UUID uploadSessionId = getStateMachineId(context.getStateMachine());

	  digestStrategyContext.commitBlockLists(uploadSessionId)
		  .doOnSuccess(result -> sendEvent(context, CommitEvent.COMMIT_SUCCESS))
		  .subscribe();
	};
}

It technically works, but of course isn't ideal as I am subscribing here inside the action and breaking my reactive chain. But if I create a new ReactiveAction that returns a Mono, how do I actually add it to the state like .state(CommitState.COMMIT_BLOCKS, commitStateService.commitBlocks()) ?

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-triage Team needs to triage and take a first look
Projects
None yet
Development

No branches or pull requests

1 participant