Create Trimmer interface
This commit is contained in:
parent
424eebde84
commit
df7c49247b
@ -225,7 +225,7 @@ func main () {
|
||||
|
||||
// set up the trimming routine
|
||||
trimmer := trimmerRoutine {
|
||||
HTTPHandler: &handler,
|
||||
Trimmer: &handler,
|
||||
}
|
||||
|
||||
// set up the routine manager
|
||||
@ -266,7 +266,7 @@ func (this *httpServerRoutine) Run (ctx context.Context) error {
|
||||
}
|
||||
|
||||
type trimmerRoutine struct {
|
||||
HTTPHandler *stephttp.Handler
|
||||
Trimmer step.Trimmer
|
||||
}
|
||||
|
||||
func (this *trimmerRoutine) Run (ctx context.Context) error {
|
||||
@ -275,7 +275,7 @@ func (this *trimmerRoutine) Run (ctx context.Context) error {
|
||||
for {
|
||||
select {
|
||||
case <- ticker.C:
|
||||
this.HTTPHandler.Trim()
|
||||
this.Trimmer.Trim()
|
||||
case <- ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
|
@ -28,6 +28,14 @@ type ConfigProcessor interface {
|
||||
ProcessConfig (config Meta) error
|
||||
}
|
||||
|
||||
// Trimmer is an object that needs to be routinely "trimmed". This can be
|
||||
// garbage collecting, sanity checking, etc.
|
||||
type Trimmer interface {
|
||||
// Trim trims the object. It must not block for any significant length
|
||||
// of time. It should be called every minute or so.
|
||||
Trim ()
|
||||
}
|
||||
|
||||
// FuncProvider provides a template.FuncMap.
|
||||
type FuncProvider interface {
|
||||
Provider
|
||||
|
Loading…
Reference in New Issue
Block a user