-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement safe rust wrapper for fabric client. Safely wrapped resolve_service_partition and get_node_list. The API design is modeled after Csharp FabricClient. Added unit tests for calling these apis with SF onebox and echo app running locally (and in ci). #15
- Loading branch information
Showing
17 changed files
with
823 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
pub mod app; | ||
pub mod health; | ||
pub mod mgmt; | ||
pub mod property; | ||
pub mod query; | ||
pub mod svc; | ||
pub mod svcgp; |
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,10 +1,84 @@ | ||
pub mod app; | ||
pub mod health; | ||
pub mod mgmt; | ||
pub mod property; | ||
pub mod query; | ||
pub mod svc; | ||
pub mod svcgp; | ||
use mssf_com::FabricCommon::FabricClient::{ | ||
IFabricPropertyManagementClient2, IFabricQueryClient10, IFabricServiceManagementClient6, | ||
}; | ||
use windows_core::Interface; | ||
|
||
use self::{ | ||
gen::{property::IFabricPropertyManagementClient2Wrap, query::IFabricQueryClient10Wrap}, | ||
query_client::QueryClient, | ||
svc_mgmt_client::ServiceManagementClient, | ||
}; | ||
|
||
// TODO: make private. Currently exposed for backward compat | ||
pub mod gen; | ||
|
||
pub mod query_client; | ||
pub mod svc_mgmt_client; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
// FabricClient safe wrapper | ||
// The design of FabricClient follows from the csharp client: | ||
// https://github.com/microsoft/service-fabric/blob/master/src/prod/src/managed/Api/src/System/Fabric/FabricClient.cs | ||
|
||
pub struct FabricClient { | ||
com_property_client: IFabricPropertyManagementClient2, | ||
com_service_client: IFabricServiceManagementClient6, | ||
com_query_client: IFabricQueryClient10, | ||
} | ||
|
||
impl Default for FabricClient { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl FabricClient { | ||
pub fn new() -> Self { | ||
let com = crate::sync::CreateLocalClient::<IFabricPropertyManagementClient2>(); | ||
Self::from_com(com) | ||
} | ||
|
||
// Creates from com directly. This gives the user freedom to create com from | ||
// custom code and pass it in. | ||
// For the final state of FabricClient, this function should be private. | ||
pub fn from_com(com: IFabricPropertyManagementClient2) -> Self { | ||
let com_property_client = com.clone(); | ||
let com_service_client = com | ||
.clone() | ||
.cast::<IFabricServiceManagementClient6>() | ||
.unwrap(); | ||
let com_query_client = com.clone().cast::<IFabricQueryClient10>().unwrap(); | ||
Self { | ||
com_property_client, | ||
com_service_client, | ||
com_query_client, | ||
} | ||
} | ||
|
||
// Get the client for managing Fabric Properties in Naming Service | ||
pub fn get_property_manager(&self) -> PropertyManagementClient { | ||
PropertyManagementClient { | ||
_com: self.com_property_client.clone(), | ||
_gen_wrap: IFabricPropertyManagementClient2Wrap::from_com( | ||
self.com_property_client.clone(), | ||
), | ||
} | ||
} | ||
|
||
// Get the client for quering SF info. | ||
pub fn get_query_manager(&self) -> QueryClient { | ||
QueryClient::from_com(self.com_query_client.clone()) | ||
} | ||
|
||
// Get the client for managing service info and lifecycles. | ||
pub fn get_service_manager(&self) -> ServiceManagementClient { | ||
ServiceManagementClient::from_com(self.com_service_client.clone()) | ||
} | ||
} | ||
|
||
pub struct PropertyManagementClient { | ||
_com: IFabricPropertyManagementClient2, | ||
_gen_wrap: IFabricPropertyManagementClient2Wrap, | ||
} |
Oops, something went wrong.