mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 14:56:38 +08:00
fix(idgen): retry snowflake generation and error on negative ID
NextUint64ID now retries up to 3 times when Int64() is negative, then returns an error instead of 0 or Fatalf. All call sites propagate the error to avoid GORM omitting zero-value primary keys.
This commit is contained in:
@@ -387,8 +387,10 @@ func TestRetryTaskNonExistent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateTaskID(t *testing.T) {
|
||||
id1 := generateTaskID("test_type", "manual")
|
||||
id2 := generateTaskID("test_type", "manual")
|
||||
id1, err := generateTaskID("test_type", "manual")
|
||||
require.NoError(t, err)
|
||||
id2, err := generateTaskID("test_type", "manual")
|
||||
require.NoError(t, err)
|
||||
|
||||
// 两个 ID 应不同(包含 Snowflake ID)
|
||||
assert.NotEqual(t, id1, id2)
|
||||
|
||||
Reference in New Issue
Block a user