Code Room
Code reviewHardcr-g091
Subject Circuit breakerLevel Senior–Staff~35 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go circuit breaker.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewgo
type Breaker struct {	failures int	open     bool	openedAt time.Time} func (b *Breaker) Call(fn func() error) error {	if b.open && time.Since(b.openedAt) < 30*time.Second {		return ErrOpen	}	err := fn()	if err != nil {		b.failures++		if b.failures >= 5 {			b.open = true			b.openedAt = time.Now()		}		return err	}	b.failures = 0	return nil}
Run or narrate your approach, then ask the coach.