Skip to main content

a3consul

English | 简体中文

a3consul is a simple wrapper around py-consul to make it easier to use.

1. Introduction

  • Provide encapsulation for Node Discovery.

2. Usage

Install

pip install a3consul

Examples: Node Discovery

  • Node
from a3consul.scene_cases.node_discovery.node import Node

if __name__ == '__main__':
    node_conf = {
        "topic": "unittest",
        "node_path": "/nodes/",
        "init": {
            "host": "127.0.0.1",
            "port": 8500,
        },
        "session": {
            "ttl": 10,
        },
        "renew": {
            "sleep_seconds": 5,
            "timeout_seconds": 20,
        },
    }
    node = Node(conf=node_conf)
    node_id = node.register_node_id()
    node.start_renew_thread()
    node.close()
  • NodeWatcher
from typing import Set
from a3consul.scene_cases.node_discovery.node_watcher import NodeWatcher


class MyNodeWatcher(NodeWatcher):
    def _on_change(self, online_node_id_set: Set[str], offline_node_id_set: Set[str]):
        # do something
        pass

    def _handle_first_node_id_set(self, node_id_set: Set[str]):
        # kick or keep them or do something else
        pass


if __name__ == '__main__':
    watcher_conf = {
        "init": {
            "host": "127.0.0.1",
            "port": 8500,
        },
        "node_path": "/nodes/",
    }
    watcher = MyNodeWatcher(conf=watcher_conf)
    watcher.start()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a3consul-0.3.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a3consul-0.3.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file a3consul-0.3.0.tar.gz.

File metadata

  • Download URL: a3consul-0.3.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for a3consul-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c08d1a48dc5f0c5e2498bc27859349ce6eda0a60f485a34f7530d4088e3d26e3
MD5 64fc4502809c4bbd9e5cbe6e7ba2d56f
BLAKE2b-256 98ac3b5696ebf6d7d2c5d48497051938a14073f197c2dd223801efedc1db0136

See more details on using hashes here.

File details

Details for the file a3consul-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: a3consul-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for a3consul-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4faaabc529c3298b6c17a8d3312981dd714023f71dacc74a351b8727c3bfa0c6
MD5 631b97fcc417e493a35b333a66afb970
BLAKE2b-256 0f5f62f6c866dec0547d8be3d0f37fe63ee1343ffaf2429941faf681fa3295a4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page