HashiCorp Consul integration for LegionIO. Provides runners for interacting with the Consul HTTP API covering KV store, agent management, catalog, health checks, sessions, events, and cluster status.
gem install lex-consulget_key- Read a key (supports recursive and raw modes)put_key- Write a key (supports CAS, flags, lock acquire/release)delete_key- Delete a key (supports recursive delete and CAS)list_keys- List keys by prefix
self_info- Read agent configurationmembers- List cluster membersjoin- Join a node to the clusterleave- Graceful leaveforce_leave- Force remove a nodereload- Reload agent configurationmaintenance- Enable/disable maintenance mode
datacenters- List known datacentersnodes- List catalog nodesservices- List catalog servicesservice- List nodes for a servicenode- Get services on a noderegister- Register a node/service/checkderegister- Deregister a node/service/check
node_health- Health checks for a nodeservice_checks- Checks for a serviceservice_health- Healthy service instanceschecks_in_state- Checks by state (passing/warning/critical)connect_health- Mesh-capable service instances
create_session- Create a session (for distributed locks)destroy_session- Destroy a sessionsession_info- Read session detailslist_sessions- List all sessionsnode_sessions- List sessions for a noderenew_session- Renew a session TTL
fire_event- Fire a custom eventlist_events- List recent events
leader- Get Raft leader addresspeers- List Raft peer addresses
list_partitions- List all admin partitionsget_partition- Get a partition by namecreate_partition- Create or update a partitiondelete_partition- Delete a partition
require 'legion/extensions/consul'
client = Legion::Extensions::Consul::Client.new(
url: 'http://consul.example.com:8500',
token: 'my-consul-token'
)
# KV operations
client.put_key(key: 'config/db/host', value: 'db.example.com')
client.get_key(key: 'config/db/host')
client.list_keys(prefix: 'config/')
# Service discovery
client.services
client.service_health(service: 'web', passing: true)
# Cluster status
client.leader
client.members- Ruby >= 3.4
- LegionIO framework (optional for standalone client usage)
- HashiCorp Consul cluster (any version with HTTP API v1)
faraday>= 2.0
MIT