version up
This commit is contained in:
parent
7742baf450
commit
1d64849cdf
|
@ -19,7 +19,7 @@ prost = { version = "0" }
|
||||||
nats = { version = "0" }
|
nats = { version = "0" }
|
||||||
base64 = { version = "0" }
|
base64 = { version = "0" }
|
||||||
|
|
||||||
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.22-snapshot" }
|
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.67-snapshot" }
|
||||||
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.2-snapshot" }
|
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.51-snapshot" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
1
src/api/game/mod.rs
Normal file
1
src/api/game/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod service;
|
173
src/api/game/service.rs
Normal file
173
src/api/game/service.rs
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("beteran-frontend-server-edge::game::service::Service")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(connection_broker: nats::asynk::Connection, queue_broker: String) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(self.list_games(),).map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_client_in_header(
|
||||||
|
&self,
|
||||||
|
message: &nats::asynk::Message,
|
||||||
|
) -> Result<bpr::models::core::network::Client, bcr::error::rpc::Error> {
|
||||||
|
match &message.headers {
|
||||||
|
Some(headers) => {
|
||||||
|
let client = match headers.get(bpr::c2se::core::network::HEADER_CLIENT) {
|
||||||
|
Some(c) => {
|
||||||
|
let msg = base64::decode(c).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
bpr::models::core::network::Client::decode(msg.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
None => Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid header".to_string(),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_games(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::frontend::api::game::SUBJECT_LIST_GAMES,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req =
|
||||||
|
bpr::c2se::api::game::ListGamesRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_games_req = bpr::ss::api::game::ListGamesRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::api::game::list_games_request::Request {
|
||||||
|
pagination: req.pagination,
|
||||||
|
sorts: req.sorts,
|
||||||
|
search: match req.search {
|
||||||
|
Some(s) => Some(bpr::ss::api::game::list_games_request::request::Search {
|
||||||
|
vendor_id: s.vendor_id,
|
||||||
|
key_like: s.key_like,
|
||||||
|
category_like: s.category_like,
|
||||||
|
platform_like: s.platform_like,
|
||||||
|
game_type_like: s.game_type_like,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_list_games_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::api::game::SUBJECT_LIST_GAMES,
|
||||||
|
ss_list_games_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_games_res =
|
||||||
|
bpr::ss::api::game::ListGamesResponse::decode(ss_list_games_res_msg.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_list_games_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_list_games_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::api::game::ListGamesResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::api::game::list_games_response::Result { games: r.games }),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::api::game::ListGamesResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
2
src/api/mod.rs
Normal file
2
src/api/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod game;
|
||||||
|
pub mod vendor;
|
1
src/api/vendor/mod.rs
vendored
Normal file
1
src/api/vendor/mod.rs
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod service;
|
179
src/api/vendor/service.rs
vendored
Normal file
179
src/api/vendor/service.rs
vendored
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("beteran-frontend-server-edge::vendor::service::Service")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(connection_broker: nats::asynk::Connection, queue_broker: String) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(self.list_vendors(),).map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_client_in_header(
|
||||||
|
&self,
|
||||||
|
message: &nats::asynk::Message,
|
||||||
|
) -> Result<bpr::models::core::network::Client, bcr::error::rpc::Error> {
|
||||||
|
match &message.headers {
|
||||||
|
Some(headers) => {
|
||||||
|
let client = match headers.get(bpr::c2se::core::network::HEADER_CLIENT) {
|
||||||
|
Some(c) => {
|
||||||
|
let msg = base64::decode(c).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
bpr::models::core::network::Client::decode(msg.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
None => Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid header".to_string(),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_vendors(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::frontend::api::vendor::SUBJECT_LIST_VENDORS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::api::vendor::ListVendorsRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_vendors_req = bpr::ss::api::vendor::ListVendorsRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::api::vendor::list_vendors_request::Request {
|
||||||
|
pagination: req.pagination,
|
||||||
|
sorts: req.sorts,
|
||||||
|
search: match req.search {
|
||||||
|
Some(s) => Some(
|
||||||
|
bpr::ss::api::vendor::list_vendors_request::request::Search {
|
||||||
|
name_like: s.name_like,
|
||||||
|
company_id: s.company_id,
|
||||||
|
vendor_id: s.vendor_id,
|
||||||
|
key_like: s.key_like,
|
||||||
|
category_like: s.category_like,
|
||||||
|
is_enable: s.is_enable,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_list_vendors_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::api::vendor::SUBJECT_LIST_VENDORS,
|
||||||
|
ss_list_vendors_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_vendors_res = bpr::ss::api::vendor::ListVendorsResponse::decode(
|
||||||
|
ss_list_vendors_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_list_vendors_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_list_vendors_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::api::vendor::ListVendorsResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::api::vendor::list_vendors_response::Result {
|
||||||
|
vendors: r.vendors,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::api::vendor::ListVendorsResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
1
src/bank/mod.rs
Normal file
1
src/bank/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod service;
|
270
src/bank/service.rs
Normal file
270
src/bank/service.rs
Normal file
|
@ -0,0 +1,270 @@
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("beteran-frontend-server-edge::bank::service::Service")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(connection_broker: nats::asynk::Connection, queue_broker: String) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(self.list_banks(), self.get_bank(),).map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_client_in_header(
|
||||||
|
&self,
|
||||||
|
message: &nats::asynk::Message,
|
||||||
|
) -> Result<bpr::models::core::network::Client, bcr::error::rpc::Error> {
|
||||||
|
match &message.headers {
|
||||||
|
Some(headers) => {
|
||||||
|
let client = match headers.get(bpr::c2se::core::network::HEADER_CLIENT) {
|
||||||
|
Some(c) => {
|
||||||
|
let msg = base64::decode(c).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
bpr::models::core::network::Client::decode(msg.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
None => Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid header".to_string(),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_banks(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::frontend::bank::SUBJECT_LIST_BANKS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req =
|
||||||
|
bpr::c2se::bank::ListBanksRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_banks_req = bpr::ss::bank::ListBanksRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::bank::list_banks_request::Request {
|
||||||
|
pagination: req.pagination,
|
||||||
|
sorts: req.sorts,
|
||||||
|
search: match req.search {
|
||||||
|
Some(s) => Some(bpr::ss::bank::list_banks_request::request::Search {
|
||||||
|
name_like: s.name_like,
|
||||||
|
show: s.show,
|
||||||
|
can_use: s.can_use,
|
||||||
|
memo_like: s.memo_like,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_list_banks_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::bank::SUBJECT_LIST_BANKS,
|
||||||
|
ss_list_banks_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_banks_res = bpr::ss::bank::ListBanksResponse::decode(
|
||||||
|
ss_list_banks_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_list_banks_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_list_banks_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::bank::ListBanksResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::bank::list_banks_response::Result { banks: r.banks }),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::bank::ListBanksResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_bank(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::frontend::bank::SUBJECT_GET_BANK,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req =
|
||||||
|
bpr::c2se::bank::GetBankRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_bank_req = bpr::ss::bank::GetBankRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::bank::get_bank_request::Request { id: req.id }),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_bank_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::bank::SUBJECT_GET_BANK,
|
||||||
|
ss_get_bank_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_bank_res = bpr::ss::bank::GetBankResponse::decode(
|
||||||
|
ss_get_bank_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_get_bank_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_get_bank_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::bank::GetBankResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::bank::get_bank_response::Result { bank: r.bank }),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::bank::GetBankResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,8 @@ pub struct Service {
|
||||||
|
|
||||||
impl std::fmt::Debug for Service {
|
impl std::fmt::Debug for Service {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
f.debug_struct("beteran-frontend-server-edge::identity::service::Service").finish()
|
f.debug_struct("beteran-frontend-server-edge::identity::service::Service")
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,57 +81,66 @@ impl Service {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
let req = bpr::c2se::common::identity::CheckUsernameForDuplicationRequest::decode(
|
let req =
|
||||||
message.data.as_slice(),
|
bpr::c2se::identity::CheckUsernameForDuplicationRequest::decode(message.data.as_slice())
|
||||||
)
|
.map_err(|e| {
|
||||||
.map_err(|e| {
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
message: format!("invalid request: {}", e),
|
||||||
message: format!("invalid request: {}", e),
|
})
|
||||||
})
|
})?;
|
||||||
})?;
|
|
||||||
|
|
||||||
let ss_check_username_for_duplication_req =
|
let ss_check_username_for_duplication_req =
|
||||||
bpr::ss::member::identity::CheckUsernameForDuplicationRequest {
|
bpr::ss::identity::CheckUsernameForDuplicationRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
username: req.username,
|
request: Some(
|
||||||
|
bpr::ss::identity::check_username_for_duplication_request::Request {
|
||||||
|
username: req.username,
|
||||||
|
},
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_check_username_for_duplication_res_msg = self
|
let ss_check_username_for_duplication_res_msg = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
.request(
|
.request(
|
||||||
bpr::ss::member::identity::SUBJECT_CHECK_USERNAME_FOR_DUPLICATION,
|
bpr::ss::identity::SUBJECT_CHECK_USERNAME_FOR_DUPLICATION,
|
||||||
ss_check_username_for_duplication_req.encode_to_vec(),
|
ss_check_username_for_duplication_req.encode_to_vec(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_check_username_for_duplication_res =
|
let ss_check_username_for_duplication_res =
|
||||||
bpr::ss::member::identity::CheckUsernameForDuplicationResponse::decode(
|
bpr::ss::identity::CheckUsernameForDuplicationResponse::decode(
|
||||||
ss_check_username_for_duplication_res_msg.data.as_slice(),
|
ss_check_username_for_duplication_res_msg.data.as_slice(),
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(e) = ss_check_username_for_duplication_res.error {
|
if let Some(e) = ss_check_username_for_duplication_res.error {
|
||||||
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(r) = ss_check_username_for_duplication_res.result {
|
if let Some(r) = ss_check_username_for_duplication_res.result {
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CheckUsernameForDuplicationResponse {
|
bpr::c2se::identity::CheckUsernameForDuplicationResponse {
|
||||||
error: None,
|
error: None,
|
||||||
result: Some(
|
result: Some(
|
||||||
bpr::c2se::common::identity::check_username_for_duplication_response::Result {
|
bpr::c2se::identity::check_username_for_duplication_response::Result {
|
||||||
duplicated: r.duplicated,
|
duplicated: r.duplicated,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -140,7 +150,9 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +163,7 @@ impl Service {
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CheckUsernameForDuplicationResponse {
|
bpr::c2se::identity::CheckUsernameForDuplicationResponse {
|
||||||
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
result: None,
|
result: None,
|
||||||
}
|
}
|
||||||
|
@ -177,57 +189,66 @@ impl Service {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
let req = bpr::c2se::common::identity::CheckNicknameForDuplicationRequest::decode(
|
let req =
|
||||||
message.data.as_slice(),
|
bpr::c2se::identity::CheckNicknameForDuplicationRequest::decode(message.data.as_slice())
|
||||||
)
|
.map_err(|e| {
|
||||||
.map_err(|e| {
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
message: format!("invalid request: {}", e),
|
||||||
message: format!("invalid request: {}", e),
|
})
|
||||||
})
|
})?;
|
||||||
})?;
|
|
||||||
|
|
||||||
let ss_check_nickname_for_duplication_req =
|
let ss_check_nickname_for_duplication_req =
|
||||||
bpr::ss::member::identity::CheckNicknameForDuplicationRequest {
|
bpr::ss::identity::CheckNicknameForDuplicationRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
nickname: req.nickname,
|
request: Some(
|
||||||
|
bpr::ss::identity::check_nickname_for_duplication_request::Request {
|
||||||
|
nickname: req.nickname,
|
||||||
|
},
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_check_nickname_for_duplication_res_msg = self
|
let ss_check_nickname_for_duplication_res_msg = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
.request(
|
.request(
|
||||||
bpr::ss::member::identity::SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
bpr::ss::identity::SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
||||||
ss_check_nickname_for_duplication_req.encode_to_vec(),
|
ss_check_nickname_for_duplication_req.encode_to_vec(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_check_nickname_for_duplication_res =
|
let ss_check_nickname_for_duplication_res =
|
||||||
bpr::ss::member::identity::CheckNicknameForDuplicationResponse::decode(
|
bpr::ss::identity::CheckNicknameForDuplicationResponse::decode(
|
||||||
ss_check_nickname_for_duplication_res_msg.data.as_slice(),
|
ss_check_nickname_for_duplication_res_msg.data.as_slice(),
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(e) = ss_check_nickname_for_duplication_res.error {
|
if let Some(e) = ss_check_nickname_for_duplication_res.error {
|
||||||
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(r) = ss_check_nickname_for_duplication_res.result {
|
if let Some(r) = ss_check_nickname_for_duplication_res.result {
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CheckNicknameForDuplicationResponse {
|
bpr::c2se::identity::CheckNicknameForDuplicationResponse {
|
||||||
error: None,
|
error: None,
|
||||||
result: Some(
|
result: Some(
|
||||||
bpr::c2se::common::identity::check_nickname_for_duplication_response::Result {
|
bpr::c2se::identity::check_nickname_for_duplication_response::Result {
|
||||||
duplicated: r.duplicated,
|
duplicated: r.duplicated,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -237,7 +258,9 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +271,7 @@ impl Service {
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CheckNicknameForDuplicationResponse {
|
bpr::c2se::identity::CheckNicknameForDuplicationResponse {
|
||||||
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
result: None,
|
result: None,
|
||||||
}
|
}
|
||||||
|
@ -274,51 +297,59 @@ impl Service {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
let _req = bpr::c2se::common::identity::CaptchaRequest::decode(message.data.as_slice())
|
let _req =
|
||||||
.map_err(|e| {
|
bpr::c2se::identity::CaptchaRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
message: format!("invalid request: {}", e),
|
message: format!("invalid request: {}", e),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_captcha_req = bpr::ss::member::identity::CaptchaRequest {
|
let ss_captcha_req = bpr::ss::identity::CaptchaRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::identity::captcha_request::Request {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_captcha_res_msg = self
|
let ss_captcha_res_msg = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
.request(
|
.request(
|
||||||
bpr::ss::member::identity::SUBJECT_CAPTCHA,
|
bpr::ss::identity::SUBJECT_CAPTCHA,
|
||||||
ss_captcha_req.encode_to_vec(),
|
ss_captcha_req.encode_to_vec(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_captcha_res =
|
let ss_captcha_res = bpr::ss::identity::CaptchaResponse::decode(
|
||||||
bpr::ss::member::identity::CaptchaResponse::decode(ss_captcha_res_msg.data.as_slice())
|
ss_captcha_res_msg.data.as_slice(),
|
||||||
.map_err(|e| {
|
)
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
.map_err(|e| {
|
||||||
message: format!("server: {}", e),
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
})
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
})?;
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
if let Some(e) = ss_captcha_res.error {
|
if let Some(e) = ss_captcha_res.error {
|
||||||
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(r) = ss_captcha_res.result {
|
if let Some(r) = ss_captcha_res.result {
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CaptchaResponse {
|
bpr::c2se::identity::CaptchaResponse {
|
||||||
error: None,
|
error: None,
|
||||||
result: Some(bpr::c2se::common::identity::captcha_response::Result {
|
result: Some(bpr::c2se::identity::captcha_response::Result {
|
||||||
token: r.token,
|
security_code_hash: r.security_code_hash,
|
||||||
image: r.image,
|
image: r.image,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -327,7 +358,9 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +371,7 @@ impl Service {
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::common::identity::CaptchaResponse {
|
bpr::c2se::identity::CaptchaResponse {
|
||||||
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
result: None,
|
result: None,
|
||||||
}
|
}
|
||||||
|
@ -364,55 +397,64 @@ impl Service {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
let req = bpr::c2se::frontend::identity::SigninRequest::decode(message.data.as_slice())
|
let req =
|
||||||
.map_err(|e| {
|
bpr::c2se::identity::SigninRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
message: format!("invalid request: {}", e),
|
message: format!("invalid request: {}", e),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_signin_req = bpr::ss::member::identity::SigninRequest {
|
let ss_signin_req = bpr::ss::identity::SigninRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
token: req.token,
|
request: Some(bpr::ss::identity::signin_request::Request {
|
||||||
security_code: req.security_code,
|
security_code_hash: req.security_code_hash,
|
||||||
username: req.username,
|
security_code: req.security_code,
|
||||||
password: req.password,
|
username: req.username,
|
||||||
|
password: req.password,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_signin_res_msg = self
|
let ss_signin_res_msg = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
.request(
|
.request(
|
||||||
bpr::ss::member::identity::SUBJECT_SIGNIN,
|
bpr::ss::identity::SUBJECT_SIGNIN,
|
||||||
ss_signin_req.encode_to_vec(),
|
ss_signin_req.encode_to_vec(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let ss_signin_res =
|
let ss_signin_res = bpr::ss::identity::SigninResponse::decode(
|
||||||
bpr::ss::member::identity::SigninResponse::decode(ss_signin_res_msg.data.as_slice())
|
ss_signin_res_msg.data.as_slice(),
|
||||||
.map_err(|e| {
|
)
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
.map_err(|e| {
|
||||||
message: format!("server: {}", e),
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
})
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
})?;
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
if let Some(e) = ss_signin_res.error {
|
if let Some(e) = ss_signin_res.error {
|
||||||
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(r) = ss_signin_res.result {
|
if let Some(r) = ss_signin_res.result {
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::frontend::identity::SigninResponse {
|
bpr::c2se::identity::SigninResponse {
|
||||||
error: None,
|
error: None,
|
||||||
result: Some(bpr::c2se::frontend::identity::signin_response::Result {
|
result: Some(bpr::c2se::identity::signin_response::Result {
|
||||||
session_id: r.session_id,
|
access_token: r.access_token,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
.encode_to_vec(),
|
.encode_to_vec(),
|
||||||
|
@ -420,7 +462,9 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
message: format!("server: {}", e),
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +475,7 @@ impl Service {
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.respond(
|
.respond(
|
||||||
bpr::c2se::frontend::identity::SigninResponse {
|
bpr::c2se::identity::SigninResponse {
|
||||||
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
result: None,
|
result: None,
|
||||||
}
|
}
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -1,5 +1,7 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
mod api;
|
||||||
|
mod bank;
|
||||||
mod identity;
|
mod identity;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -16,11 +18,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let broker_opts = nats::asynk::Options::new();
|
let broker_opts = nats::asynk::Options::new();
|
||||||
let connection_broker = broker_opts.connect(url_broker).await?;
|
let connection_broker = broker_opts.connect(url_broker).await?;
|
||||||
|
|
||||||
let identity_service = identity::service::Service::new(connection_broker, queue_broker);
|
let bank_service = bank::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
let identity_service =
|
||||||
|
identity::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
|
||||||
|
let api_vendor_service =
|
||||||
|
api::vendor::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
let api_game_service =
|
||||||
|
api::game::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
|
||||||
println!("Server edge[beteran-frontend-server-edge] is started");
|
println!("Server edge[beteran-frontend-server-edge] is started");
|
||||||
|
|
||||||
futures::try_join!(identity_service.subscribe())?;
|
futures::try_join!(
|
||||||
|
bank_service.subscribe(),
|
||||||
|
identity_service.subscribe(),
|
||||||
|
api_vendor_service.subscribe(),
|
||||||
|
api_game_service.subscribe(),
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user