(ctx context.Context)
| 569 | } |
| 570 | |
| 571 | func (c *counterInt64) tryGetRemoteState(ctx context.Context) (CounterInt64State, bool) { |
| 572 | remoteVal, err := c.registry.connector.Get(ctx, ConnectorMainIndex, c.key, "value", nil) |
| 573 | if err != nil { |
| 574 | if common.HasErrorCode(err, common.ErrCodeRecordNotFound) { |
| 575 | c.registry.logger.Debug().Err(err).Str("key", c.key).Msg("remote counter value not found, will initialize it") |
| 576 | } else { |
| 577 | c.registry.logger.Warn().Err(err).Str("key", c.key).Msg("failed to get remote counter value") |
| 578 | } |
| 579 | return CounterInt64State{}, false |
| 580 | } |
| 581 | var st CounterInt64State |
| 582 | if err := common.SonicCfg.Unmarshal(remoteVal, &st); err != nil { |
| 583 | // No backward compatibility: treat parse errors as missing |
| 584 | c.registry.logger.Debug().Err(err).Str("key", c.key).Msg("failed to parse remote counter state (treating as missing)") |
| 585 | return CounterInt64State{}, false |
| 586 | } |
| 587 | if st.UpdatedAt <= 0 { |
| 588 | return CounterInt64State{}, false |
| 589 | } |
| 590 | return st, true |
| 591 | } |
| 592 | |
| 593 | func (c *counterInt64) updateRemoteState(ctx context.Context, st CounterInt64State) { |
| 594 | if st.UpdatedBy == "" { |
no test coverage detected