use of com.netflix.titus.grpc.protogen.ScalingPolicyResult in project titus-control-plane by Netflix.
the class DefaultAutoScalingServiceGrpc method getScalingPolicy.
@Override
public void getScalingPolicy(com.netflix.titus.grpc.protogen.ScalingPolicyID request, io.grpc.stub.StreamObserver<com.netflix.titus.grpc.protogen.GetPolicyResult> responseObserver) {
// FIXME: make NOT_FOUND an explicit error condition
// appScaleManager.getScalingPolicy(id) will return an empty Observable when the id is not found, which makes
// the gRPC handler throw an exception (INTERNAL: Completed without a response). This error should be an
// explicit condition of the API, and mapped to Status.NOT_FOUND
appScaleManager.getScalingPolicy(request.getId()).subscribe(autoScalingPolicyInternal -> {
ScalingPolicyResult scalingPolicyResult = GrpcModelConverters.toScalingPolicyResult(autoScalingPolicyInternal);
responseObserver.onNext(GetPolicyResult.newBuilder().addItems(scalingPolicyResult).build());
}, e -> safeOnError(logger, e, responseObserver), responseObserver::onCompleted);
}
use of com.netflix.titus.grpc.protogen.ScalingPolicyResult in project titus-control-plane by Netflix.
the class DefaultAutoScalingServiceGrpc method completePolicyList.
private void completePolicyList(Observable<AutoScalingPolicy> policyObservable, io.grpc.stub.StreamObserver<com.netflix.titus.grpc.protogen.GetPolicyResult> responseObserver) {
List<ScalingPolicyResult> scalingPolicyResultList = new ArrayList<>();
policyObservable.subscribe(autoScalingPolicyInternal -> {
ScalingPolicyResult scalingPolicyResult = GrpcModelConverters.toScalingPolicyResult(autoScalingPolicyInternal);
scalingPolicyResultList.add(scalingPolicyResult);
}, e -> safeOnError(logger, e, responseObserver), () -> {
responseObserver.onNext(GetPolicyResult.newBuilder().addAllItems(scalingPolicyResultList).build());
responseObserver.onCompleted();
});
}
Aggregations