Skip to content

Commit 1e19e21

Browse files
chore: consistent error checking, and rename function
Signed-off-by: Theis Randeris Mathiassen <[email protected]>
1 parent 18704de commit 1e19e21

File tree

1 file changed

+7
-5
lines changed
  • service/sharddistributor/store/etcd/executorstore

1 file changed

+7
-5
lines changed

service/sharddistributor/store/etcd/executorstore/etcdstore.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ func (s *executorStoreImpl) RecordHeartbeat(ctx context.Context, namespace, exec
164164
return fmt.Errorf("record heartbeat: %w", err)
165165
}
166166

167-
s.updateShardStatisticsFromHeartbeat(ctx, namespace, executorID, request.ReportedShards)
167+
s.recordShardStatistics(ctx, namespace, executorID, request.ReportedShards)
168168

169169
return nil
170170
}
171171

172-
func (s *executorStoreImpl) updateShardStatisticsFromHeartbeat(ctx context.Context, namespace, executorID string, reported map[string]*types.ShardStatusReport) {
172+
func (s *executorStoreImpl) recordShardStatistics(ctx context.Context, namespace, executorID string, reported map[string]*types.ShardStatusReport) {
173173
if len(reported) == 0 {
174174
return
175175
}
@@ -223,7 +223,8 @@ func (s *executorStoreImpl) updateShardStatisticsFromHeartbeat(ctx context.Conte
223223

224224
var stats store.ShardStatistics
225225
if len(statsResp.Kvs) > 0 {
226-
if err := json.Unmarshal(statsResp.Kvs[0].Value, &stats); err != nil {
226+
err := json.Unmarshal(statsResp.Kvs[0].Value, &stats)
227+
if err != nil {
227228
s.logger.Warn(
228229
"failed to unmarshal shard statistics for heartbeat update",
229230
tag.ShardNamespace(namespace),
@@ -251,7 +252,8 @@ func (s *executorStoreImpl) updateShardStatisticsFromHeartbeat(ctx context.Conte
251252
continue
252253
}
253254

254-
if _, err := s.client.Put(ctx, shardStatsKey, string(payload)); err != nil {
255+
_, err = s.client.Put(ctx, shardStatsKey, string(payload))
256+
if err != nil {
255257
s.logger.Warn(
256258
"failed to persist shard statistics from heartbeat",
257259
tag.ShardNamespace(namespace),
@@ -826,7 +828,7 @@ func (s *executorStoreImpl) applyShardStatisticsUpdates(ctx context.Context, nam
826828
}
827829

828830
func ewmaSmoothedLoad(prev, current float64, lastUpdate, now int64) float64 {
829-
const tauSeconds = 30.0 // smaller = more responsive, larger = smoother, slower
831+
const tauSeconds = 30.0 // smaller = more responsive, larger = smoother
830832
if lastUpdate <= 0 || tauSeconds <= 0 {
831833
return current
832834
}

0 commit comments

Comments
 (0)