Skip to content

Instantly share code, notes, and snippets.

# [ANN] Consul 0.2 Release
We released Consul 0.1 exactly two weeks ago, and today we are releasing 0.2.
This is a very exciting release for a few reasons:
* Release of the Web UI. Consul now ships with an easy to use interface that
gives access to all the key information. We have a live demo running across
3 datacenters here: http://demo.consul.io/
* New read consistency modes. After feedback from the community, we introduced
1) Create table "kvs"
2) Create table "kvs_id_idx"
3) For insert:
a) Insert into kvs (rowid, data blob)
b) Insert into kvs_id_idx (key, rowid)
4) For delete:
a) Iterate across kvs_id_idx
b) Delete kvs where rowid matches
Prefix: fb40ef7c-9d4d-b23d-f6fc-a14777c327e7
Inserting:
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/b1b6da9a-6edc-26ce-8b0e-685fa9806556
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/71b7ce26-4bb6-861f-5778-471d6e640018
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/9aba39af-8c5a-b7e4-3e8c-f3e6ff723cc2
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/e5f4f847-2283-9ec8-69b9-6d1209f69c4a
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/9898fd19-a66b-d945-f989-a4f5c0fefed1
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/e807189e-b547-d123-dbdd-b5a88e8bfbd6
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/f1b741bb-6ecf-3df0-7f96-c1f6b1b3b75c
fb40ef7c-9d4d-b23d-f6fc-a14777c327e7/ccb34cbb-59f0-31fb-bf5b-bd44163329c7
package main
import (
"bytes"
"fmt"
"github.com/armon/gomdb"
"github.com/ugorji/go/codec"
"reflect"
"strings"
"sync/atomic"

Consul Consistency

As Kyle brought up, Consul at the moment has a single known case of a potential inconsistency (Could be unknown cases lurking). Currently Consul works by electing a leader, who "leases" the position for LeaderLeaseTimeout interval. At each interval, it checks that a quorum of nodes still believes it to be the leader. At the same time, if a follower does not hear from the leader within randomInterva(HeartbeatTimeout, 2 * HeartbeatTimeout), it will start a new election.

package main
import (
"encoding/binary"
"github.com/armon/gomdb"
)
func main() {
// Create the env
env, err := mdb.NewEnv()
def unicode_hammer(s):
if !isinstance(s, unicode):
return s
for enc in ("utf-8","utf-16", "utf-32", "latin-1"):
try:
return s.encode(enc, "replace")
except:
pass
return s
#!/bin/sh
#
# This script installs and configures the Serf agent that runs on
# every node. As with the other scripts, this should probably be done with
# formal configuration management, but a shell script is simple as well.
#
# The SERF_ROLE environmental variable must be passed into this script
# in order to set the role of the machine. This should be either "lb" or
# "web".
#
package main
import (
"crypto/tls"
"fmt"
"github.com/inconshreveable/muxado"
"log"
"net"
)
package main
import (
"fmt"
"github.com/miekg/dns"
"net"
"time"
)
const domain = "consul."