Module hyveos_sdk.services.discovery
Classes
class DHTKey (*args, **kwargs)
-
A ProtocolMessage
Ancestors
- google._upb._message.Message
- google.protobuf.message.Message
Class variables
var DESCRIPTOR
class DiscoveryService (conn: grpc.aio._base_channel.Channel)
-
Expand source code
class DiscoveryService: """ A handle to the discovery service. Exposes methods to interact with the discovery service, like for marking the local runtime as a provider for a discovery key or getting the providers for a discovery key. """ def __init__(self, conn: Channel): self.stub = DiscoveryStub(conn) async def provide(self, topic: str, key: str | bytes) -> None: """ Marks the local runtime as a provider for a discovery key. """ await self.stub.Provide(DHTKey(topic=Topic(topic=topic), key=enc(key))) def get_providers(self, topic: str, key: str | bytes) -> ManagedStream[Peer]: """ Gets the providers for a discovery key. Returns ------- stream : ManagedStream[Peer] A stream of providers for the discovery key. """ stream = self.stub.GetProviders(DHTKey(topic=Topic(topic=topic), key=enc(key))) return ManagedStream(stream) async def stop_providing(self, topic: str, key: str | bytes) -> None: """ Stops providing a discovery key. """ await self.stub.StopProviding(DHTKey(topic=Topic(topic=topic), key=enc(key)))
A handle to the discovery service.
Exposes methods to interact with the discovery service, like for marking the local runtime as a provider for a discovery key or getting the providers for a discovery key.
Methods
def get_providers(self, topic: str, key: str | bytes) ‑> ManagedStream[bridge_pb2.Peer]
-
Expand source code
def get_providers(self, topic: str, key: str | bytes) -> ManagedStream[Peer]: """ Gets the providers for a discovery key. Returns ------- stream : ManagedStream[Peer] A stream of providers for the discovery key. """ stream = self.stub.GetProviders(DHTKey(topic=Topic(topic=topic), key=enc(key))) return ManagedStream(stream)
Gets the providers for a discovery key.
Returns
stream
:ManagedStream[Peer]
- A stream of providers for the discovery key.
async def provide(self, topic: str, key: str | bytes) ‑> None
-
Expand source code
async def provide(self, topic: str, key: str | bytes) -> None: """ Marks the local runtime as a provider for a discovery key. """ await self.stub.Provide(DHTKey(topic=Topic(topic=topic), key=enc(key)))
Marks the local runtime as a provider for a discovery key.
async def stop_providing(self, topic: str, key: str | bytes) ‑> None
-
Expand source code
async def stop_providing(self, topic: str, key: str | bytes) -> None: """ Stops providing a discovery key. """ await self.stub.StopProviding(DHTKey(topic=Topic(topic=topic), key=enc(key)))
Stops providing a discovery key.
class Peer (*args, **kwargs)
-
A ProtocolMessage
Ancestors
- google._upb._message.Message
- google.protobuf.message.Message
Class variables
var DESCRIPTOR
class Topic (*args, **kwargs)
-
A ProtocolMessage
Ancestors
- google._upb._message.Message
- google.protobuf.message.Message
Class variables
var DESCRIPTOR