// NewUint64Config makes reasonable Unt64Config from the arguments passed,
//
// sequenceBits is greedy parameter and will be set to the maximum value when possible.
//
// Examples:
//
// * Horizontal scaling:
//   processBits: 5, serverBits: 10, sequenceBits 24
//   This will support upto 32 processes and 1024 servers.
//
// * Vertical scaling:
//   processBits: 6, serverBits: 1, sequenceBits: 20
//   This will support upto 64 processes.
NewUint64Config makes reasonable Unt64Config from the arguments passed.

sequenceBits is greedy parameter and will be set to the maximum value when possible.



Horizontal scaling:
processBits: 5, serverBits: 10, sequenceBits 24
This will support upto 32 processes and 1024 servers.

Vertical scaling:
processBits: 6, serverBits: 1, sequenceBits: 20
This will support upto 64 processes.
// NewUint64Config makes reasonable Unt64Config from the arguments passed // // sequenceBits is greedy parameter and will be set to the maximum value when possible . // // Examples : // // * Horizontal scaling : // processBits : 5 serverBits : 10 sequenceBits 24 // This will support upto 32 processes and 1024 servers . // // * Vertical scaling : // processBits : 6 serverBits : 1 sequenceBits : 20 // This will support upto 64 processes .
func NewUint64Config(serverBits, processBits, sequenceBits uint64) Uint64Config {
	if processBits < minUint64ProcessBits {
		processBits = minUint64ProcessBits
	}
	if serverBits < minUint64ServerBits {
		serverBits = minUint64ServerBits
	}
	if sequenceBits < minUint64SequenceBits {
		sequenceBits = minUint64SequenceBits
	}
	if processBits+serverBits+sequenceBits > totalUint64Bits {
		processBits = defaultUint64ProcessBits
		serverBits = defaultUint64ServerBits
		sequenceBits = defaultUint64SequenceBits
	} else if processBits+serverBits+sequenceBits < totalUint64Bits {
		sequenceBits = totalUint64Bits - processBits - serverBits
	}
	var (
		now         = time.Now()
		epoch       = uint64(now.Unix())
		customEpoch = uint64(now.Unix()) - epoch
	)
	return Uint64Config{
		Epoch:        epoch,
		CustomEpoch:  customEpoch,
		LastTime:     0,
		Sequence:     0,
		ProcessBits:  processBits,
		ServerBits:   serverBits,
		SequenceBits: sequenceBits,
		Mutex:        &sync.Mutex{},
	}
}
func NewUint64Config ( serverBits , processBits , sequenceBits uint64 ) Uint64Config { if processBits < minUint64ProcessBits { processBits = minUint64ProcessBits } if serverBits < minUint64ServerBits { serverBits = minUint64ServerBits } if sequenceBits < minUint64SequenceBits { sequenceBits = minUint64SequenceBits } if processBits + serverBits + sequenceBits > totalUint64Bits { processBits = defaultUint64ProcessBits serverBits = defaultUint64ServerBits sequenceBits = defaultUint64SequenceBits } else if processBits + serverBits + sequenceBits < totalUint64Bits { sequenceBits = totalUint64Bits - processBits - serverBits } var ( now = time . Now ( ) epoch = uint64 ( now . Unix ( ) ) customEpoch = uint64 ( now . Unix ( ) ) - epoch ) return Uint64Config { Epoch : epoch , CustomEpoch : customEpoch , LastTime : 0 , Sequence : 0 , ProcessBits : processBits , ServerBits : serverBits , SequenceBits : sequenceBits , Mutex : & sync . Mutex { } , } }
NewUint64Config makes reasonable Unt64Config from the arguments passed.
NewUint64Config makes reasonable Unt64Config from the arguments passed .
// max out bits for sequenceBits