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()

Metadata

Release files for a3consul 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a3consul 0.3.0
File Size Uploaded
a3consul-0.3.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a3consul 0.3.0
File Interpreter ABI Platform
a3consul-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / a3consul-0.3.0.tar.gz

Download URL a3consul-0.3.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c08d1a48dc5f0c5e2498bc27859349ce6eda0a60f485a34f7530d4088e3d26e3
BLAKE2b-256 checksum
How to use checksums
98ac3b5696ebf6d7d2c5d48497051938a14073f197c2dd223801efedc1db0136
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / a3consul-0.3.0-py3-none-any.whl

Download URL a3consul-0.3.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4faaabc529c3298b6c17a8d3312981dd714023f71dacc74a351b8727c3bfa0c6
BLAKE2b-256 checksum
How to use checksums
0f5f62f6c866dec0547d8be3d0f37fe63ee1343ffaf2429941faf681fa3295a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page