func (m *MemEngine) consumeStateUpdateMessage(u *user, now time.Time, msg gregor.StateUpdateMessage) (*item, error) { var err error var i *item if msg.Creation() != nil { if i, err = m.consumeCreation(u, now, msg.Creation()); err != nil { return nil, err } } if msg.Dismissal() != nil { md := msg.Metadata() if err = m.consumeDismissal(u, now, msg.Dismissal(), md.CTime()); err != nil { return nil, err } } return i, nil }
func (s *SQLEngine) consumeStateUpdateMessage(m gregor.StateUpdateMessage) (ctime time.Time, err error) { tx, err := s.driver.Begin() if err != nil { return time.Time{}, err } defer tx.Rollback() md := m.Metadata() if md, err = s.consumeInBandMessageMetadata(tx, md, gregor.InBandMsgTypeUpdate); err != nil { return time.Time{}, err } ctime = md.CTime() if m.Creation() != nil { if err = s.consumeCreation(tx, m.Creation()); err != nil { return ctime, err } } if m.Dismissal() != nil { if err = s.consumeMsgIDsToDismiss(tx, md.UID(), md.MsgID(), m.Dismissal().MsgIDsToDismiss(), md.CTime()); err != nil { return ctime, err } if err = s.consumeRangesToDismiss(tx, md.UID(), md.MsgID(), m.Dismissal().RangesToDismiss(), md.CTime()); err != nil { return ctime, err } } if err = tx.Commit(); err != nil { return time.Time{}, err } return ctime, nil }