All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pivotal.services.plugin.tasks.helper.CfScaleInstanceCountDelegate Maven / Gradle / Ivy

There is a newer version: 2.3.0-rc.6
Show newest version
package io.pivotal.services.plugin.tasks.helper;

import io.pivotal.services.plugin.CfProperties;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.applications.ScaleApplicationRequest;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import reactor.core.publisher.Mono;

/**
 * Helper class for scaling instance Count of an app
 *
 * @author Biju Kunjummen
 */
public class CfScaleInstanceCountDelegate {

    private static final Logger LOGGER = Logging.getLogger(CfScaleInstanceCountDelegate.class);

    public Mono scaleInstances(CloudFoundryOperations cfOperations,
                                     CfProperties cfProperties, int instanceCount) {

        Mono resp = cfOperations.applications().scale(
            ScaleApplicationRequest.builder()
                .instances(instanceCount)
                .build()
        ).doOnSubscribe((s) -> {
            LOGGER.lifecycle("Scaling app {} to instance count {}", cfProperties.name(), instanceCount);
        });

        return resp;

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy