additional message types

This commit is contained in:
ntr 2019-07-17 17:35:31 +10:00
parent b03afb41b2
commit 328bdf533a

View File

@ -48,11 +48,18 @@ pub enum Message {
fn handle_notification(n: Notification, db: &Db, pss: &Sender<Message>) -> Result<(), Error> { fn handle_notification(n: Notification, db: &Db, pss: &Sender<Message>) -> Result<(), Error> {
info!("pubsub received notification notification={:?}", n); info!("pubsub received notification notification={:?}", n);
// maybe we need it
let mut tx = db.transaction()?;
let msg = match n.table { let msg = match n.table {
Table::Accounts => Message::Account(account::select(db, n.id)?), Table::Accounts => Message::Account(account::select(db, n.id)?),
_ => unimplemented!(), Table::Instances => Message::Instance(instance::instance_get(&mut tx, n.id)?),
Table::Games => Message::Game(game::game_get(&mut tx, n.id)?),
_ => return Err(format_err!("unimplemented notification {:?}", n)),
}; };
tx.commit()?;
match pss.try_send(msg.clone()) { match pss.try_send(msg.clone()) {
Ok(()) => info!("pubsub message sent message={:?}", msg), Ok(()) => info!("pubsub message sent message={:?}", msg),
Err(e) => warn!("pubsub delivery failure err={:?}", e), Err(e) => warn!("pubsub delivery failure err={:?}", e),