Chaski Confluent: Scripts

Environment Variable Setup Script

This script configures essential environment variables required for the proper functioning of Chaski Confluent services. Below is a summary of the variables and their purposes:

  • ``CHASKI_STREAMER_ROOT``: Specifies the address of the root streamer, which acts as the central node for communication.

  • ``CHASKI_CERTIFICATE_AUTHORITY``: Points to the address of the Certificate Authority responsible for managing SSL/TLS certificates.

  • ``CHASKI_REMOTE_PROXY``: Defines the address of the remote proxy used for routing external communications.

  • ``CHASKI_CELERY_BACKEND``: Configures the backend for Celery task management, using the Chaski protocol.

  • ``CHASKI_CELERY_BROKER``: Sets the broker address for Celery to handle message passing and task distribution.

Example: Connecting a Streamer Node Using CHASKI_STREAMER_ROOT

A streamer node can connect to the root node specified in the CHASKI_STREAMER_ROOT environment variable. The following script demonstrates this:

```python import os from chaski.streamer import ChaskiStreamer

Create the streamer node

streamer = ChaskiStreamer( ip=’127.0.0.1’, port=65434, name=’StreamerNode’, subscriptions=[‘topic1’], )

Connect to the root node

streamer.connect(os.getenv(‘CHASKI_STREAMER_ROOT’)

print(“Streamer connected.”)

Example: Streamer Node with SSL Certificate Integration

The following example demonstrates how to configure a producer node with SSL certificate support using the `CHASKI_CERTIFICATE_AUTHORITY` environment variable. The node can request the SSL certificate either inline or after initialization.

Inline SSL Certificate Request

The SSL certificate is requested during the initialization of the producer node:

import os
from chaski.streamer import ChaskiStreamer

producer = ChaskiStreamer(
    port=65433,
    name='Producer',
    subscriptions=['topic1'],
    reconnections=None,
    ssl_certificates_location='certs_ca',
    request_ssl_certificate=os.getenv('CHASKI_CERTIFICATE_AUTHORITY'),
)

print("Producer initialized with SSL certificate.")

Post-initialization SSL Certificate Request

The SSL certificate is requested after the node is initialized:

import os
from chaski.streamer import ChaskiStreamer

producer = ChaskiStreamer(
    name='Producer',
    subscriptions=['topic1'],
    reconnections=None,
    ssl_certificates_location='certs_ca',
)

# Request the SSL certificate
await producer.request_ssl_certificate(os.getenv('CHASKI_CERTIFICATE_AUTHORITY'))

print("SSL certificate requested and applied to Producer.")

Both approaches ensure the producer node is configured for secure communication with the Certificate Authority.