Skip to content

Commit 95ea0b1

Browse files
mnoah1behinddwalls
authored andcommitted
refactor(stovepipe): use singular record source control
1 parent e8a6c2a commit 95ea0b1

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

stovepipe/controller/record/record.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ import (
4444
// when that fact is green advances the queue's last-green bookmark and promotes
4545
// the commit. Implements consumer.Controller.
4646
type Controller struct {
47-
logger *zap.SugaredLogger
48-
metricsScope tally.Scope
49-
stores storage.Factory
50-
sourceControls sourcecontrol.Factory
51-
topicKey consumer.TopicKey
52-
consumerGroup string
47+
logger *zap.SugaredLogger
48+
metricsScope tally.Scope
49+
stores storage.Factory
50+
sourceControl sourcecontrol.Factory
51+
topicKey consumer.TopicKey
52+
consumerGroup string
5353
}
5454

5555
// Verify Controller implements consumer.Controller interface at compile time.
@@ -68,18 +68,18 @@ func NewController(
6868
logger *zap.SugaredLogger,
6969
scope tally.Scope,
7070
stores storage.Factory,
71-
sourceControls sourcecontrol.Factory,
71+
sourceControl sourcecontrol.Factory,
7272
topicKey consumer.TopicKey,
7373
consumerGroup string,
7474
) *Controller {
7575
name := string(topicKey) + "_controller"
7676
return &Controller{
77-
logger: logger.Named(name),
78-
metricsScope: scope.SubScope(name),
79-
stores: stores,
80-
sourceControls: sourceControls,
81-
topicKey: topicKey,
82-
consumerGroup: consumerGroup,
77+
logger: logger.Named(name),
78+
metricsScope: scope.SubScope(name),
79+
stores: stores,
80+
sourceControl: sourceControl,
81+
topicKey: topicKey,
82+
consumerGroup: consumerGroup,
8383
}
8484
}
8585

@@ -247,7 +247,7 @@ func (c *Controller) reportFailureDetectionLatency(ctx context.Context, request
247247
return
248248
}
249249

250-
sourceControl, err := c.sourceControls.For(sourcecontrol.Config{QueueName: request.Queue})
250+
sourceControl, err := c.sourceControl.For(sourcecontrol.Config{QueueName: request.Queue})
251251
if err != nil {
252252
c.failureDetectionUnobserved(request, "resolve_source_control", err)
253253
return
@@ -366,7 +366,7 @@ func (c *Controller) advanceLastGreen(ctx context.Context, store storage.Storage
366366
func (c *Controller) emitLastGreenTimestamp(ctx context.Context, request entity.Request) {
367367
queueTag := metrics.NewTag("queue", request.Queue)
368368

369-
sourceControl, err := c.sourceControls.For(sourcecontrol.Config{QueueName: request.Queue})
369+
sourceControl, err := c.sourceControl.For(sourcecontrol.Config{QueueName: request.Queue})
370370
if err != nil {
371371
metrics.NamedCounter(c.metricsScope, _opName, "last_green_timestamp_resolve_errors", 1, queueTag)
372372
c.logger.Warnw("failed to resolve source control to report the last green timestamp",
@@ -421,7 +421,7 @@ func (c *Controller) emitLastGreenTimestamp(ctx context.Context, request entity.
421421
// harmlessly. A commit that a rewritten history dropped from the ref cannot be
422422
// promoted by any retry, so that case is counted and skipped rather than failed.
423423
func (c *Controller) promote(ctx context.Context, request entity.Request) error {
424-
sc, err := c.sourceControls.For(sourcecontrol.Config{QueueName: request.Queue})
424+
sc, err := c.sourceControl.For(sourcecontrol.Config{QueueName: request.Queue})
425425
if err != nil {
426426
metrics.NamedCounter(c.metricsScope, _opName, "source_control_errors", 1,
427427
metrics.NewTag("stage", "resolve"),

stovepipe/controller/record/record_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func TestProcess_TimestampReportingFailureDoesNotFailRecord(t *testing.T) {
296296
func TestProcess_UnresolvableSourceControlCountsTimestampFailure(t *testing.T) {
297297
ctrl := gomock.NewController(t)
298298
c, m := newController(t, ctrl)
299-
c.sourceControls = failingSourceControlFactory{}
299+
c.sourceControl = failingSourceControlFactory{}
300300

301301
m.reqStore.EXPECT().Get(gomock.Any(), testID).
302302
Return(requestWithState(entity.RequestStateSucceeded), nil)
@@ -398,7 +398,7 @@ func TestProcess_UnobservableDetectionLatencyDoesNotFailRecord(t *testing.T) {
398398
name: "source control cannot be resolved",
399399
step: "resolve_source_control",
400400
setup: func(c *Controller, _ recordMocks) {
401-
c.sourceControls = failingSourceControlFactory{}
401+
c.sourceControl = failingSourceControlFactory{}
402402
},
403403
},
404404
{
@@ -579,7 +579,7 @@ func TestProcess_PromotionErrorsPropagate(t *testing.T) {
579579
{
580580
name: "source control resolve fails",
581581
setup: func(c *Controller, _ recordMocks) {
582-
c.sourceControls = failingSourceControlFactory{}
582+
c.sourceControl = failingSourceControlFactory{}
583583
},
584584
},
585585
{

0 commit comments

Comments
 (0)