Skip to content

Commit

Permalink
fix(docs): update method docs after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
costela committed Oct 24, 2023
1 parent 7be9ede commit c232a85
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type untypedCircuit interface {

// observer is used to observe the result of a single wrapped call through the circuit breaker.
type observer interface {
// observe is called after the wrapped function returns. If [Circuit.Do] returns a non-nil [Observable], it will be
// observe is called after the wrapped function returns. If [Circuit.Do] returns a non-nil [observer], it will be
// called exactly once.
observe(failure bool)
}
Expand Down
6 changes: 3 additions & 3 deletions hoglet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ type Breaker interface {
connect(untypedCircuit)

// observerForCall returns an observer for the incoming call.
// It is called exactly once per call to [Breaker.Do], before calling the wrapped function.
// It is called exactly once per call to [Circuit.Call], before calling the wrapped function.
// If the breaker is open, it returns nil.
// If the breaker is closed, it returns a non-nil [Observable] that will be used to observe the result of the call.
// If the breaker is closed, it returns a non-nil [observer] that will be used to observe the result of the call.
observerForCall(context.Context) (observer, error)
}

Expand Down Expand Up @@ -183,7 +183,7 @@ func (c *Circuit[IN, OUT]) Call(ctx context.Context, in IN) (out OUT, err error)
var internalCancellation = errors.New("internal cancellation")

// observeCtx observes the given context for cancellation and records it as a failure.
// It assumes [Observable.Observe] is idempotent and deduplicates calls itself.
// It assumes [observer] is idempotent and deduplicates calls itself.
func (c *Circuit[IN, OUT]) observeCtx(obs observer, ctx context.Context) {
// We want to observe a context error as soon as possible to open the breaker, but at the same time we want to
// keep the call to the wrapped function synchronous to avoid all pitfalls that come with asynchronicity.
Expand Down
2 changes: 1 addition & 1 deletion hoglet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type mockObservable struct {
once sync.Once
}

// observe implements [Observer]
// observe implements [observer]
func (mo *mockObservable) observe(failure bool) {
mo.once.Do(func() {
if mo.breaker != nil {
Expand Down

0 comments on commit c232a85

Please sign in to comment.