minietcd

package module
v0.0.0-...-2ef5dc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2017 License: MIT Imports: 10 Imported by: 0

README

minietcd Travis badge GoDoc

Super small and "dumb" read-only client for coreos/etcd.

Intented only for v2 protocol as of right now.

Rationale

One of the main points of Go was compiler speed.

Since Go v1.5 this is not true anymore.

Now, consider CoreOS team decision to move both etcd's client and server code into the same repository, things get even worse.

minietcd's use case is simple: get keys from etcd, do it simple, do it fast (in terms of compiling speed).

I know there's a lot of stuff this library doesn't cover but it's intentional.

Installation

Use: go get github.com/toqueteos/minietcd

Example

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/toqueteos/minietcd"
)

const (
    Endpoint = "127.0.0.1:4001"
    Root     = "foo"
)

func main() {
    conn := minietcd.New()
    conn.SetLoggingOutput(os.Stderr) // optional, os.Stdout by default

    if err := conn.Dial(Endpoint); err != nil {
        log.Fatalf("failed to connect to endpoint %q, error %q\n", Endpoint, err)
    }

    keys, err := conn.Keys(Root)
    if err != nil {
        log.Fatalf("failed to get %q keys with error %q\n", Root, err)
    }

    for k, v := range keys {
        fmt.Println(k, v)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSupportedVersion = errors.New("minietcd only works with version 2")

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func New

func New() (conn *Conn)

func (*Conn) Dial

func (c *Conn) Dial(_url string) error

func (*Conn) Keys

func (c *Conn) Keys(name string) (kv map[string]string, err error)

func (*Conn) SetLoggingOutput

func (c *Conn) SetLoggingOutput(w io.Writer)

type Node

type Node struct {
	Dir           bool   `json:"dir,omitempty"`
	Key           string `json:"key"`
	Value         string `json:"value,omitempty"`
	CreatedIndex  int    `json:"createdIndex"`
	ModifiedIndex int    `json:"modifiedIndex"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL