seqsvr

package
v0.0.0-...-5c9bec8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SectionStateCreated = iota
	SectionStateInitialized
)
View Source
const (
	StatePause uint32 = iota + 1
	StateOpen
)

Variables

This section is empty.

Functions

func Lock

func Lock() error

Types

type AllocService

type AllocService struct {
	api.UnimplementedAllocServer
	// contains filtered or unexported fields
}

func NewAllocService

func NewAllocService(sequence *Sequence, router *Router) *AllocService

func (*AllocService) FetchNext

func (a *AllocService) FetchNext(ctx context.Context, req *api.FetchSeqNextReq) (*api.UUID, error)

type PrepareApply

type PrepareApply struct {
	Version     uint64
	ApplyTick   int64
	Sections    []uint32
	SectionSize uint32
}

type RegisterEndpoint

type RegisterEndpoint struct {
	Scheme   string            `json:"scheme,omitempty"`
	Kind     types.ServerKind  `json:"kind,omitempty"`
	Host     string            `json:"host,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type RegisterNodeInfo

type RegisterNodeInfo struct {
	IP        string              `json:"ip,omitempty"`
	Endpoints []*RegisterEndpoint `json:"endpoints,omitempty"`
}

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) GetRouter

func (r *Router) GetRouter() *proto.Router

func (*Router) UpdateRouter

func (r *Router) UpdateRouter(router *proto.Router)

func (*Router) Version

func (r *Router) Version() uint64

type Section

type Section struct {
	ID uint32
	// contains filtered or unexported fields
}

func NewSection

func NewSection(ID, size uint32, storeCli Storage) *Section

func (*Section) FetchNextSeq

func (s *Section) FetchNextSeq(ctx context.Context, ID uint32) (seq uint64, err error)

type Sequence

type Sequence struct {
	// contains filtered or unexported fields
}

func NewSequence

func NewSequence(storeCli Storage) *Sequence

func (*Sequence) ApplyRouter

func (s *Sequence) ApplyRouter(tick int64)

func (*Sequence) CommitRouter

func (s *Sequence) CommitRouter(version uint64, applyTick int64, sectionSize uint32, sections []uint32)

func (*Sequence) FetchNextSeq

func (s *Sequence) FetchNextSeq(ctx context.Context, ID uint32) (seq uint64, err error)

func (*Sequence) Open

func (s *Sequence) Open()

func (*Sequence) Pause

func (s *Sequence) Pause()

func (*Sequence) Paused

func (s *Sequence) Paused() bool

func (*Sequence) Reset

func (s *Sequence) Reset()

type Storage

type Storage interface {
	Register(ctx context.Context, node *RegisterNodeInfo) error
	Unregister(ctx context.Context) error
	Heartbeat(ctx context.Context, version uint64) (*proto.Router, error)
	IncrAndGetMax(ctx context.Context, ID uint32, nowVal, step uint64) (uint64, error)
}

func NewEtcdv3Storage

func NewEtcdv3Storage() Storage

type TickType

type TickType int
const (
	TickBase      TickType = 0
	TickHeartbeat TickType = 1
)

type Ticker

type Ticker struct {
	// contains filtered or unexported fields
}

func NewTicker

func NewTicker(router *Router, sequence *Sequence, storeClient Storage) *Ticker

func (*Ticker) Run

func (t *Ticker) Run() error

func (*Ticker) Stop

func (t *Ticker) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL