group

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RaftDBFile = "freno-raft.db"

Variables

This section is empty.

Functions

func GetLeader

func GetLeader() string

GetLeader returns identity of raft leader

func GetState

func GetState() raft.RaftState

GetState returns current raft state

func IsLeader

func IsLeader() bool

IsLeader tells if this node is the current raft leader

func Monitor

func Monitor()

Monitor is a utility function to routinely observe leadership state. It doesn't actually do much; merely takes notes.

Types

type ConsensusService

type ConsensusService interface {
	ThrottleApp(appName string, expireAt time.Time, ratio float64) error
	ThrottledAppsMap() (result map[string](*base.AppThrottle))
	UnthrottleApp(appName string) error
	RecentAppsMap() (result map[string](*base.RecentApp))
}

ConsensusService is a freno-oriented interface for making requests that require consensus.

func Setup

func Setup(throttler *throttle.Throttler) (ConsensusService, error)

Setup creates the entire raft shananga. Creates the store, associates with the throttler, contacts peer nodes, and subscribes to leader changes to export them.

type Store

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

The store is a raft store that is freno-aware. It operates on a `throttler` instance on given events/commands. Store implements consensusService, which is a freno-oriented interface for running operations via consensus.

func NewStore

func NewStore(raftDir string, raftBind string, throttler *throttle.Throttler) *Store

NewStore inits and returns a new store

func (*Store) Join

func (store *Store) Join(addr string) error

Join joins a node, located at addr, to this store. The node must be ready to respond to Raft communications at that address.

func (*Store) Open

func (store *Store) Open(peerNodes []string) error

Open opens the store. If enableSingle is set, and there are no existing peers, then this node becomes the first node, and therefore leader, of the cluster.

func (*Store) RecentAppsMap

func (store *Store) RecentAppsMap() (result map[string](*base.RecentApp))

func (*Store) ThrottleApp

func (store *Store) ThrottleApp(appName string, expireAt time.Time, ratio float64) error

ThrottleApp, as implied by consensusService, is a raft oepration request which will ask for consensus.

func (*Store) ThrottledAppsMap

func (store *Store) ThrottledAppsMap() (result map[string](*base.AppThrottle))

func (*Store) UnthrottleApp

func (store *Store) UnthrottleApp(appName string) error

UnthrottleApp, as implied by consensusService, is a raft oepration request which will ask for consensus.

Jump to

Keyboard shortcuts

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