Skip to content

Commit

Permalink
feat: add interruptWith with KafkaExecutionFailure
Browse files Browse the repository at this point in the history
Uses the same structure as for context. but the refactoring with the "HTTP part" will have to be done later
  • Loading branch information
ThibaudAV committed Dec 9, 2024
1 parent 290c887 commit 64aff42
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.gravitee.gateway.reactive.api.context.kafka;

import io.gravitee.gateway.reactive.api.context.base.NativeExecutionContext;
import io.gravitee.gateway.reactive.api.exception.kafka.KafkaExecutionFailure;
import io.reactivex.rxjava3.core.Completable;
import java.util.function.Function;
import org.apache.kafka.common.protocol.ApiKeys;
Expand Down Expand Up @@ -53,4 +54,10 @@ public interface KafkaExecutionContext extends NativeExecutionContext {
* @param onResponseCallback the action to be executed at the response phase.
*/
void addActionOnResponse(Function<KafkaExecutionContext, Completable> onResponseCallback);

/**
* Interrupts the current execution while indicating that the response can be sent "as is" to the downstream.
* @param failure {@link KafkaExecutionFailure} object that indicates that the execution has failed.
*/
Completable interruptWith(final KafkaExecutionFailure failure);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.gateway.reactive.api.exception.base;

public interface BaseExecutionFailure {
String message();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.gateway.reactive.api.exception.base;

public interface NativeExecutionFailure extends BaseExecutionFailure {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.gateway.reactive.api.exception.kafka;

import io.gravitee.gateway.reactive.api.exception.base.NativeExecutionFailure;
import org.apache.kafka.common.protocol.Errors;

public interface KafkaExecutionFailure extends NativeExecutionFailure {
Errors errors();
}

0 comments on commit 64aff42

Please sign in to comment.