client

package
v0.0.0-...-daf3ae0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package client will respond to tsuru events creating by default one bucket type for each data type (counter, set and map). Having these bucket types for each new service instance the client will create a bucket, and for each app binding to this instance the riak client will create a user and an ACL to access to this bucket.

Index

Constants

View Source
const (
	//BucketTypeCounter is a counter data type bucket type
	BucketTypeCounter = "tsuru-counter"
	//BucketTypeSet is a set data type bucket type
	BucketTypeSet = "tsuru-set"
	//BucketTypeMap is a map data type bucket type
	BucketTypeMap = "tsuru-map"
)
View Source
const (
	RiakInstancesInfoBucket = "tsuru-instances"
	RiakUsersInfoBucket     = "tsuru-users"
)

This will hold the added instances on tsuru

Variables

View Source
var BucketTypes = map[string]string{
	BucketTypeCounter: "Bucket type of counter data type",
	BucketTypeSet:     "Bucket type of set data type",
	BucketTypeMap:     "Bucket type of map data type",
}

BucketTypes lists all the bucket types available

View Source
var NameBucketTypeMapping = map[string]string{
	BucketTypeCounter: "counter",
	BucketTypeSet:     "set",
	BucketTypeMap:     "map",
}

NameBucketTypeMapping maps bucket types to data types

Functions

func NewRiakCluster

func NewRiakCluster(cfg *config.ServiceConfig) (*riak.Cluster, error)

Types

type Client

type Client interface {
	GetBucketType(bucketName string) string
	GetBucketTypes() ([]map[string]string, error)
	CreateBucket(bucketName, bucketType string) error
	DeleteBucket(bucketName, bucketType string) error
	EnsureUserPresent(word string) (user, pass string, err error)
	DeleteUser(username string) error
	GrantUserAccess(username, bucketName string) error
	RevokeUserAccess(username, bucketName string) error
	IsAlive(bucketName string) (alive bool, err error)
}

Client is the interface to the storer

type Dummy

type Dummy struct {
	*Riak

	// Our custom database (on the instance to allow parallel tests)
	Buckets map[string]string
	Users   map[string]*UserProps
	// contains filtered or unexported fields
}

Dummy is the entrypoint for riak dummy client

func NewDummy

func NewDummy() *Dummy

NewDummy creates a dummy client, useful for testing

func (*Dummy) CreateBucket

func (c *Dummy) CreateBucket(bucketName, bucketType string) error

func (*Dummy) DeleteBucket

func (c *Dummy) DeleteBucket(bucketName, bucketType string) error

func (*Dummy) DeleteUser

func (c *Dummy) DeleteUser(username string) error

func (*Dummy) EnsureUserPresent

func (c *Dummy) EnsureUserPresent(word string) (user, pass string, err error)

func (*Dummy) GetBucketType

func (c *Dummy) GetBucketType(bucketName string) string

func (*Dummy) GetBucketTypes

func (c *Dummy) GetBucketTypes() ([]map[string]string, error)

func (*Dummy) GrantUserAccess

func (c *Dummy) GrantUserAccess(username, bucketName string) error

func (*Dummy) IsAlive

func (c *Dummy) IsAlive(bucketName string) (alive bool, err error)

func (*Dummy) RevokeUserAccess

func (c *Dummy) RevokeUserAccess(username, bucketName string) error

type Nil

type Nil struct {
}

Nil implements client interface doing nothing

func NewNil

func NewNil() *Nil

NewNil Creates a new nil client

func (*Nil) CreateBucket

func (c *Nil) CreateBucket(bucketName, bucketType string) error

func (*Nil) DeleteBucket

func (c *Nil) DeleteBucket(bucketName, bucketType string) error

func (*Nil) DeleteUser

func (c *Nil) DeleteUser(username string) error

func (*Nil) EnsureUserPresent

func (c *Nil) EnsureUserPresent(word string) (user, pass string, err error)

func (*Nil) GetBucketType

func (c *Nil) GetBucketType(bucketName string) string

func (*Nil) GetBucketTypes

func (c *Nil) GetBucketTypes() ([]map[string]string, error)

func (*Nil) GrantUserAccess

func (c *Nil) GrantUserAccess(username, bucketName string) error

func (*Nil) IsAlive

func (c *Nil) IsAlive(bucketName string) (alive bool, err error)

func (*Nil) RevokeUserAccess

func (c *Nil) RevokeUserAccess(username, bucketName string) error

type Riak

type Riak struct {
	//SSHConnection SSH connection (for riak-admin manage operations)
	SSHClient *ssh.Client

	// RiakClient riak lowlevel client (for riak bucket operations)
	RiakClient *riak.Cluster
}

Riak is the entrypoint for riak client

func NewRiak

func NewRiak(cfg *config.ServiceConfig) *Riak

NewRiak creates a riak client and the ssh connection

func (*Riak) CreateBucket

func (c *Riak) CreateBucket(bucketName, bucketType string) error

CreateBucket Creates a bucket on riak

func (*Riak) DeleteBucket

func (c *Riak) DeleteBucket(bucketName, bucketType string) error

DeleteBucket Deletes a bucket on riak

func (*Riak) DeleteUser

func (c *Riak) DeleteUser(username string) error

DeleteUser Deletes a user on riak

func (*Riak) EnsureUserPresent

func (c *Riak) EnsureUserPresent(word string) (user, pass string, err error)

EnsureUserPresent stores the user and password (based on a reference word) on the database if there aren't present, returns the generated user and password or previous stored one

func (*Riak) GetBucketType

func (c *Riak) GetBucketType(bucketName string) string

GetBucketType returns the bucket type based on the bucket name

func (*Riak) GetBucketTypes

func (c *Riak) GetBucketTypes() ([]map[string]string, error)

GetBucketTypes Gets Riak plans

func (*Riak) GrantUserAccess

func (c *Riak) GrantUserAccess(username, bucketName string) error

GrantUserAccess grants access to a bucket on riak

func (*Riak) IsAlive

func (c *Riak) IsAlive(bucketName string) (alive bool, err error)

IsAlive checks if riak store is alive

func (*Riak) RevokeUserAccess

func (c *Riak) RevokeUserAccess(username, bucketName string) error

RevokeUserAccess revokes access to user on a bucket

type UserProps

type UserProps struct {
	Username string
	Password string
	ACL      []string // bucket names wich can access
}

Jump to

Keyboard shortcuts

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