-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Windows Implementation for sync server and client
Adds the windows functionality for PipeListener, PipeConnection, and ClientConnection and does the few other changes required to build and run the example projects. This includes adding feature support to the examples so they wouldn't build the async projects (as the unix specific code hasn't been removed yet). Namedpipes are used as Containerd is one of the main use cases for this project on Windows and containerd only supports namedpipes. Signed-off-by: James Sturtevant <jstur@microsoft.com>
- Loading branch information
1 parent
914b5b5
commit e957414
Showing
23 changed files
with
521 additions
and
113 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
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
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 |
---|---|---|
@@ -1,18 +1,28 @@ | ||
#![allow(dead_code)] | ||
use std::fs; | ||
use std::io::Result; | ||
use std::path::Path; | ||
|
||
pub const SOCK_ADDR: &str = "unix:///tmp/ttrpc-test"; | ||
#[cfg(unix)] | ||
pub const SOCK_ADDR: &str = r"unix:///tmp/ttrpc-test"; | ||
|
||
#[cfg(windows)] | ||
pub const SOCK_ADDR: &str = r"\\.\pipe\ttrpc-test"; | ||
|
||
#[cfg(unix)] | ||
pub fn remove_if_sock_exist(sock_addr: &str) -> Result<()> { | ||
let path = sock_addr | ||
.strip_prefix("unix://") | ||
.expect("socket address is not expected"); | ||
|
||
if Path::new(path).exists() { | ||
fs::remove_file(&path)?; | ||
if std::path::Path::new(path).exists() { | ||
std::fs::remove_file(path)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[cfg(windows)] | ||
pub fn remove_if_sock_exist(_sock_addr: &str) -> Result<()> { | ||
//todo force close file handle? | ||
|
||
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
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 |
---|---|---|
|
@@ -49,6 +49,9 @@ pub mod error; | |
#[macro_use] | ||
mod common; | ||
|
||
#[macro_use] | ||
mod macros; | ||
|
||
pub mod context; | ||
|
||
pub mod proto; | ||
|
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,26 @@ | ||
// Copyright (c) 2020 Ant Financial | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
//! macro functions. | ||
macro_rules! cfg_sync { | ||
($($item:item)*) => { | ||
$( | ||
#[cfg(feature = "sync")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))] | ||
$item | ||
)* | ||
} | ||
} | ||
|
||
macro_rules! cfg_async { | ||
($($item:item)*) => { | ||
$( | ||
#[cfg(all(feature = "async", target_family="unix"))] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "async")))] | ||
$item | ||
)* | ||
} | ||
} |
Oops, something went wrong.