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

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



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

Vertical scaling:
processBits: 6, serverBits: 1, sequenceBits: 20
This will support upto 64 processes.
// NewUint32Config makes reasonable Uint32Config from the arguments provided // // sequenceBits is greedy parameter and will be set to the maximum value when possible . // // Examples : // // * Horizontal scaling : // processBits : 5 serverBits : 10 sequenceBits 12 // This will support upto 32 processes and 1024 servers . // // * Vertical scaling : // processBits : 6 serverBits : 1 sequenceBits : 20 // This will support upto 64 processes .
func NewUint32Config(serverBits, processBits, sequenceBits uint32) Uint32Config {
	if processBits < minUint32ProcessBits {
		processBits = minUint32ProcessBits
	}
	if serverBits < minUint32ServerBits {
		serverBits = minUint32ServerBits
	}
	if sequenceBits < minUint32SequenceBits {
		sequenceBits = minUint32ServerBits
	}
	if processBits+serverBits+sequenceBits > totalUint32Bits {
		processBits = defaultUint32ProcessBits
		serverBits = defaultUint32ServerBits
		sequenceBits = defaultUint32SequenceBits
	} else if processBits+serverBits+sequenceBits < totalUint32Bits {
		sequenceBits = totalUint32Bits - processBits - serverBits
	}
	var (
		now         = time.Now()
		epoch       = uint32(now.Unix())
		customEpoch = uint32(now.Unix()) - epoch
	)
	return Uint32Config{
		Epoch:        epoch,
		CustomEpoch:  customEpoch,
		LastTime:     0,
		Sequence:     0,
		ProcessBits:  processBits,
		ServerBits:   serverBits,
		SequenceBits: sequenceBits,
		Mutex:        &sync.Mutex{},
	}
}
func NewUint32Config ( serverBits , processBits , sequenceBits uint32 ) Uint32Config { if processBits < minUint32ProcessBits { processBits = minUint32ProcessBits } if serverBits < minUint32ServerBits { serverBits = minUint32ServerBits } if sequenceBits < minUint32SequenceBits { sequenceBits = minUint32ServerBits } if processBits + serverBits + sequenceBits > totalUint32Bits { processBits = defaultUint32ProcessBits serverBits = defaultUint32ServerBits sequenceBits = defaultUint32SequenceBits } else if processBits + serverBits + sequenceBits < totalUint32Bits { sequenceBits = totalUint32Bits - processBits - serverBits } var ( now = time . Now ( ) epoch = uint32 ( now . Unix ( ) ) customEpoch = uint32 ( now . Unix ( ) ) - epoch ) return Uint32Config { Epoch : epoch , CustomEpoch : customEpoch , LastTime : 0 , Sequence : 0 , ProcessBits : processBits , ServerBits : serverBits , SequenceBits : sequenceBits , Mutex : & sync . Mutex { } , } }
NewUint32Config makes reasonable Uint32Config from the arguments provided.
NewUint32Config makes reasonable Uint32Config from the arguments provided .
// max out bits for sequenceBits