-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2024 Xu Shaohua <[email protected]>. All rights reserved. | ||
// Use of this source is governed by GNU Affero General Public License | ||
// that can be found in the LICENSE file. | ||
|
||
use stdext::function_name; | ||
|
||
use crate::commands::{ClusterToDispatcherCmd, DispatcherToListenerCmd}; | ||
use crate::dispatcher::Dispatcher; | ||
use crate::error::{Error, ErrorKind}; | ||
|
||
impl Dispatcher { | ||
pub(super) fn handle_cluster_cmd(&mut self, cmd: ClusterToDispatcherCmd) -> Result<(), Error> { | ||
// Send command to listener. | ||
log::debug!( | ||
"{}, proxy cmd from cluster to listener, cmd: {cmd:?}", | ||
function_name!() | ||
); | ||
let listener_id = cmd.session_group.listener_id(); | ||
if let Some(listener_sender) = self.listener_senders.get(&listener_id) { | ||
let cmd = DispatcherToListenerCmd::Reply(cmd.session_group, cmd.reply_frame); | ||
Ok(listener_sender.send(cmd)?) | ||
} else { | ||
Err(Error::from_string( | ||
ErrorKind::ChannelError, | ||
format!("Failed to find listener with id: {listener_id}"), | ||
)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) 2024 Xu Shaohua <[email protected]>. All rights reserved. | ||
// Use of this source is governed by GNU Affero General Public License | ||
// that can be found in the LICENSE file. | ||
|
||
pub mod save; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2024 Xu Shaohua <[email protected]>. All rights reserved. | ||
// Use of this source is governed by GNU Affero General Public License | ||
// that can be found in the LICENSE file. | ||
|
||
use crate::cmd::reply_frame::ReplyFrame; | ||
|
||
/// The `SAVE` commands performs a synchronous save of the dataset producing a point in time snapshot | ||
/// of all the data inside the server instance, in the form of an RDB file. | ||
/// | ||
/// You almost never want to call `SAVE` in production environments where it will | ||
/// block all the other clients. Instead, the `BGSAVE` is usually used. | ||
/// However, in case of issues preventing Redis to create the background saving child | ||
/// (for instance errors in the fork(2) system call), the `SAVE` command can be a good last resort | ||
/// to perform the dump of the latest dataset. | ||
/// | ||
/// Reply: | ||
/// - Simple string reply: OK. | ||
pub fn save() -> ReplyFrame { | ||
// TODO(Shaohua): Save to RDB file. | ||
log::info!("[storage] TODO: save to RDB file."); | ||
ReplyFrame::ok() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters