def test_overrides_default_hostname_if_provided(self,
                                                    secure_channel_mock: Mock):
        hostname = str(uuid4())

        create_secure_channel(hostname=hostname)

        secure_channel_call = secure_channel_mock.mock_calls[0]
        assert secure_channel_call.args[0] == f"{hostname}:{DEFAULT_PORT}"
    def test_overrides_default_port_if_provided(self,
                                                secure_channel_mock: Mock):
        port = 123

        create_secure_channel(port=port)

        secure_channel_call = secure_channel_mock.mock_calls[0]
        assert secure_channel_call.args[0] == f"{DEFAULT_HOSTNAME}:{port}"
Ejemplo n.º 3
0
    return job


# Will use environment variable ZEEBE_ADDRESS or localhost:26500 and NOT use TLS
# create_insecure_channel returns a grpc.aio.Channel instance. If needed you
# can build one on your own
grpc_channel = create_insecure_channel()
worker = ZeebeWorker(grpc_channel)

# With custom hostname/port
grpc_channel = create_insecure_channel(hostname="zeebe-gateway.mydomain",
                                       port=443)
worker = ZeebeWorker(grpc_channel)

# Will use environment variable ZEEBE_ADDRESS or localhost:26500 and use TLS
grpc_channel = create_secure_channel()
worker = ZeebeWorker(grpc_channel)

# With custom hostname/port
grpc_channel = create_secure_channel(hostname="zeebe-gateway.mydomain",
                                     port=443)
worker = ZeebeWorker(grpc_channel)

# Connect to zeebe cluster in camunda cloud
grpc_channel = create_camunda_cloud_channel(
    client_id="<my_client_id>",
    client_secret="<my_client_secret>",
    cluster_id="<my_cluster_id>",
    region="<region>"  # Default value is bru-2
)
worker = ZeebeWorker(grpc_channel)
Ejemplo n.º 4
0
from pyzeebe import (ZeebeClient, create_camunda_cloud_channel,
                     create_insecure_channel, create_secure_channel)

# Create a zeebe client without credentials
grpc_channel = create_insecure_channel(hostname="localhost", port=26500)
zeebe_client = ZeebeClient(grpc_channel)

# Create a zeebe client with TLS
grpc_channel = create_secure_channel()
zeebe_client = ZeebeClient(grpc_channel)

# Create a zeebe client for camunda cloud
grpc_channel = create_camunda_cloud_channel(
    client_id="<my_client_id>",
    client_secret="<my_client_secret>",
    cluster_id="<my_cluster_id>",
    region="<region>" # Default is bru-2
)
zeebe_client = ZeebeClient(grpc_channel)

# Run a Zeebe instance process
process_instance_key = await zeebe_client.run_process(
    bpmn_process_id="My zeebe process", variables={}
)

# Run a Zeebe process instance and receive the result
process_instance_key, process_result = await zeebe_client.run_process_with_result(
    bpmn_process_id="My zeebe process", timeout=10000
)  # Will wait 10000 milliseconds (10 seconds)

# Deploy a bpmn process definition
    def test_uses_default_address(self, secure_channel_mock: Mock):
        create_secure_channel()

        secure_channel_call = secure_channel_mock.mock_calls[0]
        assert secure_channel_call.args[0] == create_address()
    def test_calls_using_default_grpc_options(self, secure_channel_mock: Mock):
        create_secure_channel()

        secure_channel_call = secure_channel_mock.mock_calls[0]
        assert secure_channel_call.kwargs["options"] == get_channel_options()
    def test_uses_ssl_credentials_if_no_channel_credentials_provided(self):
        with patch("grpc.ssl_channel_credentials") as ssl_mock:
            create_secure_channel()

        ssl_mock.assert_called_once()
    def test_returns_grpc_channel(self):
        channel = create_secure_channel()

        assert isinstance(channel, grpc.aio.Channel)