Files
2022-12-28 07:54:21 +01:00

22 lines
462 B
Python

import time
import consul
# Connect to the Consul cluster
client = consul.Consul()
# Continuously register and deregister a service
while True:
# Register the service
client.agent.service.register(
"stress-test-service",
port=8080,
tags=["stress-test"],
check=consul.Check().tcp("localhost", 8080, "10s")
)
# Deregister the service
client.agent.service.deregister("stress-test-service")
time.sleep(1)