rsclient

package
v0.0.0-...-be95f36 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Package Documentation

To import:

import "github.com/therealbill/redskull/rpcclient"

Sample Usage

Say you want a utility which will be run on startup of a sentinel server to "register" the local sentinel instance. This way new sentinels are already in your constellation. In order to keep this simple you'e set up a TCP load balance so your tools can simply call one DNS address and be connected to your Redskull cluster.

The relevant portion of the tool could look like the following:

//set a timeout of 5 seconds
timeout := time.Second * 5
client, err:= NewClient("myredskull.host.name:8001" , timeout ) 
if err != nil {
	log.Fatal("Unable to connect to Redskull cluster")
}
ok, err := client.AddSentinel("my.local.sentinel.ip:port")
if err != nil {
	log.Fatalf("Unable to add sentinel. Error was '%s'",err)
}

if !ok {
	log.Fatal("Redskull returned no error, but didn't register the new sentinel. Look into it's logs.")
}
//whatever you want to do from here.

As you can see we connect, check for valid connection, then attempt to add our local sentinel. The "tricky" bits would be determining the IP to register. Ideally your sentinel config file would have it in the bind statement but that isn't always the address you need to use (as might be the case in a container behind NAT for example.

Types

Client

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

NewPodRequest

NewPodRequest is a struct used for passing in the pod information from the rpc client to the server, and is not generally used by the client code.

type NewPodRequest struct {
    Name   string
    IP     string
    Port   int
    Quorum int
    Auth   string
}

Functions

NewClient

NewClient returns a client connection. It takes a connection string in the form of "host:port", and a time.Duration for the timeout.

func NewClient(dsn string, timeout time.Duration) (*Client, error)

##AddPod AddPod(NewPodRequest) will take the information in the PodRequest and instruct Redskull to add it to it's monitor list. It is used by rpc clients to marshal up the necessary parameters.

func (c *Client) AddPod(name, ip string, port, quorum int, auth string) (actions.RedisPod, error)

##AddSentinel AddSentinel(address) will instuct Redskull to add the sentinel at the given address.

func (c *Client) AddSentinel(address string) (bool, error)

##BalancePod BalancePod will attempt to rebalance the pod's sentinels.

func (c *Client) BalancePod(podname string) error

##GetPod GetPod(podname) will return an actions.RedisPod type for the given pod, if found, or an empty one and an error if not.

func (c *Client) GetPod(podname string) (actions.RedisPod, error)

##GetSentinelsForPod GetSentinelsForPod(podname) returns the number and list of sentinels for the given podname.

func (c *Client) GetSentinelsForPod(address string) (int, []string, error)

##RemovePod RemovePod(podname) removes the pod from Redskull and associated sentinels.

func (c *Client) RemovePod(podname string) error

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddSlaveToPodRequest

type AddSlaveToPodRequest struct {
	Pod       string
	SlaveIP   string
	SlavePort int
	SlaveAuth string
}

AddSlaveToPodRequest is a struct for passing slave+pod information over the wire

type Client

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

func NewClient

func NewClient(dsn string, timeout time.Duration) (*Client, error)

NewClient returns a client connection

func (*Client) AddPod

func (c *Client) AddPod(name, ip string, port, quorum int, auth string) (common.RedisPod, error)

AddPod(NewPodRequest) will take the information in the PodRequest and instruct Redskull to add it to it's monitor list.

func (*Client) AddSentinel

func (c *Client) AddSentinel(address string) (bool, error)

AddSentinel(address) will instuct Redskull to add the sentinel at the given address

func (*Client) AddSlaveToPod

func (c *Client) AddSlaveToPod(podname, slaveip string, slaveport int, slaveauth string) (bool, error)

AddSlaveToPod is used to instruct Red skull to add a slave to the given pod.

func (*Client) BalancePod

func (c *Client) BalancePod(podname string) error

BalancePod will attempt to rebalance the pod's sentinels

func (*Client) CheckPodAuth

func (c *Client) CheckPodAuth(podname string) (map[string]bool, error)

CheckPodAuth has the server check it's authenticationn capability to the master and all attached slaves for the pod. It returns a map true/false for each IP in the pod. If the master can not be authed against it returns an empty map.

func (*Client) GetPod

func (c *Client) GetPod(podname string) (common.RedisPod, error)

GetPod(podname) will return the common.RedisPod type for the given pod, if found.

func (*Client) GetSentinelsForPod

func (c *Client) GetSentinelsForPod(address string) (int, []string, error)

GetSentinelsForPod(podname) returns the number and list of sentinels for the given podname

func (*Client) RemovePod

func (c *Client) RemovePod(podname string) error

RemovePod(podname) removes the prod from Redskull and associated sentinels

func (*Client) ValidatePodSentinels

func (c *Client) ValidatePodSentinels(podname string) (map[string]bool, error)

ValidatePodSentinels validates the sentinels listed for the given pod.

type NewPodRequest

type NewPodRequest struct {
	Name   string
	IP     string
	Port   int
	Quorum int
	Auth   string
}

NewPodRequest is a struct used for passing in the pod information from the client

Jump to

Keyboard shortcuts

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