private void process(IQueable msg) { try { if (msg is ErlException) { this.Mailbox.DeliverError(this, (ErlException)msg); return; } var erlMsg = msg as ErlMsg; if (erlMsg == null) throw new ErlException("Invalid message type: " + msg.GetType()); var map = ((ErlDataStore)Store).Map; var binding = new ErlVarBind(); //{Schema, ChangeType :: $d | $w, [{schema, Flds...}]} if (erlMsg.Msg==null || !erlMsg.Msg.Match(SUBSCRIPTION_MSG_PATTERN, binding)) return; var schemaName = ((ErlAtom)binding[SCHEMA]).Value; var op = ((ErlByte)binding[TYPE]).Value; var rows = ((ErlList)binding[ROWS]).Value; var schema = map.GetCRUDSchemaForName(schemaName); foreach(var rowTuple in rows.Cast<ErlTuple>()) { var row = map.ErlTupleToRow(schemaName, rowTuple, schema); var ctp = op == 'd' ? RowChangeType.Delete : RowChangeType.Upsert; var data = new RowChange(ctp, row, null); this.Mailbox.Deliver(this, data); } } catch(Exception err) { App.Log.Write( new Log.Message { Type = Log.MessageType.Error, Topic = CoreConsts.ERLANG_TOPIC, From = "{0}.process()".Args(GetType().Name), Text = err.ToMessageWithType(), Exception = err } ); } }
private void process(IQueable msg) { try { if (msg is ErlException) { this.Mailbox.DeliverError(this, (ErlException)msg); return; } var erlMsg = msg as ErlMsg; if (erlMsg == null) { throw new ErlException("Invalid message type: " + msg.GetType()); } var map = ((ErlDataStore)Store).Map; var binding = new ErlVarBind(); //{Schema, TS, ChangeType :: $d | $w, [{schema, Flds...}]} %% delete, write(upsert) //{Schema, TS, ChangeType :: $D | $C | $c, []} %% Drop, Create, Clear if (erlMsg.Msg == null || !erlMsg.Msg.Match(SUBSCRIPTION_MSG_PATTERN, binding)) { return; } var schemaName = ((ErlAtom)binding[SCHEMA]).Value; var ts = binding[TIMESTAMP].ValueAsLong; var op = (char)((ErlByte)binding[TYPE]).Value; var rows = ((ErlList)binding[ROWS]).Value; var schema = map.GetCRUDSchemaForName(schemaName); m_LastTimeStamp = new DataTimeStamp(ts); CRUDSubscriptionEvent.EventType etp; switch (op) { case 'd': etp = CRUDSubscriptionEvent.EventType.RowDelete; break; case 'c': etp = CRUDSubscriptionEvent.EventType.TableClear; break; case 'D': etp = CRUDSubscriptionEvent.EventType.TableDrop; break; case 'C': etp = CRUDSubscriptionEvent.EventType.TableCreate; break; default: etp = CRUDSubscriptionEvent.EventType.RowUpsert; break; } if (rows.Count > 0) { int errors = 0; foreach (var rowTuple in rows.Cast <ErlTuple>()) { try { var row = map.ErlTupleToRow(schemaName, rowTuple, schema); var data = new CRUDSubscriptionEvent(etp, schema, row, m_LastTimeStamp); this.Mailbox.Deliver(this, data); } catch (Exception ie) { errors++; log(ie); } } // TODO: Add error reporting to user } else { //used to clear data, no rows are fetched var data = new CRUDSubscriptionEvent(etp, schema, null, m_LastTimeStamp); this.Mailbox.Deliver(this, data); } } catch (Exception err) { log(err); } }
private void process(IQueable msg) { try { if (msg is ErlException) { this.Mailbox.DeliverError(this, (ErlException)msg); return; } var erlMsg = msg as ErlMsg; if (erlMsg == null) throw new ErlException("Invalid message type: " + msg.GetType()); var map = ((ErlDataStore)Store).Map; var binding = new ErlVarBind(); //{Schema, ChangeType :: $d | $w, [{schema, Flds...}]} %% delete, write(upsert) //{Schema, ChangeType :: $D | $C | $c, []} %% Drop, Create, Clear if (erlMsg.Msg==null || !erlMsg.Msg.Match(SUBSCRIPTION_MSG_PATTERN, binding)) return; var schemaName = ((ErlAtom)binding[SCHEMA]).Value; var op = (char)((ErlByte)binding[TYPE]).Value; var rows = ((ErlList)binding[ROWS]).Value; var schema = map.GetCRUDSchemaForName(schemaName); CRUDSubscriptionEvent.EventType etp; switch(op) { case 'd': etp = CRUDSubscriptionEvent.EventType.RowDelete; break; case 'c': etp = CRUDSubscriptionEvent.EventType.TableClear; break; case 'D': etp = CRUDSubscriptionEvent.EventType.TableDrop; break; case 'C': etp = CRUDSubscriptionEvent.EventType.TableCreate; break; default: etp = CRUDSubscriptionEvent.EventType.RowUpsert; break; } if (rows.Count>0) { foreach(var rowTuple in rows.Cast<ErlTuple>()) { var row = map.ErlTupleToRow(schemaName, rowTuple, schema); var data = new CRUDSubscriptionEvent(etp, schema, row); this.Mailbox.Deliver(this, data); } } else { var data = new CRUDSubscriptionEvent(etp, schema, null); this.Mailbox.Deliver(this, data); } } catch(Exception err) { App.Log.Write( new Log.Message { Type = Log.MessageType.Error, Topic = CoreConsts.ERLANG_TOPIC, From = "{0}.process()".Args(GetType().Name), Text = err.ToMessageWithType(), Exception = err } ); } }
private void process(IQueable msg) { try { if (msg is ErlException) { this.Mailbox.DeliverError(this, (ErlException)msg); return; } var erlMsg = msg as ErlMsg; if (erlMsg == null) throw new ErlException("Invalid message type: " + msg.GetType()); var map = ((ErlDataStore)Store).Map; var binding = new ErlVarBind(); //{Schema, TS, ChangeType :: $d | $w, [{schema, Flds...}]} %% delete, write(upsert) //{Schema, TS, ChangeType :: $D | $C | $c, []} %% Drop, Create, Clear if (erlMsg.Msg==null || !erlMsg.Msg.Match(SUBSCRIPTION_MSG_PATTERN, binding)) return; var schemaName = ((ErlAtom)binding[SCHEMA]).Value; var ts = binding[TIMESTAMP].ValueAsLong; var op = (char)((ErlByte)binding[TYPE]).Value; var rows = ((ErlList)binding[ROWS]).Value; var schema = map.GetCRUDSchemaForName(schemaName); m_LastTimeStamp = new DataTimeStamp(ts); CRUDSubscriptionEvent.EventType etp; switch(op) { case 'd': etp = CRUDSubscriptionEvent.EventType.RowDelete; break; case 'c': etp = CRUDSubscriptionEvent.EventType.TableClear; break; case 'D': etp = CRUDSubscriptionEvent.EventType.TableDrop; break; case 'C': etp = CRUDSubscriptionEvent.EventType.TableCreate; break; default: etp = CRUDSubscriptionEvent.EventType.RowUpsert; break; } if (rows.Count>0) { int errors = 0; foreach(var rowTuple in rows.Cast<ErlTuple>()) { try { var row = map.ErlTupleToRow(schemaName, rowTuple, schema); var data = new CRUDSubscriptionEvent(etp, schema, row, new DataTimeStamp(ts)); this.Mailbox.Deliver(this, data); } catch(Exception ie) { errors++; log(MessageType.Error, "prcs().forea(rTpl)", ie.ToMessageWithType(), ie); } } // TODO: Add error reporting to user } else { //used to clear data, no rows are fetched var data = new CRUDSubscriptionEvent(etp, schema, null, new DataTimeStamp(ts)); this.Mailbox.Deliver(this, data); } } catch(Exception err) { log(MessageType.Error, "prcs().outcatch{}", err.ToMessageWithType(), err); } }
private void process(IQueable msg) { try { if (msg is ErlException) { this.Mailbox.DeliverError(this, (ErlException)msg); return; } var erlMsg = msg as ErlMsg; if (erlMsg == null) { throw new ErlException("Invalid message type: " + msg.GetType()); } var map = ((ErlDataStore)Store).Map; var binding = new ErlVarBind(); //{Schema, TS, ChangeType :: $d | $w, [{schema, Flds...}]} %% delete, write(upsert) //{Schema, TS, ChangeType :: $D | $C | $c, []} %% Drop, Create, Clear if (erlMsg.Msg == null || !erlMsg.Msg.Match(SUBSCRIPTION_MSG_PATTERN, binding)) { return; } var schemaName = ((ErlAtom)binding[SCHEMA]).Value; var ts = binding[TIMESTAMP].ValueAsLong; var op = (char)((ErlByte)binding[TYPE]).Value; var rows = ((ErlList)binding[ROWS]).Value; var schema = map.GetCRUDSchemaForName(schemaName); m_LastTimeStamp = new DataTimeStamp(ts); CRUDSubscriptionEvent.EventType etp; switch (op) { case 'd': etp = CRUDSubscriptionEvent.EventType.RowDelete; break; case 'c': etp = CRUDSubscriptionEvent.EventType.TableClear; break; case 'D': etp = CRUDSubscriptionEvent.EventType.TableDrop; break; case 'C': etp = CRUDSubscriptionEvent.EventType.TableCreate; break; default: etp = CRUDSubscriptionEvent.EventType.RowUpsert; break; } if (rows.Count > 0) { foreach (var rowTuple in rows.Cast <ErlTuple>()) { var row = map.ErlTupleToRow(schemaName, rowTuple, schema); var data = new CRUDSubscriptionEvent(etp, schema, row, new DataTimeStamp(ts)); this.Mailbox.Deliver(this, data); } } else { //used to clear data, no rows are fetched var data = new CRUDSubscriptionEvent(etp, schema, null, new DataTimeStamp(ts)); this.Mailbox.Deliver(this, data); } } catch (Exception err) { App.Log.Write( new Log.Message { Type = Log.MessageType.Error, Topic = CoreConsts.ERLANG_TOPIC, From = "{0}.process()".Args(GetType().Name), Text = err.ToMessageWithType(), Exception = err } ); } }