Skip to main content
Version: 1.5.0

Consul

Distributed Storebackend/consul

Consul is a service discovery and configuration management tool. It provides a distributed key-value store that's perfect for configuration management and service coordination in microservices architectures.

📦 Installation

go get github.com/azrod/kivigo/backend/consul

Requires a running Consul server or cluster. Consul provides strong consistency guarantees through the Raft consensus algorithm.

Dependencies

  • Consul server (version 1.8+)
  • Network connectivity to Consul cluster

✨ Features

Basic Operations
Batch Operations
Health Checks
Persistence
Multi-DC Support
ACLs
Watches
Service Discovery

🚀 Usage

package main

import (
"github.com/azrod/kivigo"
"github.com/azrod/kivigo/backend/consul"
)

func main() {
// Basic configuration
opt := consul.DefaultOptions()
opt.Address = "localhost:8500"

// Custom configuration with auth
customOpt := &consul.Config{
Address: "consul.example.com:8500",
Token: "your-acl-token",
Scheme: "https",
Datacenter: "dc1",
}

// Create backend
kvStore, err := consul.New(customOpt)
if err != nil {
panic(err)
}
defer kvStore.Close()

// Create client
client, err := kivigo.New(kvStore)
if err != nil {
panic(err)
}
}

📝 Notes

  • Consul provides strong consistency through Raft consensus
  • All writes go through the leader, reads can be eventually consistent
  • Use ACL tokens for production security
  • Consul supports multi-datacenter deployments
  • Consider using Consul Connect for service mesh capabilities

🔗 Additional Resources