File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,11 @@ class Region:
43
43
"""The region's category."""
44
44
45
45
def __post_init__ (self ) -> None :
46
- from sentry .utils .snowflake import REGION_ID
46
+ from sentry .utils .snowflake import NULL_REGION_ID , REGION_ID
47
47
48
48
REGION_ID .validate (self .id )
49
+ if self .id == NULL_REGION_ID :
50
+ raise ValueError (f"Region ID { NULL_REGION_ID } is reserved for non-multi-region systems" )
49
51
50
52
def to_url (self , path : str ) -> str :
51
53
return self .address + path
Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ def validate(self, value):
61
61
MAX_AVAILABLE_REGION_SEQUENCES = 1 << REGION_SEQUENCE .length
62
62
assert MAX_AVAILABLE_REGION_SEQUENCES > 0
63
63
64
+ NULL_REGION_ID = 0
65
+
64
66
65
67
def msb_0_ordering (value , width ):
66
68
"""
@@ -80,7 +82,7 @@ def generate_snowflake_id(redis_key: str) -> int:
80
82
try :
81
83
segment_values [REGION_ID ] = get_local_region ().id
82
84
except RegionContextError : # expected if running in monolith mode
83
- segment_values [REGION_ID ] = 0
85
+ segment_values [REGION_ID ] = NULL_REGION_ID
84
86
85
87
current_time = datetime .now ().timestamp ()
86
88
# supports up to 130 years
You can’t perform that action at this time.
0 commit comments