Skip to content

Commit

Permalink
Switch to non-blocking call in action
Browse files Browse the repository at this point in the history
- UpgradeDeployTargetAppsSucceedAction can't use
  old non-reactive api's as we can't block within
  sm execution.
  • Loading branch information
jvalkeal committed Apr 8, 2024
1 parent 047b373 commit afd208b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,12 @@
*/
package org.springframework.cloud.skipper.server.statemachine;

import reactor.core.publisher.Mono;

import org.springframework.cloud.skipper.server.statemachine.SkipperStateMachineService.SkipperEvents;
import org.springframework.cloud.skipper.server.statemachine.SkipperStateMachineService.SkipperStates;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;

Expand All @@ -32,6 +36,10 @@ public class UpgradeDeployTargetAppsSucceedAction extends AbstractAction {
protected void executeInternal(StateContext<SkipperStates, SkipperEvents> context) {
// TODO: when we support other type of strategies, we would not need to just
// blindly send accept as we can also cancel upgrade in this stage.
context.getStateMachine().sendEvent(SkipperEvents.UPGRADE_ACCEPT);
Message<SkipperEvents> event = MessageBuilder.withPayload(SkipperEvents.UPGRADE_ACCEPT).build();
// TODO: blindly sending event and subscribing(we can't block here) into it is not
// super nice, should look better reactive chain possibly better
// reactive support in a statemachine
context.getStateMachine().sendEvent(Mono.just(event)).subscribe();
}
}

0 comments on commit afd208b

Please sign in to comment.