consul-client

Consul client operator

Channel Revision Published Runs on
latest/edge 7 09 Dec 2024
Ubuntu 24.04 Ubuntu 22.04
latest/edge 6 18 Oct 2024
Ubuntu 24.04 Ubuntu 22.04
1.19/stable 19 24 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/stable 5 09 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/candidate 19 23 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/candidate 5 06 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/beta 19 13 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/beta 5 18 Sep 2025
Ubuntu 24.04 Ubuntu 22.04
1.19/edge 19 10 Mar 2026
Ubuntu 24.04 Ubuntu 22.04
1.19/edge 5 18 Oct 2024
Ubuntu 24.04 Ubuntu 22.04
juju deploy consul-client --channel edge
Show information

Platform:

Ubuntu
24.04 22.04

charms.consul_client.v0.consul_notify

ConsulNotify Provides and Requires module.

This library contains Provider and Requirer classes for consul-notify interface.

The provider side offers the service of network monitoring and notification. It monitors network connectivity to servers and notifies when issues are detected.

The requirer side receives notifications about network failures and provides the socket path where it wants to receive these notifications.

Provider Example

Import ConsulNotifyProvider in your charm, with the charm object and the relation name: - self - "consul-notify"

An event is also available to respond to: - socket_available

A basic example showing the usage of the provider side:

from charms.consul_client.v0.consul_notify import (
    ConsulNotifyProvider
)

class MyProviderCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        # ConsulNotify Provider
        self.consul_notify = ConsulNotifyProvider(
            self, "consul-notify",
        )
        self.framework.observe(
            self.consul_notify.on.socket_available,
            self._on_socket_available
        )

    def _on_socket_available(self, event):
        '''React to the socket available event.

        This event happens when a requirer charm relates to this charm
        and provides its socket information.
        '''
        # Get the socket information
        snap_name = self.consul_notify.snap_name
        socket_path = self.consul_notify.unix_socket_filepath

        if snap_name and socket_path:
            # Configure TCP health check with the socket information
            # This will enable monitoring and notification
            self._configure_tcp_health_check(snap_name, socket_path)
Requirer Example

Import ConsulNotifyRequirer in your charm, with the charm object and the relation name: - self - "consul-notify"

An event is also available to respond to: - relation_ready

A basic example showing the usage of the requirer side:

from charms.consul_client.v0.consul_notify import (
    ConsulNotifyRequirer
)

class MyRequirerCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        # ConsulNotify Requires
        self.consul_notify = ConsulNotifyRequirer(
            self, "consul-notify",
        )

        # Observe the relation_ready event
        self.framework.observe(
            self.consul_notify.on.relation_ready,
            self._on_consul_notify_ready
        )

    def _on_consul_notify_ready(self, event):
        '''React to the consul-notify relation being ready.

        This event happens when the relation is created or joined.
        '''
        # Set the socket information for the provider.
        # unix_socket_filepath as the socket file name, not as an absolute path.
        self.consul_notify.set_socket_info(
            snap_name="my-service-snap",
            unix_socket_filepath="socket.sock"
        )

class SocketInfoData

Description

Socket information from the requirer. None

class SocketAvailableEvent

Description

Socket information available event. None

class SocketGoneEvent

Description

Socket information gone event. None

class ConsulNotifyProviderEvents

Description

Consul Notify provider events. None

class ConsulNotifyProvider

Description

Class to be instantiated on the provider side of the relation. None

Methods

ConsulNotifyProvider. __init__( self , charm: CharmBase , relation_name: str )

ConsulNotifyProvider. snap_name( self )

Return snap_name from requirer app data.

Returns

The name of the snap that provides the socket, or None if not available

ConsulNotifyProvider. unix_socket_filepath( self )

Return UNIX socket filepath from requirer app data.

Returns

The path to the UNIX socket file, or None if not available

ConsulNotifyProvider. is_ready( self )

Check if the relation is ready with all required data.

Returns

True if both snap_name and unix_socket_filepath are available, False otherwise

class RelationReadyEvent

Description

Relation ready event for the requirer side. None

class ConsulNotifyRequirerEvents

Description

Consul Notify requirer events. None

class ConsulNotifyRequirer

Description

Class to be instantiated on the requirer side of the relation. None

Methods

ConsulNotifyRequirer. __init__( self , charm: CharmBase , relation_name: str )

ConsulNotifyRequirer. set_socket_info( self , snap_name: str , unix_socket_filepath: str )

Set socket information on the relation.

Arguments

snap_name

The name of the snap that provides the socket

unix_socket_filepath

The path to the UNIX socket file