|
13 | 13 |
|
14 | 14 |
|
15 | 15 | _RetryRule = namedtuple("_RetryRule", ["attempts", "backoff"])
|
| 16 | +TAG_NAME = "tag" |
16 | 17 |
|
17 | 18 |
|
18 | 19 | def default_backoff(attempt):
|
@@ -414,17 +415,25 @@ def without_globals(self, *global_names):
|
414 | 415 | )
|
415 | 416 | return result
|
416 | 417 |
|
417 |
| - def with_annotation(self, name: str, value: str): |
| 418 | + def with_query_tag(self, tag: str): |
| 419 | + for prefix in ["edgedb/", "gel/"]: |
| 420 | + if tag.startswith(prefix): |
| 421 | + raise errors.InvalidArgumentError(f"reserved tag: {prefix}*") |
| 422 | + if len(tag) > 128: |
| 423 | + raise errors.InvalidArgumentError( |
| 424 | + "tag too long (> 128 characters)" |
| 425 | + ) |
| 426 | + |
418 | 427 | result = self._shallow_clone()
|
419 | 428 | result._options = self._options.with_annotations(
|
420 |
| - self._options.annotations | {name: value} |
| 429 | + self._options.annotations | {TAG_NAME: tag} |
421 | 430 | )
|
422 | 431 | return result
|
423 | 432 |
|
424 |
| - def without_annotation(self, name: str): |
| 433 | + def without_query_tag(self): |
425 | 434 | result = self._shallow_clone()
|
426 | 435 | annotations = self._options.annotations.copy()
|
427 |
| - annotations.pop(name, None) |
| 436 | + annotations.pop(TAG_NAME, None) |
428 | 437 | result._options = self._options.with_annotations(annotations)
|
429 | 438 | return result
|
430 | 439 |
|
|
0 commit comments