MCPcopy Create free account
hub / github.com/erpc/erpc / updateRemoteState

Method updateRemoteState

data/shared_state_variable.go:593–623  ·  view source on GitHub ↗
(ctx context.Context, st CounterInt64State)

Source from the content-addressed store, hash-verified

591}
592
593func (c *counterInt64) updateRemoteState(ctx context.Context, st CounterInt64State) {
594 if st.UpdatedBy == "" {
595 st.UpdatedBy = c.registry.instanceId
596 }
597 payload, err := common.SonicCfg.Marshal(st)
598 if err != nil {
599 c.registry.logger.Debug().Err(err).
600 Str("key", c.key).
601 Int64("value", st.Value).
602 Msg("failed to marshal counter state for remote update")
603 return
604 }
605
606 err = c.registry.connector.Set(ctx, c.key, "value", payload, nil)
607 if err == nil {
608 err = c.registry.connector.PublishCounterInt64(ctx, c.key, st)
609 }
610 if err != nil {
611 c.registry.logger.Debug().Err(err).
612 Str("key", c.key).
613 Int64("value", st.Value).
614 Msg("failed to update remote counter value")
615 } else {
616 c.registry.logger.Debug().
617 Str("key", c.key).
618 Int64("value", st.Value).
619 Int64("updatedAt", st.UpdatedAt).
620 Str("updatedBy", st.UpdatedBy).
621 Msg("published counter value to remote")
622 }
623}
624
625// scheduleBackgroundPushCurrent dedupes and pushes the current local value to the
626// remote store under a lock, without blocking the caller.

Callers 1

Calls 2

SetMethod · 0.65
PublishCounterInt64Method · 0.65

Tested by

no test coverage detected