Documentation ¶
Index ¶
- type BaseRequest
- type CachedAllocator
- type EmptyTicker
- type GlobalIDAllocator
- type GlobalIDAllocatorInterface
- type IDAllocator
- type IDRequest
- type Interface
- type MockAllocator
- type MockAllocator_AllocOne_Call
- type MockAllocator_Alloc_Call
- func (_c *MockAllocator_Alloc_Call) Return(_a0 int64, _a1 int64, _a2 error) *MockAllocator_Alloc_Call
- func (_c *MockAllocator_Alloc_Call) Run(run func(count uint32)) *MockAllocator_Alloc_Call
- func (_c *MockAllocator_Alloc_Call) RunAndReturn(run func(uint32) (int64, int64, error)) *MockAllocator_Alloc_Call
- type MockAllocator_Expecter
- type MockGIDAllocator
- type MockGlobalIDAllocator
- type MockGlobalIDAllocator_AllocOne_Call
- func (_c *MockGlobalIDAllocator_AllocOne_Call) Return(_a0 int64, _a1 error) *MockGlobalIDAllocator_AllocOne_Call
- func (_c *MockGlobalIDAllocator_AllocOne_Call) Run(run func()) *MockGlobalIDAllocator_AllocOne_Call
- func (_c *MockGlobalIDAllocator_AllocOne_Call) RunAndReturn(run func() (int64, error)) *MockGlobalIDAllocator_AllocOne_Call
- type MockGlobalIDAllocator_Alloc_Call
- func (_c *MockGlobalIDAllocator_Alloc_Call) Return(_a0 int64, _a1 int64, _a2 error) *MockGlobalIDAllocator_Alloc_Call
- func (_c *MockGlobalIDAllocator_Alloc_Call) Run(run func(count uint32)) *MockGlobalIDAllocator_Alloc_Call
- func (_c *MockGlobalIDAllocator_Alloc_Call) RunAndReturn(run func(uint32) (int64, int64, error)) *MockGlobalIDAllocator_Alloc_Call
- type MockGlobalIDAllocator_Expecter
- type MockGlobalIDAllocator_Initialize_Call
- func (_c *MockGlobalIDAllocator_Initialize_Call) Return(_a0 error) *MockGlobalIDAllocator_Initialize_Call
- func (_c *MockGlobalIDAllocator_Initialize_Call) Run(run func()) *MockGlobalIDAllocator_Initialize_Call
- func (_c *MockGlobalIDAllocator_Initialize_Call) RunAndReturn(run func() error) *MockGlobalIDAllocator_Initialize_Call
- type Request
- type SyncRequest
- type Ticker
- type TickerChan
- type UniqueID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRequest ¶
BaseRequest implements Request interface.
func (*BaseRequest) Notify ¶
func (req *BaseRequest) Notify(err error)
Notify is used to send error to the requester.
func (*BaseRequest) Wait ¶
func (req *BaseRequest) Wait() error
Wait is blocked until the request is allocated or an error occurs.
type CachedAllocator ¶
type CachedAllocator struct { Ctx context.Context CancelFunc context.CancelFunc Reqs chan Request ToDoReqs []Request CanDoReqs []Request SyncReqs []Request TChan TickerChan ForceSyncChan chan Request SyncFunc func() (bool, error) ProcessFunc func(req Request) error CheckSyncFunc func(timeout bool) bool PickCanDoFunc func() SyncErr error Role string // contains filtered or unexported fields }
Allocator allocates from a global allocator by its given member functions
func (*CachedAllocator) CleanCache ¶
func (ta *CachedAllocator) CleanCache()
CleanCache is used to force synchronize with global allocator.
func (*CachedAllocator) Close ¶
func (ta *CachedAllocator) Close()
Close mainly stop the internal coroutine and recover resources.
func (*CachedAllocator) Init ¶
func (ta *CachedAllocator) Init()
Init mainly initialize internal members.
func (*CachedAllocator) Start ¶
func (ta *CachedAllocator) Start() error
Start starts the loop of checking whether to synchronize with the global allocator.
type EmptyTicker ¶
type EmptyTicker struct {
// contains filtered or unexported fields
}
EmptyTicker implements TickerChan, but it will never issue a signal in Chan.
func (*EmptyTicker) Chan ¶
func (t *EmptyTicker) Chan() <-chan time.Time
Chan returns a read-only channel from which you can only receive time.Time type data. As for EmptyTicker, you will never read data from Chan.
type GlobalIDAllocator ¶
type GlobalIDAllocator struct {
// contains filtered or unexported fields
}
GlobalIDAllocator is the global single point TSO allocator.
func NewGlobalIDAllocator ¶
func NewGlobalIDAllocator(key string, base kv.TxnKV) *GlobalIDAllocator
NewGlobalIDAllocator creates GlobalIDAllocator for allocates ID.
func (*GlobalIDAllocator) Alloc ¶
Alloc allocates the id of the count number. GenerateTSO is used to generate a given number of TSOs. Make sure you have initialized the TSO allocator before calling.
func (*GlobalIDAllocator) AllocOne ¶
func (gia *GlobalIDAllocator) AllocOne() (typeutil.UniqueID, error)
AllocOne allocates one id.
func (*GlobalIDAllocator) Initialize ¶
func (gia *GlobalIDAllocator) Initialize() error
Initialize will initialize the created global TSO allocator.
type GlobalIDAllocatorInterface ¶
type GlobalIDAllocatorInterface interface { // Initialize will initialize the created global TSO allocator. Initialize() error // Alloc allocates the id of the count number. Alloc(count uint32) (typeutil.UniqueID, typeutil.UniqueID, error) // AllocOne allocates one id. AllocOne() (typeutil.UniqueID, error) }
type IDAllocator ¶
type IDAllocator struct { CachedAllocator PeerID UniqueID // contains filtered or unexported fields }
IDAllocator allocates Unique and monotonically increasing IDs from Root Coord. It could also batch allocate for less root coord server access
func NewIDAllocator ¶
func NewIDAllocator(ctx context.Context, remoteAllocator remoteInterface, peerID UniqueID) (*IDAllocator, error)
NewIDAllocator creates an ID Allocator allocate Unique and monotonically increasing IDs from RootCoord.
func (*IDAllocator) Alloc ¶
func (ia *IDAllocator) Alloc(count uint32) (UniqueID, UniqueID, error)
Alloc allocates the id of the count number.
func (*IDAllocator) AllocOne ¶
func (ia *IDAllocator) AllocOne() (UniqueID, error)
AllocOne allocates one id.
func (*IDAllocator) Start ¶
func (ia *IDAllocator) Start() error
Start creates some working goroutines of IDAllocator.
type IDRequest ¶
type IDRequest struct { BaseRequest // contains filtered or unexported fields }
IDRequest implements Request and is used to get global unique Identities.
type Interface ¶
type Interface interface { Alloc(count uint32) (UniqueID, UniqueID, error) AllocOne() (UniqueID, error) }
Allocator interface is an interface for alloc id. Alloc allocates the id of the count number. AllocOne allocates one id. See GlobalIDAllocator for implementation details
func NewLocalAllocator ¶
type MockAllocator ¶
MockAllocator is an autogenerated mock type for the Interface type
func NewMockAllocator ¶
func NewMockAllocator(t interface { mock.TestingT Cleanup(func()) }) *MockAllocator
NewMockAllocator creates a new instance of MockAllocator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockAllocator) Alloc ¶
func (_m *MockAllocator) Alloc(count uint32) (int64, int64, error)
Alloc provides a mock function with given fields: count
func (*MockAllocator) AllocOne ¶
func (_m *MockAllocator) AllocOne() (int64, error)
AllocOne provides a mock function with given fields:
func (*MockAllocator) EXPECT ¶
func (_m *MockAllocator) EXPECT() *MockAllocator_Expecter
type MockAllocator_AllocOne_Call ¶
MockAllocator_AllocOne_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllocOne'
func (*MockAllocator_AllocOne_Call) Return ¶
func (_c *MockAllocator_AllocOne_Call) Return(_a0 int64, _a1 error) *MockAllocator_AllocOne_Call
func (*MockAllocator_AllocOne_Call) Run ¶
func (_c *MockAllocator_AllocOne_Call) Run(run func()) *MockAllocator_AllocOne_Call
func (*MockAllocator_AllocOne_Call) RunAndReturn ¶
func (_c *MockAllocator_AllocOne_Call) RunAndReturn(run func() (int64, error)) *MockAllocator_AllocOne_Call
type MockAllocator_Alloc_Call ¶
MockAllocator_Alloc_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Alloc'
func (*MockAllocator_Alloc_Call) Return ¶
func (_c *MockAllocator_Alloc_Call) Return(_a0 int64, _a1 int64, _a2 error) *MockAllocator_Alloc_Call
func (*MockAllocator_Alloc_Call) Run ¶
func (_c *MockAllocator_Alloc_Call) Run(run func(count uint32)) *MockAllocator_Alloc_Call
func (*MockAllocator_Alloc_Call) RunAndReturn ¶
func (_c *MockAllocator_Alloc_Call) RunAndReturn(run func(uint32) (int64, int64, error)) *MockAllocator_Alloc_Call
type MockAllocator_Expecter ¶
type MockAllocator_Expecter struct {
// contains filtered or unexported fields
}
func (*MockAllocator_Expecter) Alloc ¶
func (_e *MockAllocator_Expecter) Alloc(count interface{}) *MockAllocator_Alloc_Call
Alloc is a helper method to define mock.On call
- count uint32
func (*MockAllocator_Expecter) AllocOne ¶
func (_e *MockAllocator_Expecter) AllocOne() *MockAllocator_AllocOne_Call
AllocOne is a helper method to define mock.On call
type MockGIDAllocator ¶
type MockGIDAllocator struct { Interface AllocF func(count uint32) (UniqueID, UniqueID, error) AllocOneF func() (UniqueID, error) UpdateIDF func() error }
func NewMockGIDAllocator ¶
func NewMockGIDAllocator() *MockGIDAllocator
func (MockGIDAllocator) Alloc ¶
func (m MockGIDAllocator) Alloc(count uint32) (UniqueID, UniqueID, error)
func (MockGIDAllocator) AllocOne ¶
func (m MockGIDAllocator) AllocOne() (UniqueID, error)
func (MockGIDAllocator) UpdateID ¶
func (m MockGIDAllocator) UpdateID() error
type MockGlobalIDAllocator ¶
MockGlobalIDAllocator is an autogenerated mock type for the GlobalIDAllocatorInterface type
func NewMockGlobalIDAllocator ¶
func NewMockGlobalIDAllocator(t interface { mock.TestingT Cleanup(func()) }) *MockGlobalIDAllocator
NewMockGlobalIDAllocator creates a new instance of MockGlobalIDAllocator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockGlobalIDAllocator) Alloc ¶
func (_m *MockGlobalIDAllocator) Alloc(count uint32) (int64, int64, error)
Alloc provides a mock function with given fields: count
func (*MockGlobalIDAllocator) AllocOne ¶
func (_m *MockGlobalIDAllocator) AllocOne() (int64, error)
AllocOne provides a mock function with given fields:
func (*MockGlobalIDAllocator) EXPECT ¶
func (_m *MockGlobalIDAllocator) EXPECT() *MockGlobalIDAllocator_Expecter
func (*MockGlobalIDAllocator) Initialize ¶
func (_m *MockGlobalIDAllocator) Initialize() error
Initialize provides a mock function with given fields:
type MockGlobalIDAllocator_AllocOne_Call ¶
MockGlobalIDAllocator_AllocOne_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllocOne'
func (*MockGlobalIDAllocator_AllocOne_Call) Return ¶
func (_c *MockGlobalIDAllocator_AllocOne_Call) Return(_a0 int64, _a1 error) *MockGlobalIDAllocator_AllocOne_Call
func (*MockGlobalIDAllocator_AllocOne_Call) Run ¶
func (_c *MockGlobalIDAllocator_AllocOne_Call) Run(run func()) *MockGlobalIDAllocator_AllocOne_Call
func (*MockGlobalIDAllocator_AllocOne_Call) RunAndReturn ¶
func (_c *MockGlobalIDAllocator_AllocOne_Call) RunAndReturn(run func() (int64, error)) *MockGlobalIDAllocator_AllocOne_Call
type MockGlobalIDAllocator_Alloc_Call ¶
MockGlobalIDAllocator_Alloc_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Alloc'
func (*MockGlobalIDAllocator_Alloc_Call) Return ¶
func (_c *MockGlobalIDAllocator_Alloc_Call) Return(_a0 int64, _a1 int64, _a2 error) *MockGlobalIDAllocator_Alloc_Call
func (*MockGlobalIDAllocator_Alloc_Call) Run ¶
func (_c *MockGlobalIDAllocator_Alloc_Call) Run(run func(count uint32)) *MockGlobalIDAllocator_Alloc_Call
func (*MockGlobalIDAllocator_Alloc_Call) RunAndReturn ¶
func (_c *MockGlobalIDAllocator_Alloc_Call) RunAndReturn(run func(uint32) (int64, int64, error)) *MockGlobalIDAllocator_Alloc_Call
type MockGlobalIDAllocator_Expecter ¶
type MockGlobalIDAllocator_Expecter struct {
// contains filtered or unexported fields
}
func (*MockGlobalIDAllocator_Expecter) Alloc ¶
func (_e *MockGlobalIDAllocator_Expecter) Alloc(count interface{}) *MockGlobalIDAllocator_Alloc_Call
Alloc is a helper method to define mock.On call
- count uint32
func (*MockGlobalIDAllocator_Expecter) AllocOne ¶
func (_e *MockGlobalIDAllocator_Expecter) AllocOne() *MockGlobalIDAllocator_AllocOne_Call
AllocOne is a helper method to define mock.On call
func (*MockGlobalIDAllocator_Expecter) Initialize ¶
func (_e *MockGlobalIDAllocator_Expecter) Initialize() *MockGlobalIDAllocator_Initialize_Call
Initialize is a helper method to define mock.On call
type MockGlobalIDAllocator_Initialize_Call ¶
MockGlobalIDAllocator_Initialize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Initialize'
func (*MockGlobalIDAllocator_Initialize_Call) Return ¶
func (_c *MockGlobalIDAllocator_Initialize_Call) Return(_a0 error) *MockGlobalIDAllocator_Initialize_Call
func (*MockGlobalIDAllocator_Initialize_Call) Run ¶
func (_c *MockGlobalIDAllocator_Initialize_Call) Run(run func()) *MockGlobalIDAllocator_Initialize_Call
func (*MockGlobalIDAllocator_Initialize_Call) RunAndReturn ¶
func (_c *MockGlobalIDAllocator_Initialize_Call) RunAndReturn(run func() error) *MockGlobalIDAllocator_Initialize_Call
type SyncRequest ¶
type SyncRequest struct {
BaseRequest
}
SyncRequest embeds BaseRequest and is used to force synchronize from RootCoordinator.
type Ticker ¶
Ticker implements TickerChan and is a simple wrapper for time.TimeTicker.
func (*Ticker) Chan ¶
Chan return a read-only channel from which you can only receive time.Time type data
type TickerChan ¶
TickerChan defines an interface.