Skip to content

Commit

Permalink
feat: add DatanodeManager trait
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Apr 26, 2024
1 parent 9a948ef commit 13eeadc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/common/meta/src/flownode_manager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2023 Greptime Team
//
// 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.

use std::sync::Arc;

use api::v1::flow::{FlowRequest, FlowResponse};

use crate::error::Result;
use crate::peer::Peer;

/// The trait fo handling requests to flownode
#[async_trait::async_trait]
pub trait Flownode: Send + Sync {
async fn handle(&self, request: FlowRequest) -> Result<FlowResponse>;
}

pub type FlownodeRef = Arc<dyn Flownode>;

/// Flownode manager
#[async_trait::async_trait]
pub trait FlownodeManager: Send + Sync {
/// Retrieves a target `flownode`.
async fn flownode(&self, datanode: &Peer) -> FlownodeRef;
}

pub type FlownodeManagerRef = Arc<dyn FlownodeManager>;
1 change: 1 addition & 0 deletions src/common/meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod ddl;
pub mod ddl_manager;
pub mod distributed_time_constants;
pub mod error;
pub mod flownode_manager;
pub mod heartbeat;
pub mod instruction;
pub mod key;
Expand Down

0 comments on commit 13eeadc

Please sign in to comment.