MCPcopy Create free account
hub / github.com/cloudwan/gohan / StateUpdateContext

Method StateUpdateContext

db/sql/sql.go:708–727  ·  view source on GitHub ↗

StateUpdate update resource state

(ctx context.Context, resource *schema.Resource, state *transaction.ResourceState)

Source from the content-addressed store, hash-verified

706
707//StateUpdate update resource state
708func (tx *Transaction) StateUpdateContext(ctx context.Context, resource *schema.Resource, state *transaction.ResourceState) error {
709 defer tx.measureTime(time.Now(), resource.Schema().ID, "state_update")
710
711 q, err := tx.updateQuery(resource)
712 if err != nil {
713 return err
714 }
715 if resource.Schema().StateVersioning() && state != nil {
716 q = q.Set(quote(stateVersionColumnName), state.StateVersion)
717 q = q.Set(quote(stateErrorColumnName), state.Error)
718 q = q.Set(quote(stateColumnName), state.State)
719 q = q.Set(quote(stateMonitoringColumnName), state.Monitoring)
720 }
721 q = q.Where(sq.Eq{"id": resource.ID()})
722 sql, args, err := q.ToSql()
723 if err != nil {
724 return err
725 }
726 return tx.exec(ctx, sql, args...)
727}
728
729func (tx *Transaction) Delete(s *schema.Schema, resourceID interface{}) error {
730 return tx.DeleteContext(context.Background(), s, resourceID)

Callers 1

StateUpdateMethod · 0.95

Calls 8

measureTimeMethod · 0.95
updateQueryMethod · 0.95
execMethod · 0.95
StateVersioningMethod · 0.80
quoteFunction · 0.70
SchemaMethod · 0.65
SetMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected