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

     1  package influxdb
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  )
     7  
     8  // KeyValueLog is a generic type logs key-value pairs. This interface is intended to be used to construct other
     9  // higher-level log-like resources such as an oplog or audit log.
    10  //
    11  // The idea is to create a log who values can be accessed at the key k:
    12  // k -> [(v0,t0) (v1,t1) ... (vn,tn)]
    13  //
    14  // Logs may be retrieved in ascending or descending time order and support limits and offsets.
    15  type KeyValueLog interface {
    16  	// AddLogEntry adds an entry (v,t) to the log defined for the key k.
    17  	AddLogEntry(ctx context.Context, k []byte, v []byte, t time.Time) error
    18  
    19  	// ForEachLogEntry iterates through all the log entries at key k and applies the function fn for each record.
    20  	ForEachLogEntry(ctx context.Context, k []byte, opts FindOptions, fn func(v []byte, t time.Time) error) error
    21  
    22  	// FirstLogEntry is used to retrieve the first entry in the log at key k.
    23  	FirstLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error)
    24  
    25  	// LastLogEntry is used to retrieve the last entry in the log at key k.
    26  	LastLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error)
    27  }