common_meta/ddl/test_util/
flownode_handler.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use api::v1::flow::{FlowRequest, FlowResponse};
16use api::v1::region::InsertRequests;
17use common_telemetry::debug;
18
19use crate::error::Result;
20use crate::peer::Peer;
21use crate::test_util::MockFlownodeHandler;
22
23#[derive(Clone)]
24pub struct NaiveFlownodeHandler;
25
26#[async_trait::async_trait]
27impl MockFlownodeHandler for NaiveFlownodeHandler {
28    async fn handle(&self, peer: &Peer, request: FlowRequest) -> Result<FlowResponse> {
29        debug!("Returning Ok(0) for request: {request:?}, peer: {peer:?}");
30        Ok(FlowResponse {
31            affected_rows: 0,
32            ..Default::default()
33        })
34    }
35
36    async fn handle_inserts(
37        &self,
38        _peer: &Peer,
39        _requests: InsertRequests,
40    ) -> Result<FlowResponse> {
41        unreachable!()
42    }
43}