-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from adambaumeister/maxage
Maxage
- Loading branch information
Showing
11 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"github.com/adambaumeister/goflow/backends" | ||
"time" | ||
) | ||
|
||
/* | ||
MaxAge | ||
Using exposed "prune" methods from backends and associated GlobalConfig, deletes flow records. | ||
*/ | ||
type MaxAge struct { | ||
// String because it's going into a query string anyway | ||
MaxAgeDays string | ||
backends map[string]backends.Backend | ||
} | ||
|
||
// Set the backends to operate on | ||
func (m *MaxAge) SetBackends(b map[string]backends.Backend) { | ||
m.backends = b | ||
} | ||
|
||
func (m *MaxAge) Run() { | ||
for { | ||
for _, be := range m.backends { | ||
be.Prune(m.MaxAgeDays) | ||
} | ||
fmt.Printf("Pruning configured backends...") | ||
// This is really gross, we should have some sort of internal crontab-like thing for utilities | ||
time.Sleep(86400 * time.Second) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package utils | ||
|
||
import "github.com/adambaumeister/goflow/backends" | ||
|
||
type Utility interface { | ||
SetBackends(map[string]backends.Backend) | ||
Run() | ||
} |