exn-connector-python/Readme.md
Fotis Paraskevopoulos 19bdfeea69 Initial commit
Change-Id: I03c605dfaa884b6c7aab3e52259855eb2110fac5
2023-12-14 23:22:00 +02:00

3.0 KiB

Of course, let's integrate everything into a cohesive guide.


Using the exn Module: A Comprehensive Guide

The exn module serves as a connector, enabling communication between various components in a messaging infrastructure. This guide will take you through the basics to advanced usage of the module.

Overview

  • Core Components:
    • Bootstrap: A foundational class setting up the readiness state.
    • CoreHandler: Manages connection start, message reception, and timed tasks.
    • EXN: Main connector class initializing connections and configurations.

Basic Usage

  1. Initialize the EXN class:

    connector = connector.EXN('ui', bootstrap=Bootstrap())
    
  2. Run the connector to start:

    connector.start()
    

Advanced Usage

1. Enabling Health and State Monitoring

The EXN class offers two flags: enable_health and enable_state.

  • enable_health: Enables a scheduled publisher that sends a health-check ping at regular intervals.
  • enable_state: Activates the StatePublisher to manage and signal the lifecycle states of the component.

Gradual Implementation:

a. Basic Setup (No Flags):

```python
connector = connector.EXN('ui', bootstrap=Bootstrap())
```

b. Health Monitoring:

```python
connector = connector.EXN('ui', bootstrap=Bootstrap(), enable_health=True)
```

c. Lifecycle State Monitoring:

```python
connector = connector.EXN('ui', bootstrap=Bootstrap(), enable_health=True, enable_state=True)
```

2. The ready Function

The ready function in your Bootstrap class is called when the component is initialized. Use it to perform specific operations at startup:

Example:

def ready(self, context):
    if context.has_publisher('state'):
        context.publishers['state'].starting()

3. The Importance of the 'key' Argument

Each publisher is identified using a unique 'key', which is crucial when handling multiple publishers:

Example:

context.publishers['state'].starting()

Here, 'state' is the 'key' for a specific publisher, directing it to send a 'starting' signal.

Working with Context

The Context class in the core section aids in managing publishers and consumers within the application. Here's how:

  • Register a publisher:

    context.register_publisher(publisher)
    
  • Check if a publisher exists:

    context.has_publisher('key')
    
  • Build an address from a link:

    context.build_address_from_link(link)
    

Conclusion

The exn module provides a robust platform for component communication, health and lifecycle management, and more. Whether you're looking for simple connectivity or advanced message routing with multiple publishers, this module has got you covered.


This documentation offers an inclusive overview and guide for the exn module. Tailor it as per your specific project requirements or as the module evolves.