github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/wal/kv/kv.go (about)

     1  package kv
     2  
     3  import (
     4  	"os"
     5  	"time"
     6  )
     7  
     8  // KV is the interface that groups the Simpler and Scanner interfaces.
     9  type KV interface {
    10  	OpenCloser
    11  	Simpler
    12  	Scanner
    13  	Sequencer
    14  }
    15  
    16  // Simpler is the interface that groups the basic Put, Get and Delete methods.
    17  type Simpler interface {
    18  	Put([]byte, []byte) error
    19  	Get([]byte) ([]byte, error)
    20  	Delete([]byte) error
    21  }
    22  
    23  // Scanner is the interface that wraps the basic Scan method.
    24  type Scanner interface {
    25  	Scan([]byte) (<-chan ScanEntry, func())
    26  }
    27  
    28  // Sequencer is the interface that wraps the basic NextSequence method.
    29  type Sequencer interface {
    30  	NextSequence() (ID uint64, err error)
    31  }
    32  
    33  // OpenCloser is the interface that groups the basic Open and Close methods.
    34  type OpenCloser interface {
    35  	Open(path string, mode os.FileMode, timeout time.Duration) error
    36  	Close() error
    37  }
    38  
    39  // ScanEntry is the interface that groups the basic Pair and Error methods.
    40  type ScanEntry interface {
    41  	Pair() (key []byte, value []byte)
    42  	Error() error
    43  }