-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: add TopologyRequest
Showing
11 changed files
with
173 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from pyzeebe.grpc_internals.zeebe_cluster_adapter import ZeebeClusterAdapter | ||
from pyzeebe.grpc_internals.zeebe_job_adapter import ZeebeJobAdapter | ||
from pyzeebe.grpc_internals.zeebe_message_adapter import ZeebeMessageAdapter | ||
from pyzeebe.grpc_internals.zeebe_process_adapter import ZeebeProcessAdapter | ||
|
||
|
||
# Mixin class | ||
class ZeebeAdapter(ZeebeProcessAdapter, ZeebeJobAdapter, ZeebeMessageAdapter): | ||
class ZeebeAdapter(ZeebeClusterAdapter, ZeebeProcessAdapter, ZeebeJobAdapter, ZeebeMessageAdapter): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import annotations | ||
|
||
import grpc | ||
|
||
from pyzeebe.grpc_internals.zeebe_adapter_base import ZeebeAdapterBase | ||
from pyzeebe.proto.gateway_pb2 import TopologyRequest | ||
from pyzeebe.proto.gateway_pb2 import TopologyResponse as TopologyResponseStub | ||
|
||
from .types import TopologyResponse | ||
|
||
|
||
class ZeebeClusterAdapter(ZeebeAdapterBase): | ||
async def topology(self) -> TopologyResponse: | ||
try: | ||
response: TopologyResponseStub = await self._gateway_stub.Topology(TopologyRequest()) | ||
except grpc.aio.AioRpcError as grpc_error: | ||
await self._handle_grpc_error(grpc_error) | ||
|
||
return TopologyResponse( | ||
brokers=[ | ||
TopologyResponse.BrokerInfo( | ||
node_id=broker.nodeId, | ||
host=broker.host, | ||
port=broker.port, | ||
partitions=[ | ||
TopologyResponse.BrokerInfo.Partition( | ||
partition_id=partition.partitionId, | ||
role=TopologyResponse.BrokerInfo.Partition.PartitionBrokerRole(partition.role), | ||
health=TopologyResponse.BrokerInfo.Partition.PartitionBrokerHealth(partition.health), | ||
) | ||
for partition in broker.partitions | ||
], | ||
version=broker.version, | ||
) | ||
for broker in response.brokers | ||
], | ||
cluster_size=response.clusterSize, | ||
partitions_count=response.partitionsCount, | ||
replication_factor=response.replicationFactor, | ||
gateway_version=response.gatewayVersion, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from pyzeebe import ZeebeClient | ||
|
||
|
||
@pytest.mark.e2e | ||
async def test_topology(zeebe_client: ZeebeClient): | ||
topology = await zeebe_client.topology() | ||
|
||
assert topology.cluster_size == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
|
||
from pyzeebe.grpc_internals.types import TopologyResponse | ||
from pyzeebe.grpc_internals.zeebe_adapter import ZeebeAdapter | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestTopology: | ||
async def test_response_is_of_correct_type(self, zeebe_adapter: ZeebeAdapter): | ||
response = await zeebe_adapter.topology() | ||
|
||
assert isinstance(response, TopologyResponse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters