-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (32 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package reap contains the history reaping subsystem for orbitr. This system
// is designed to remove data from the history database such that it does not
// grow indefinitely. The system can be configured with a number of ledgers to
// maintain at a minimum.
package reap
import (
"context"
"github.com/lantah/go/services/orbitr/internal/db2/history"
"github.com/lantah/go/services/orbitr/internal/ledger"
"github.com/lantah/go/support/db"
)
// System represents the history reaping subsystem of orbitr.
type System struct {
HistoryQ *history.Q
RetentionCount uint
ledgerState *ledger.State
ctx context.Context
cancel context.CancelFunc
}
// New initializes the reaper, causing it to begin polling the gravity
// database for now ledgers and ingesting data into the orbitr database.
func New(retention uint, dbSession db.SessionInterface, ledgerState *ledger.State) *System {
ctx, cancel := context.WithCancel(context.Background())
r := &System{
HistoryQ: &history.Q{dbSession.Clone()},
RetentionCount: retention,
ledgerState: ledgerState,
ctx: ctx,
cancel: cancel,
}
return r
}