-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
43 lines (37 loc) · 797 Bytes
/
model.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
39
40
41
42
43
package pgbuffer
import (
"database/sql"
"sync"
"time"
"github.com/sirupsen/logrus"
)
type Buffer struct {
data map[string]*BufferedData
db *sql.DB
writeChan chan *writePayload
logger *logrus.Logger
cfg *Config
stopSignal chan struct{}
flushSignal chan struct{}
}
type Config struct {
Limit int64 `yaml:"limit"`
Tables []*BufferedData `yaml:"tables"`
Workers int `yaml:"workers"`
Logger *logrus.Logger
}
type BufferedData struct {
sync.Mutex
flushing bool
LastExit time.Time
LastWrite time.Time
data [][]interface{}
Table string `yaml:"table"`
Columns []string `yaml:"columns"`
Limit int64 `yaml:"limit"`
position int64
}
type writePayload struct {
table string
rows []interface{}
}