Documentation ¶
Index ¶
- Constants
- func HLCKeyLessThanFunc(lhs, rhs HLCRevision) bool
- func TimestampIDKeyFunc(r TimestampRevision) int64
- func TimestampIDKeyLessThanFunc(l, r int64) bool
- func TransactionIDKeyFunc(r TransactionIDRevision) uint64
- func TransactionIDKeyLessThanFunc(l, r uint64) bool
- type CachedOptimizedRevisions
- type CommonDecoder
- type HLCRevision
- func (hlc HLCRevision) AsDecimal() (decimal.Decimal, error)
- func (hlc HLCRevision) ConstructForTimestamp(timestamp int64) WithTimestampRevision
- func (hlc HLCRevision) Equal(rhs datastore.Revision) bool
- func (hlc HLCRevision) GreaterThan(rhs datastore.Revision) bool
- func (hlc HLCRevision) InexactFloat64() float64
- func (hlc HLCRevision) LessThan(rhs datastore.Revision) bool
- func (hlc HLCRevision) String() string
- func (hlc HLCRevision) TimestampNanoSec() int64
- type OptimizedRevisionFunction
- type ParsingFunc
- type RemoteClockRevisions
- type RemoteNowFunction
- type RevisionKind
- type TimestampRevision
- func (ir TimestampRevision) ConstructForTimestamp(timestamp int64) WithTimestampRevision
- func (ir TimestampRevision) Equal(rhs datastore.Revision) bool
- func (ir TimestampRevision) GreaterThan(rhs datastore.Revision) bool
- func (ir TimestampRevision) LessThan(rhs datastore.Revision) bool
- func (ir TimestampRevision) String() string
- func (ir TimestampRevision) Time() time.Time
- func (ir TimestampRevision) TimestampNanoSec() int64
- func (ir TimestampRevision) WithInexactFloat64() float64
- type TransactionIDRevision
- func (ir TransactionIDRevision) Equal(rhs datastore.Revision) bool
- func (ir TransactionIDRevision) GreaterThan(rhs datastore.Revision) bool
- func (ir TransactionIDRevision) LessThan(rhs datastore.Revision) bool
- func (ir TransactionIDRevision) String() string
- func (ir TransactionIDRevision) TransactionID() uint64
- func (ir TransactionIDRevision) WithInexactFloat64() float64
- type WithInexactFloat64
- type WithTimestampRevision
Constants ¶
const ( // Timestamp is a revision that is a timestamp. Timestamp RevisionKind = "timestamp" // TransactionID is a revision that is a transaction ID. TransactionID = "txid" // HybridLogicalClock is a revision that is a hybrid logical clock. HybridLogicalClock = "hlc" )
Variables ¶
This section is empty.
Functions ¶
func HLCKeyLessThanFunc ¶
func HLCKeyLessThanFunc(lhs, rhs HLCRevision) bool
HLCKeyLessThanFunc is used to compare keys created by the HLCKeyFunc.
func TimestampIDKeyFunc ¶
func TimestampIDKeyFunc(r TimestampRevision) int64
TimestampIDKeyFunc is used to create keys for timestamps.
func TimestampIDKeyLessThanFunc ¶
TimestampIDKeyLessThanFunc is used to create keys for timestamps.
func TransactionIDKeyFunc ¶
func TransactionIDKeyFunc(r TransactionIDRevision) uint64
TransactionIDKeyFunc is used to create keys for transaction IDs.
func TransactionIDKeyLessThanFunc ¶
TransactionIDKeyLessThanFunc is used to create keys for transaction IDs.
Types ¶
type CachedOptimizedRevisions ¶
CachedOptimizedRevisions does caching and deduplication for requests for optimized revisions.
func NewCachedOptimizedRevisions ¶
func NewCachedOptimizedRevisions(maxRevisionStaleness time.Duration) *CachedOptimizedRevisions
NewCachedOptimizedRevisions returns a CachedOptimizedRevisions for the given configuration
func (*CachedOptimizedRevisions) OptimizedRevision ¶
func (*CachedOptimizedRevisions) SetOptimizedRevisionFunc ¶
func (cor *CachedOptimizedRevisions) SetOptimizedRevisionFunc(revisionFunc OptimizedRevisionFunction)
SetOptimizedRevisionFunc must be called after construction, and is the method by which one specializes this helper for a specific datastore.
type CommonDecoder ¶
type CommonDecoder struct {
Kind RevisionKind
}
CommonDecoder is a revision decoder that can decode revisions of a given kind.
func (CommonDecoder) RevisionFromString ¶
func (cd CommonDecoder) RevisionFromString(s string) (datastore.Revision, error)
type HLCRevision ¶
type HLCRevision struct {
// contains filtered or unexported fields
}
HLCRevision is a revision that is a hybrid logical clock, stored as two integers. The first integer is the timestamp in nanoseconds, and the second integer is the logical clock defined as 11 digits, with the first digit being ignored to ensure precision of the given logical clock.
func HLCKeyFunc ¶
func HLCKeyFunc(r HLCRevision) HLCRevision
HLCKeyFunc is used to convert a simple HLC for use in maps.
func HLCRevisionFromString ¶
func HLCRevisionFromString(revisionStr string) (HLCRevision, error)
HLCRevisionFromString parses a string into a hybrid logical clock revision.
func NewForHLC ¶
func NewForHLC(decimal decimal.Decimal) (HLCRevision, error)
NewForHLC creates a new revision for the given hybrid logical clock.
func NewHLCForTime ¶
func NewHLCForTime(time time.Time) HLCRevision
NewHLCForTime creates a new revision for the given time.
func (HLCRevision) ConstructForTimestamp ¶
func (hlc HLCRevision) ConstructForTimestamp(timestamp int64) WithTimestampRevision
func (HLCRevision) GreaterThan ¶
func (hlc HLCRevision) GreaterThan(rhs datastore.Revision) bool
func (HLCRevision) InexactFloat64 ¶
func (hlc HLCRevision) InexactFloat64() float64
func (HLCRevision) String ¶
func (hlc HLCRevision) String() string
func (HLCRevision) TimestampNanoSec ¶
func (hlc HLCRevision) TimestampNanoSec() int64
type OptimizedRevisionFunction ¶
type OptimizedRevisionFunction func(context.Context) (rev datastore.Revision, validFor time.Duration, err error)
OptimizedRevisionFunction instructs the datastore to compute its own current optimized revision given the specific quantization, and return for how long it will remain valid.
type ParsingFunc ¶
ParsingFunc is a function that can parse a string into a revision.
func RevisionParser ¶
func RevisionParser(kind RevisionKind) ParsingFunc
RevisionParser returns a ParsingFunc for the given RevisionKind.
type RemoteClockRevisions ¶
type RemoteClockRevisions struct { *CachedOptimizedRevisions // contains filtered or unexported fields }
RemoteClockRevisions handles revision calculation for datastores that provide their own clocks.
func NewRemoteClockRevisions ¶
func NewRemoteClockRevisions(gcWindow, maxRevisionStaleness, followerReadDelay, quantization time.Duration) *RemoteClockRevisions
NewRemoteClockRevisions returns a RemoteClockRevisions for the given configuration
func (*RemoteClockRevisions) CheckRevision ¶
func (*RemoteClockRevisions) SetNowFunc ¶
func (rcr *RemoteClockRevisions) SetNowFunc(nowFunc RemoteNowFunction)
SetNowFunc sets the function used to determine the head revision
type RemoteNowFunction ¶
RemoteNowFunction queries the datastore to get a current revision.
type RevisionKind ¶
type RevisionKind string
RevisionKind is an enum of the different kinds of revisions that can be used.
type TimestampRevision ¶
type TimestampRevision int64
TimestampRevision is a revision that is a timestamp.
func NewForTime ¶
func NewForTime(time time.Time) TimestampRevision
NewForTime creates a new revision for the given time.
func NewForTimestamp ¶
func NewForTimestamp(timestampNanosec int64) TimestampRevision
NewForTimestamp creates a new revision for the given timestamp.
func (TimestampRevision) ConstructForTimestamp ¶
func (ir TimestampRevision) ConstructForTimestamp(timestamp int64) WithTimestampRevision
func (TimestampRevision) GreaterThan ¶
func (ir TimestampRevision) GreaterThan(rhs datastore.Revision) bool
func (TimestampRevision) LessThan ¶
func (ir TimestampRevision) LessThan(rhs datastore.Revision) bool
func (TimestampRevision) String ¶
func (ir TimestampRevision) String() string
func (TimestampRevision) Time ¶
func (ir TimestampRevision) Time() time.Time
func (TimestampRevision) TimestampNanoSec ¶
func (ir TimestampRevision) TimestampNanoSec() int64
func (TimestampRevision) WithInexactFloat64 ¶
func (ir TimestampRevision) WithInexactFloat64() float64
type TransactionIDRevision ¶
type TransactionIDRevision uint64
TransactionIDRevision is a revision that is a transaction ID.
func NewForTransactionID ¶
func NewForTransactionID(transactionID uint64) TransactionIDRevision
NewForTransactionID creates a new revision for the given transaction ID.
func (TransactionIDRevision) Equal ¶
func (ir TransactionIDRevision) Equal(rhs datastore.Revision) bool
func (TransactionIDRevision) GreaterThan ¶
func (ir TransactionIDRevision) GreaterThan(rhs datastore.Revision) bool
func (TransactionIDRevision) LessThan ¶
func (ir TransactionIDRevision) LessThan(rhs datastore.Revision) bool
func (TransactionIDRevision) String ¶
func (ir TransactionIDRevision) String() string
func (TransactionIDRevision) TransactionID ¶
func (ir TransactionIDRevision) TransactionID() uint64
func (TransactionIDRevision) WithInexactFloat64 ¶
func (ir TransactionIDRevision) WithInexactFloat64() float64
type WithInexactFloat64 ¶
type WithInexactFloat64 interface { // InexactFloat64 returns a float64 that is an inexact representation of the // revision. InexactFloat64() float64 }
WithInexactFloat64 is an interface that can be implemented by a revision to provide an inexact float64 representation of the revision.
type WithTimestampRevision ¶
type WithTimestampRevision interface { datastore.Revision TimestampNanoSec() int64 ConstructForTimestamp(timestampNanoSec int64) WithTimestampRevision }
WithTimestampRevision is an interface that can be implemented by a revision to provide a timestamp.