Module glean.net.ping_uploader
Classes
class CapablePingUploadRequest (request: glean.net.ping_upload_worker.PingUploadRequest)-
Expand source code
class CapablePingUploadRequest: def __init__(self, request: PingUploadRequest) -> None: self.request = request def capable(self, func: Callable[[List[str]], bool]) -> Optional[PingUploadRequest]: if func(self.request.uploader_capabilities): return self.request return NoneMethods
def capable(self, func: Callable[[List[str]], bool]) ‑> glean.net.ping_upload_worker.PingUploadRequest | None-
Expand source code
def capable(self, func: Callable[[List[str]], bool]) -> Optional[PingUploadRequest]: if func(self.request.uploader_capabilities): return self.request return None
class PingUploader (*args, **kwargs)-
Expand source code
class PingUploader(Protocol): def upload( self, capable_request: CapablePingUploadRequest ) -> Union[ UploadResult, UploadResult.UNRECOVERABLE_FAILURE, UploadResult.RECOVERABLE_FAILURE, UploadResult.HTTP_STATUS, UploadResult.INCAPABLE, ]: """ Upload a ping to a server. Args: capable_request (CapablePingUploadRequest): The ping upload request, locked behind a capability check. Returns: result (UploadResult): the status code of the upload response. """ passBase class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol): def meth(self) -> int: ...Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type checkSee PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto[T](Protocol): def meth(self) -> T: ...Ancestors
- typing.Protocol
- typing.Generic
Subclasses
Methods
def upload(self,
capable_request: CapablePingUploadRequest) ‑> glean._uniffi.glean.UploadResult | glean._uniffi.glean.UploadResult.UNRECOVERABLE_FAILURE | glean._uniffi.glean.UploadResult.RECOVERABLE_FAILURE | glean._uniffi.glean.UploadResult.HTTP_STATUS | glean._uniffi.glean.UploadResult.INCAPABLE-
Expand source code
def upload( self, capable_request: CapablePingUploadRequest ) -> Union[ UploadResult, UploadResult.UNRECOVERABLE_FAILURE, UploadResult.RECOVERABLE_FAILURE, UploadResult.HTTP_STATUS, UploadResult.INCAPABLE, ]: """ Upload a ping to a server. Args: capable_request (CapablePingUploadRequest): The ping upload request, locked behind a capability check. Returns: result (UploadResult): the status code of the upload response. """ passUpload a ping to a server.
Args
capable_request:CapablePingUploadRequest- The ping upload request, locked behind a capability check.
Returns
result (UploadResult): the status code of the upload response.
class UploadResult-
Expand source code
class UploadResult: def __init__(self): raise RuntimeError("UploadResult cannot be instantiated directly") # Each enum variant is a nested class of the enum itself. @dataclass class RECOVERABLE_FAILURE: def __init__(self, unused:int): self.unused = unused pass def __str__(self): return "UploadResult.RECOVERABLE_FAILURE(unused={})".format(self.unused) def __eq__(self, other): if not isinstance(other, UploadResult): return NotImplemented if not other.is_RECOVERABLE_FAILURE(): return False if self.unused != other.unused: return False return True @dataclass class UNRECOVERABLE_FAILURE: def __init__(self, unused:int): self.unused = unused pass def __str__(self): return "UploadResult.UNRECOVERABLE_FAILURE(unused={})".format(self.unused) def __eq__(self, other): if not isinstance(other, UploadResult): return NotImplemented if not other.is_UNRECOVERABLE_FAILURE(): return False if self.unused != other.unused: return False return True @dataclass class INCAPABLE: def __init__(self, unused:int): self.unused = unused pass def __str__(self): return "UploadResult.INCAPABLE(unused={})".format(self.unused) def __eq__(self, other): if not isinstance(other, UploadResult): return NotImplemented if not other.is_INCAPABLE(): return False if self.unused != other.unused: return False return True @dataclass class HTTP_STATUS: def __init__(self, code:int): self.code = code pass def __str__(self): return "UploadResult.HTTP_STATUS(code={})".format(self.code) def __eq__(self, other): if not isinstance(other, UploadResult): return NotImplemented if not other.is_HTTP_STATUS(): return False if self.code != other.code: return False return True @dataclass class DONE: def __init__(self, unused:int): self.unused = unused pass def __str__(self): return "UploadResult.DONE(unused={})".format(self.unused) def __eq__(self, other): if not isinstance(other, UploadResult): return NotImplemented if not other.is_DONE(): return False if self.unused != other.unused: return False return True # For each variant, we have `is_NAME` and `is_name` methods for easily checking # whether an instance is that variant. def is_RECOVERABLE_FAILURE(self) -> bool: return isinstance(self, UploadResult.RECOVERABLE_FAILURE) def is_recoverable_failure(self) -> bool: return isinstance(self, UploadResult.RECOVERABLE_FAILURE) def is_UNRECOVERABLE_FAILURE(self) -> bool: return isinstance(self, UploadResult.UNRECOVERABLE_FAILURE) def is_unrecoverable_failure(self) -> bool: return isinstance(self, UploadResult.UNRECOVERABLE_FAILURE) def is_INCAPABLE(self) -> bool: return isinstance(self, UploadResult.INCAPABLE) def is_incapable(self) -> bool: return isinstance(self, UploadResult.INCAPABLE) def is_HTTP_STATUS(self) -> bool: return isinstance(self, UploadResult.HTTP_STATUS) def is_http_status(self) -> bool: return isinstance(self, UploadResult.HTTP_STATUS) def is_DONE(self) -> bool: return isinstance(self, UploadResult.DONE) def is_done(self) -> bool: return isinstance(self, UploadResult.DONE)Subclasses
- glean._uniffi.glean.UploadResult.DONE
- glean._uniffi.glean.UploadResult.HTTP_STATUS
- glean._uniffi.glean.UploadResult.INCAPABLE
- glean._uniffi.glean.UploadResult.RECOVERABLE_FAILURE
- glean._uniffi.glean.UploadResult.UNRECOVERABLE_FAILURE
Class variables
var DONEvar HTTP_STATUSvar INCAPABLEvar RECOVERABLE_FAILUREvar UNRECOVERABLE_FAILURE
Methods
def is_DONE(self) ‑> bool-
Expand source code
def is_DONE(self) -> bool: return isinstance(self, UploadResult.DONE) def is_HTTP_STATUS(self) ‑> bool-
Expand source code
def is_HTTP_STATUS(self) -> bool: return isinstance(self, UploadResult.HTTP_STATUS) def is_INCAPABLE(self) ‑> bool-
Expand source code
def is_INCAPABLE(self) -> bool: return isinstance(self, UploadResult.INCAPABLE) def is_RECOVERABLE_FAILURE(self) ‑> bool-
Expand source code
def is_RECOVERABLE_FAILURE(self) -> bool: return isinstance(self, UploadResult.RECOVERABLE_FAILURE) def is_UNRECOVERABLE_FAILURE(self) ‑> bool-
Expand source code
def is_UNRECOVERABLE_FAILURE(self) -> bool: return isinstance(self, UploadResult.UNRECOVERABLE_FAILURE) def is_done(self) ‑> bool-
Expand source code
def is_done(self) -> bool: return isinstance(self, UploadResult.DONE) def is_http_status(self) ‑> bool-
Expand source code
def is_http_status(self) -> bool: return isinstance(self, UploadResult.HTTP_STATUS) def is_incapable(self) ‑> bool-
Expand source code
def is_incapable(self) -> bool: return isinstance(self, UploadResult.INCAPABLE) def is_recoverable_failure(self) ‑> bool-
Expand source code
def is_recoverable_failure(self) -> bool: return isinstance(self, UploadResult.RECOVERABLE_FAILURE) def is_unrecoverable_failure(self) ‑> bool-
Expand source code
def is_unrecoverable_failure(self) -> bool: return isinstance(self, UploadResult.UNRECOVERABLE_FAILURE)