balancer2go

package
Version: v0.9.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2014 License: GPL-3.0, BSD-3-Clause Imports: 1 Imported by: 0

README

balancer2go

Simple golang balancer library

See the test file for wroking examples.

API docs here.

Continous integration: Build Status

Documentation

Overview

Simple RPC client balancer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balancer

type Balancer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

The main balancer type

func NewBalancer

func NewBalancer() *Balancer

Constructor for RateList holding one slice for addreses and one slice for connections.

func (*Balancer) AddClient

func (bl *Balancer) AddClient(address string, client Worker)

Adds a client to the two internal map.

func (*Balancer) Balance

func (bl *Balancer) Balance() (result Worker)

Returns the next available connection at each call looping at the end of connections.

func (*Balancer) GetClient

func (bl *Balancer) GetClient(address string) (c Worker, exists bool)

Returns a client for the specifed address.

func (*Balancer) GetClientAddresses

func (bl *Balancer) GetClientAddresses() []string

Returns a string slice with all client addresses

func (*Balancer) RemoveClient

func (bl *Balancer) RemoveClient(address string)

Removes a client from the map locking the readers and reseting the balancer index.

func (*Balancer) Shutdown

func (bl *Balancer) Shutdown(shutdownMethod string)

Sends a shotdown call to the clients

type Worker

type Worker interface {
	Call(serviceMethod string, args interface{}, reply interface{}) error
	Close() error
}

Interface for RPC clients

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL