forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crud_log.go
41 lines (33 loc) · 883 Bytes
/
crud_log.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
package influxdb
import (
"time"
)
// CRUDLogSetter is the interface to set the crudlog.
type CRUDLogSetter interface {
SetCreatedAt(now time.Time)
SetUpdatedAt(now time.Time)
}
// CRUDLog is the struct to store crud related ops.
type CRUDLog struct {
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// SetCreatedAt set the created time.
func (log *CRUDLog) SetCreatedAt(now time.Time) {
log.CreatedAt = now
}
// SetUpdatedAt set the updated time.
func (log *CRUDLog) SetUpdatedAt(now time.Time) {
log.UpdatedAt = now
}
// TimeGenerator represents a generator for now.
type TimeGenerator interface {
// Now creates the generated time.
Now() time.Time
}
// RealTimeGenerator will generate the real time.
type RealTimeGenerator struct{}
// Now returns the current time.
func (g RealTimeGenerator) Now() time.Time {
return time.Now()
}