mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 00:34:28 +08:00
support importing transaction by csv/tsv file via command line
This commit is contained in:
@@ -60,7 +60,7 @@ func (u *InternalUuidGenerator) GenerateUuid(idType UuidType) int64 {
|
||||
}
|
||||
|
||||
// GenerateUuids generates new uuids
|
||||
func (u *InternalUuidGenerator) GenerateUuids(idType UuidType, count uint8) []int64 {
|
||||
func (u *InternalUuidGenerator) GenerateUuids(idType UuidType, count uint16) []int64 {
|
||||
// 63bits = unixTime(32bits) + uuidType(4bits) + uuidServerId(8bits) + sequentialNumber(19bits)
|
||||
|
||||
uuids := make([]int64, count)
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestGenerateUuids_Count0(t *testing.T) {
|
||||
func TestGenerateUuids_Count255(t *testing.T) {
|
||||
expectedUuidServerId := uint8(90)
|
||||
expectedUuidType := UUID_TYPE_TRANSACTION
|
||||
expectedUuidCount := uint8(255)
|
||||
expectedUuidCount := uint16(255)
|
||||
|
||||
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: expectedUuidServerId})
|
||||
|
||||
@@ -250,7 +250,7 @@ func TestGenerateUuids_Count255(t *testing.T) {
|
||||
func TestGenerateUuids_30TimesIn3Seconds(t *testing.T) {
|
||||
expectedUuidServerId := uint8(90)
|
||||
expectedUuidType := UUID_TYPE_TRANSACTION
|
||||
expectedUuidCount := uint8(255)
|
||||
expectedUuidCount := uint16(255)
|
||||
|
||||
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: expectedUuidServerId})
|
||||
|
||||
@@ -289,7 +289,7 @@ func TestGenerateUuids_30TimesIn3Seconds(t *testing.T) {
|
||||
|
||||
func TestGenerateUuids_20000TimesConcurrent(t *testing.T) {
|
||||
concurrentCount := 10
|
||||
expectedUuidCount := uint8(20)
|
||||
expectedUuidCount := uint16(20)
|
||||
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: 3})
|
||||
var mutex sync.Mutex
|
||||
var generatedIds sync.Map
|
||||
@@ -338,7 +338,7 @@ func TestGenerateUuids_20000TimesConcurrent(t *testing.T) {
|
||||
|
||||
func TestGenerateUuids_1000000TimesConcurrent(t *testing.T) {
|
||||
concurrentCount := 10
|
||||
expectedUuidCount := uint8(250)
|
||||
expectedUuidCount := uint16(250)
|
||||
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: 3})
|
||||
var mutex sync.Mutex
|
||||
var generatedIds sync.Map
|
||||
@@ -391,7 +391,7 @@ func TestGenerateUuids_1000000TimesConcurrent(t *testing.T) {
|
||||
|
||||
func TestGenerateUuid_Over524287Times(t *testing.T) {
|
||||
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: 1})
|
||||
onceGenerateCount := uint8(255)
|
||||
onceGenerateCount := uint16(255)
|
||||
generationStartUnixTime := time.Now().Unix()
|
||||
|
||||
for i := 0; i < 2057; i++ { // 2056*255=524280, 2057*255=524,535 (only can generates 524,287 uuids per second)
|
||||
|
||||
@@ -33,6 +33,6 @@ func (u *UuidContainer) GenerateUuid(uuidType UuidType) int64 {
|
||||
}
|
||||
|
||||
// GenerateUuids returns new uuids by the current uuid generator
|
||||
func (u *UuidContainer) GenerateUuids(uuidType UuidType, count uint8) []int64 {
|
||||
func (u *UuidContainer) GenerateUuids(uuidType UuidType, count uint16) []int64 {
|
||||
return u.Current.GenerateUuids(uuidType, count)
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package uuid
|
||||
// UuidGenerator is common uuid generator interface
|
||||
type UuidGenerator interface {
|
||||
GenerateUuid(uuidType UuidType) int64
|
||||
GenerateUuids(uuidType UuidType, count uint8) []int64
|
||||
GenerateUuids(uuidType UuidType, count uint16) []int64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user