hololinked.server.zmq.brokers.AsyncZMQClient
Bases: BaseZMQClient, BaseAsyncZMQ
Async ZMQ client (asyncio compatible) that connect with a ZMQ server. Implements REQ-REP pattern.
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 | |
Functions
__init__
__init__(id: str, server_id: str, context: Context | None = None, access_point: str = ZMQ_TRANSPORTS.IPC, handshake: bool = True, **kwargs) -> None
Initialize the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Unique id of the client to receive messages from the server. Each client connecting to same server must still have unique ID. |
required |
|
str
|
The server id to connect to |
required |
|
Context | None
|
ZeroMQ Context object to use. If None, a global context is used. |
None
|
|
str
|
Use |
IPC
|
|
bool
|
When true, handshake with the server first before receiving any other message and block until that handshake was accomplished, highly recommended. |
True
|
|
Additional arguments:
|
{}
|
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_execute
async
async_execute(thing_id: str, objekt: str, operation: str, payload: SerializableData = SerializableNone, preserialized_payload: PreserializedData = PreserializedEmptyByte, server_execution_context: SchedulerExecutionContext | dict[str, Any] = default_scheduler_execution_context, thing_execution_context: ThingExecutionContext | dict[str, Any] = default_thing_execution_context) -> ResponseMessage
Send an operation and receive the response for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
|
required |
|
str
|
name of property, action or event (usually only property or action) |
required |
|
str
|
operation to be performed, like |
required |
|
SerializableData
|
serializable data to be sent as payload |
SerializableNone
|
|
PreserializedData
|
pre-encoded data to be sent as payload, generally used for large or custom data that is already serialized |
PreserializedEmptyByte
|
|
SchedulerExecutionContext | dict[str, Any]
|
Specify server level execution context like |
default_scheduler_execution_context
|
|
ThingExecutionContext | dict[str, Any]
|
Specify thing level execution context like |
default_thing_execution_context
|
Returns:
| Type | Description |
|---|---|
ResponseMessage
|
response message from server after completing the operation |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_recv_response
async
Receives response from server.
Messages are identified by message id, and out of order messages are sent to a cache which may be popped
later. This method blocks until the expected message is received or stop_polling() is called from another
thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
the message id of the expected response message |
required |
Returns:
| Name | Type | Description |
|---|---|---|
response_message |
ResponseMessage
|
the response message matching the given message id |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_send_request
async
async_send_request(thing_id: str, objekt: str, operation: str, payload: SerializableData = SerializableNone, preserialized_payload: PreserializedData = PreserializedEmptyByte, server_execution_context: SchedulerExecutionContext | dict[str, Any] = default_scheduler_execution_context, thing_execution_context: ThingExecutionContext | dict[str, Any] = default_thing_execution_context) -> str
Send request message to server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
|
required |
|
str
|
name of property, action or event (usually only property or action) |
required |
|
str
|
operation to be performed, like |
required |
|
SerializableData
|
serializable data to be sent as payload |
SerializableNone
|
|
PreserializedData
|
pre-encoded data to be sent as payload, generally used for large or custom data that is already serialized |
PreserializedEmptyByte
|
|
SchedulerExecutionContext | dict[str, Any]
|
Specify server level execution context like |
default_scheduler_execution_context
|
|
ThingExecutionContext | dict[str, Any]
|
Specify thing level execution context like |
default_thing_execution_context
|
Returns:
| Type | Description |
|---|---|
bytes
|
a message id in bytes |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handshake
Schedules a handshake coroutine in the running event loop or completes handshake synchronously if no event loop is running.
Use handshake_complete() async method to check if handshake is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int | None
|
timeout in milliseconds to wait for handshake to complete. If handshake does not complete within this time,
a |
60000
|
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handshake_complete
async
Wait for handshake to complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float | int
|
timeout in milliseconds to wait for handshake to complete. If handshake does not complete within this time,
a |
60000
|
Raises:
| Type | Description |
|---|---|
TimeoutError
|
if handshake does not complete within the specified timeout |