Documentation
¶
Index ¶
- Variables
- type Coordinate
- type CoordinateResponse
- type Coordinator
- type Elem
- type FSM
- type HLC
- type OP
- type OperationGroup
- type ShardRouter
- func (s *ShardRouter) Abort(reqs []*pb.Request) (*TransactionResponse, error)
- func (s *ShardRouter) Commit(reqs []*pb.Request) (*TransactionResponse, error)
- func (s *ShardRouter) Get(ctx context.Context, key []byte) ([]byte, error)
- func (s *ShardRouter) Register(group uint64, tm Transactional, st store.MVCCStore)
- type TransactionManager
- type TransactionResponse
- type Transactional
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRequest = errors.New("invalid request")
var ErrNotImplemented = errors.New("not implemented")
var ErrUnknownRequestType = errors.New("unknown request type")
Functions ¶
This section is empty.
Types ¶
type Coordinate ¶
type Coordinate struct {
// contains filtered or unexported fields
}
func NewCoordinator ¶
func NewCoordinator(txm Transactional, r *raft.Raft) *Coordinate
func (*Coordinate) Clock ¶
func (c *Coordinate) Clock() *HLC
func (*Coordinate) Dispatch ¶
func (c *Coordinate) Dispatch(reqs *OperationGroup[OP]) (*CoordinateResponse, error)
func (*Coordinate) IsLeader ¶
func (c *Coordinate) IsLeader() bool
func (*Coordinate) RaftLeader ¶
func (c *Coordinate) RaftLeader() raft.ServerAddress
RaftLeader returns the current leader's address as known by this node.
func (*Coordinate) VerifyLeader ¶
func (c *Coordinate) VerifyLeader() error
type CoordinateResponse ¶
type CoordinateResponse struct {
CommitIndex uint64
}
type Coordinator ¶
type Coordinator interface {
Dispatch(reqs *OperationGroup[OP]) (*CoordinateResponse, error)
IsLeader() bool
VerifyLeader() error
RaftLeader() raft.ServerAddress
Clock() *HLC
}
type HLC ¶
type HLC struct {
// contains filtered or unexported fields
}
HLC implements a simple hybrid logical clock suitable for issuing monotonically increasing timestamps across shards/raft groups.
Layout (ms logical):
high 48 bits: wall clock milliseconds since Unix epoch low 16 bits : logical counter to break ties when wall time does not advance
This keeps ordering stable across leaders as long as clocks are loosely synchronized; it avoids dependence on per-raft commit indices that diverge between shards.
type OperationGroup ¶
type OperationGroup[T OP] struct { Elems []*Elem[T] IsTxn bool // StartTS is a logical timestamp captured at transaction begin. // It is ignored for non-transactional groups. StartTS uint64 }
OperationGroup is a group of operations that should be executed atomically.
type ShardRouter ¶
type ShardRouter struct {
// contains filtered or unexported fields
}
ShardRouter routes requests to multiple raft groups based on key ranges. It does not provide transactional guarantees across shards; commits are executed per shard and failures may leave partial results.
func NewShardRouter ¶
func NewShardRouter(e *distribution.Engine) *ShardRouter
NewShardRouter creates a new router.
func (*ShardRouter) Abort ¶
func (s *ShardRouter) Abort(reqs []*pb.Request) (*TransactionResponse, error)
Abort dispatches aborts to the correct raft group.
func (*ShardRouter) Commit ¶
func (s *ShardRouter) Commit(reqs []*pb.Request) (*TransactionResponse, error)
func (*ShardRouter) Register ¶
func (s *ShardRouter) Register(group uint64, tm Transactional, st store.MVCCStore)
Register associates a raft group ID with its transactional manager and store.
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(raft *raft.Raft) *TransactionManager
func (*TransactionManager) Abort ¶
func (t *TransactionManager) Abort(reqs []*pb.Request) (*TransactionResponse, error)
func (*TransactionManager) Commit ¶
func (t *TransactionManager) Commit(reqs []*pb.Request) (*TransactionResponse, error)
type TransactionResponse ¶
type TransactionResponse struct {
CommitIndex uint64
}
type Transactional ¶
type Transactional interface {
Commit(reqs []*pb.Request) (*TransactionResponse, error)
Abort(reqs []*pb.Request) (*TransactionResponse, error)
}