mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-29 16:08:13 +02:00
add name
This commit is contained in:
parent
7e36c96884
commit
1f28934a94
2 changed files with 8 additions and 3 deletions
|
@ -4,6 +4,8 @@ package disabler
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errDisabled = errors.New("disabled")
|
var errDisabled = errors.New("disabled")
|
||||||
|
@ -19,6 +21,7 @@ type Disabler interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type disabler struct {
|
type disabler struct {
|
||||||
|
name string
|
||||||
handler Handler
|
handler Handler
|
||||||
onChangeEnabled chan bool
|
onChangeEnabled chan bool
|
||||||
}
|
}
|
||||||
|
@ -27,8 +30,8 @@ type disabler struct {
|
||||||
// RunEnabled will be called. If the Disabler is subsequently disabled the
|
// RunEnabled will be called. If the Disabler is subsequently disabled the
|
||||||
// context passed to RunEnabled will be canceled. If the Disabler is subseqently
|
// context passed to RunEnabled will be canceled. If the Disabler is subseqently
|
||||||
// enabled, RunEnabled will be started again.
|
// enabled, RunEnabled will be started again.
|
||||||
func New(handler Handler, enabled bool) Disabler {
|
func New(name string, handler Handler, enabled bool) Disabler {
|
||||||
d := disabler{handler: handler, onChangeEnabled: make(chan bool, 1)}
|
d := disabler{name: name, handler: handler, onChangeEnabled: make(chan bool, 1)}
|
||||||
d.change(enabled)
|
d.change(enabled)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
@ -47,8 +50,10 @@ func (d disabler) Run(ctx context.Context) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Ctx(ctx).Info().Msgf("enabled %s", d.name)
|
||||||
err := d.runEnabledOnce(ctx)
|
err := d.runEnabledOnce(ctx)
|
||||||
if errors.Is(err, errDisabled) {
|
if errors.Is(err, errDisabled) {
|
||||||
|
log.Ctx(ctx).Info().Msgf("disabled %s", d.name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ func New(
|
||||||
sessionScheduler: scheduler.New(),
|
sessionScheduler: scheduler.New(),
|
||||||
userScheduler: scheduler.New(),
|
userScheduler: scheduler.New(),
|
||||||
}
|
}
|
||||||
mgr.Disabler = disabler.New(mgr, true)
|
mgr.Disabler = disabler.New("identity_manager", mgr, true)
|
||||||
mgr.reset()
|
mgr.reset()
|
||||||
mgr.UpdateConfig(options...)
|
mgr.UpdateConfig(options...)
|
||||||
return mgr
|
return mgr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue