farm-ng-core
core.event_client.EventClient Class Reference

Public Member Functions

None __init__ (self, EventServiceConfig config)
 
EventServiceConfig config (self)
 
EventServiceHealthMetrics metrics (self)
 
logging.Logger logger (self)
 
str server_address (self)
 
AsyncIterator[tuple[Event, Message|bytes]] subscribe (self, SubscribeRequest request, bool decode=True)
 
list[Uri] list_uris (self)
 
RequestReplyReply request_reply (self, str path, Message message, list[Timestamp]|None timestamps=None)
 

Public Attributes

 channel
 
 stub
 

Detailed Description

Generic client class to connect with the Amiga brain services.

Internally implements an `asyncio` gRPC channel that is designed to be imported
by service specific clients.

Constructor & Destructor Documentation

◆ __init__()

None core.event_client.EventClient.__init__ (   self,
EventServiceConfig  config 
)
Initializes the client.

Args:
    config (EventServiceConfig): the grpc configuration data structure.

Raises:
    ValueError: if the port or host are invalid.

Member Function Documentation

◆ config()

EventServiceConfig core.event_client.EventClient.config (   self)
Returns the configuration data structure.

◆ list_uris()

list[Uri] core.event_client.EventClient.list_uris (   self)
Returns the list of uris.

Returns:
    list[Uri]: the list of uris.

◆ logger()

logging.Logger core.event_client.EventClient.logger (   self)
Returns the logger.

◆ metrics()

EventServiceHealthMetrics core.event_client.EventClient.metrics (   self)
Returns the metrics data structure.

◆ request_reply()

RequestReplyReply core.event_client.EventClient.request_reply (   self,
str  path,
Message  message,
list[Timestamp] | None   timestamps = None 
)
Sends a request and waits for a reply.

Args:
    path (str): the path of the request.
    message (Message): the message to send.
    timestamps (list[Timestamp], optional): the timestamps to add to the event.

Returns:
    ReqRepReply: the reply.

◆ server_address()

str core.event_client.EventClient.server_address (   self)
Returns the composed address and port.

◆ subscribe()

AsyncIterator[tuple[Event, Message | bytes]] core.event_client.EventClient.subscribe (   self,
SubscribeRequest  request,
bool   decode = True 
)
Subscribes to the server.

Args:
    request (SubscribeRequest): the subscription request.
    decode (bool, optional): if True, the payload will be decoded. Defaults to True.

Yields:
    tuple[Event, Message | bytes]: the event and the payload.

Member Data Documentation

◆ channel

core.event_client.EventClient.channel

◆ stub

core.event_client.EventClient.stub

The documentation for this class was generated from the following file: