github.com/influxdata/influxdb/v2@v2.7.6/crud_log.go (about)

     1  package influxdb
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // CRUDLogSetter is the interface to set the crudlog.
     8  type CRUDLogSetter interface {
     9  	SetCreatedAt(now time.Time)
    10  	SetUpdatedAt(now time.Time)
    11  }
    12  
    13  // CRUDLog is the struct to store crud related ops.
    14  type CRUDLog struct {
    15  	CreatedAt time.Time `json:"createdAt"`
    16  	UpdatedAt time.Time `json:"updatedAt"`
    17  }
    18  
    19  // SetCreatedAt set the created time.
    20  func (log *CRUDLog) SetCreatedAt(now time.Time) {
    21  	log.CreatedAt = now
    22  }
    23  
    24  // SetUpdatedAt set the updated time.
    25  func (log *CRUDLog) SetUpdatedAt(now time.Time) {
    26  	log.UpdatedAt = now
    27  }
    28  
    29  // TimeGenerator represents a generator for now.
    30  type TimeGenerator interface {
    31  	// Now creates the generated time.
    32  	Now() time.Time
    33  }
    34  
    35  // RealTimeGenerator will generate the real time.
    36  type RealTimeGenerator struct{}
    37  
    38  // Now returns the current time.
    39  func (g RealTimeGenerator) Now() time.Time {
    40  	return time.Now()
    41  }