rollout

package module
v0.0.0-...-63dd500 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Rollout for Go/Zookeeper

Usage

zk, session, err := zookeeper.Dial("localhost:2181", 5e9)
if err != nil {
    log.Fatal(err)
}
event := <-session
if event.State != zookeeper.STATE_CONNECTED {
    log.Fatal("Cannot initialize zookeeper: ", event.State)
}
client := rollout.NewClient(zk, "/rollout/users")

// The service must be started
client.Start()

// Check to see if this feature is enabled for this user
client.FeatureActive("myfeature", userId, userGroups)

// Don't forget to stop the service when you're done (usually on shutdown)
client.Stop()

Testing

You must have Zookeeper enabled on localhost:2181, then simply issue make.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFeatureNotFound = errors.New("feature not found")

ErrFeatureNotFound can be detected to inform better defaulting behaviors

Functions

This section is empty.

Types

type Client

type Client interface {
	Start() error
	Stop()
	RawPercentage(feature string) (float64, error)
	FeatureActive(feature string, userId int64, userGroups []string) bool
}

func NewClient

func NewClient(zk *zk.Conn, path string, errorHandler errorHandlerFunc) Client

type ZookeeperClient

type ZookeeperClient struct {
	*zk.Conn
	Errors chan error
	Hosts  []string
}

func NewZookeeperClient

func NewZookeeperClient(hostString string) *ZookeeperClient

func (*ZookeeperClient) CreateFullNode

func (zkc *ZookeeperClient) CreateFullNode(node string, ephemeral bool) error

Creates a znode at the given string, including any intervening, required paths

func (*ZookeeperClient) Start

func (zkc *ZookeeperClient) Start()

Jump to

Keyboard shortcuts

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