roundrobin

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright (c) 2014-2015 Oliver Eilhard. All rights reserved. Use of this source code is governed by the MIT license. See LICENSE file for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBalancer

func NewBalancer(conns ...balancers.Connection) (balancers.Balancer, error)

NewBalancer creates a new round-robin balancer. It can be initializes by a variable number of connections. To use plain URLs instead of connections, use NewBalancerFromURL.

Types

type Balancer

type Balancer struct {
	sync.Mutex // guards the following variables
	// contains filtered or unexported fields
}

Balancer implements a round-robin balancer.

func NewBalancerFromURL

func NewBalancerFromURL(urls ...string) (*Balancer, error)

NewBalancerFromURL creates a new round-robin balancer for the given list of URLs. It returns an error if any of the URLs is invalid.

func (*Balancer) Connections

func (b *Balancer) Connections() []balancers.Connection

Connections returns a list of all connections.

func (*Balancer) Get

func (b *Balancer) Get() (balancers.Connection, error)

Get returns a connection from the balancer that can be used for the next request. ErrNoConn is returns when no connection is available.

Jump to

Keyboard shortcuts

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