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
- Variables
- func NewRiakCluster(cfg *config.ServiceConfig) (*riak.Cluster, error)
- type Client
- type Dummy
- func (c *Dummy) CreateBucket(bucketName, bucketType string) error
- func (c *Dummy) DeleteBucket(bucketName, bucketType string) error
- func (c *Dummy) DeleteUser(username string) error
- func (c *Dummy) EnsureUserPresent(word string) (user, pass string, err error)
- func (c *Dummy) GetBucketType(bucketName string) string
- func (c *Dummy) GetBucketTypes() ([]map[string]string, error)
- func (c *Dummy) GrantUserAccess(username, bucketName string) error
- func (c *Dummy) IsAlive(bucketName string) (alive bool, err error)
- func (c *Dummy) RevokeUserAccess(username, bucketName string) error
- type Nil
- func (c *Nil) CreateBucket(bucketName, bucketType string) error
- func (c *Nil) DeleteBucket(bucketName, bucketType string) error
- func (c *Nil) DeleteUser(username string) error
- func (c *Nil) EnsureUserPresent(word string) (user, pass string, err error)
- func (c *Nil) GetBucketType(bucketName string) string
- func (c *Nil) GetBucketTypes() ([]map[string]string, error)
- func (c *Nil) GrantUserAccess(username, bucketName string) error
- func (c *Nil) IsAlive(bucketName string) (alive bool, err error)
- func (c *Nil) RevokeUserAccess(username, bucketName string) error
- type Riak
- func (c *Riak) CreateBucket(bucketName, bucketType string) error
- func (c *Riak) DeleteBucket(bucketName, bucketType string) error
- func (c *Riak) DeleteUser(username string) error
- func (c *Riak) EnsureUserPresent(word string) (user, pass string, err error)
- func (c *Riak) GetBucketType(bucketName string) string
- func (c *Riak) GetBucketTypes() ([]map[string]string, error)
- func (c *Riak) GrantUserAccess(username, bucketName string) error
- func (c *Riak) IsAlive(bucketName string) (alive bool, err error)
- func (c *Riak) RevokeUserAccess(username, bucketName string) error
- type UserProps
Constants ¶
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" )
const ( RiakInstancesInfoBucket = "tsuru-instances" RiakUsersInfoBucket = "tsuru-users" )
This will hold the added instances on tsuru
Variables ¶
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
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 (*Dummy) CreateBucket ¶
func (*Dummy) DeleteBucket ¶
func (*Dummy) DeleteUser ¶
func (*Dummy) EnsureUserPresent ¶
func (*Dummy) GetBucketType ¶
func (*Dummy) GrantUserAccess ¶
func (*Dummy) RevokeUserAccess ¶
type Nil ¶
type Nil struct { }
Nil implements client interface doing nothing
func (*Nil) CreateBucket ¶
func (*Nil) DeleteBucket ¶
func (*Nil) DeleteUser ¶
func (*Nil) EnsureUserPresent ¶
func (*Nil) GetBucketType ¶
func (*Nil) GrantUserAccess ¶
func (*Nil) RevokeUserAccess ¶
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 ¶
CreateBucket Creates a bucket on riak
func (*Riak) DeleteBucket ¶
DeleteBucket Deletes a bucket on riak
func (*Riak) DeleteUser ¶
DeleteUser Deletes a user on riak
func (*Riak) EnsureUserPresent ¶
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 ¶
GetBucketType returns the bucket type based on the bucket name
func (*Riak) GetBucketTypes ¶
GetBucketTypes Gets Riak plans
func (*Riak) GrantUserAccess ¶
GrantUserAccess grants access to a bucket on riak
func (*Riak) RevokeUserAccess ¶
RevokeUserAccess revokes access to user on a bucket