group

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ForceLeadership = false

Functions

This section is empty.

Types

type ConsensusService

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

	IsHealthy() bool
	IsLeader() bool
	GetLeader() string
	GetStateDescription() string
	GetSharedDomainServices() (map[string]string, error)
	GetStatus() *ConsensusServiceStatus

	Monitor()
}

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

func SetupRaft added in v1.0.4

func SetupRaft(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 ConsensusServiceProvider added in v1.0.4

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

func NewConsensusServiceProvider added in v1.0.4

func NewConsensusServiceProvider(throttler *throttle.Throttler) (p *ConsensusServiceProvider, err error)

func (*ConsensusServiceProvider) GetConsensusService added in v1.0.4

func (p *ConsensusServiceProvider) GetConsensusService() ConsensusService

func (*ConsensusServiceProvider) Monitor added in v1.0.4

func (p *ConsensusServiceProvider) Monitor()

type ConsensusServiceStatus added in v1.0.4

type ConsensusServiceStatus struct {
	ServiceID                 string
	Healthy                   bool
	IsLeader                  bool
	Leader                    string
	State                     string
	Domain                    string
	ShareDomain               string
	ShareDomainServices       map[string]string
	ShareDomainServicesList   []string // list of this service ID and share domain services, combined
	HealthyDomainServicesList []string
}

type MySQLBackend added in v1.0.4

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

func NewMySQLBackend added in v1.0.4

func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error)

func (*MySQLBackend) AttemptLeadership added in v1.0.4

func (backend *MySQLBackend) AttemptLeadership() error

func (*MySQLBackend) ForceLeadership added in v1.0.4

func (backend *MySQLBackend) ForceLeadership() error

func (*MySQLBackend) GetHealthyDomainServices added in v1.0.4

func (backend *MySQLBackend) GetHealthyDomainServices() (services []string, err error)

GetHealthyDomainServices returns list of services healthy within same domain as this service, including this service

func (*MySQLBackend) GetLeader added in v1.0.4

func (backend *MySQLBackend) GetLeader() string

func (*MySQLBackend) GetSharedDomainServices added in v1.0.4

func (backend *MySQLBackend) GetSharedDomainServices() (services map[string]string, err error)

GetSharedDomainServices returns active leader services that have same ShareDomain as this service: - assuming ShareDomain is not empty - excluding this very service

func (*MySQLBackend) GetStateDescription added in v1.0.4

func (backend *MySQLBackend) GetStateDescription() string

func (*MySQLBackend) GetStatus added in v1.0.4

func (backend *MySQLBackend) GetStatus() *ConsensusServiceStatus

func (*MySQLBackend) IsHealthy added in v1.0.4

func (backend *MySQLBackend) IsHealthy() bool

func (*MySQLBackend) IsLeader added in v1.0.4

func (backend *MySQLBackend) IsLeader() bool

func (*MySQLBackend) Monitor added in v1.0.4

func (backend *MySQLBackend) Monitor()

func (*MySQLBackend) ReadLeadership added in v1.0.4

func (backend *MySQLBackend) ReadLeadership() (leaderState int64, leader string, err error)

func (*MySQLBackend) RecentAppsMap added in v1.0.4

func (backend *MySQLBackend) RecentAppsMap() (result map[string](*base.RecentApp))

func (*MySQLBackend) Reelect added in v1.0.4

func (backend *MySQLBackend) Reelect() error

func (*MySQLBackend) RegisterHealth added in v1.0.4

func (backend *MySQLBackend) RegisterHealth() error

func (*MySQLBackend) ThrottleApp added in v1.0.4

func (backend *MySQLBackend) ThrottleApp(appName string, ttlMinutes int64, expireAt time.Time, ratio float64) error

func (*MySQLBackend) ThrottledAppsMap added in v1.0.4

func (backend *MySQLBackend) ThrottledAppsMap() (result map[string](*base.AppThrottle))

func (*MySQLBackend) UnthrottleApp added in v1.0.4

func (backend *MySQLBackend) UnthrottleApp(appName string) error

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) GetLeader added in v1.0.4

func (store *Store) GetLeader() string

GetLeader returns identity of raft leader

func (*Store) GetSharedDomainServices added in v1.0.4

func (store *Store) GetSharedDomainServices() (services map[string]string, err error)

func (*Store) GetState added in v1.0.4

func (store *Store) GetState() raft.RaftState

GetState returns current raft state

func (*Store) GetStateDescription added in v1.0.4

func (store *Store) GetStateDescription() string

GetState returns current raft state

func (*Store) GetStatus added in v1.0.4

func (store *Store) GetStatus() *ConsensusServiceStatus

func (*Store) IsHealthy added in v1.0.4

func (store *Store) IsHealthy() bool

func (*Store) IsLeader added in v1.0.4

func (store *Store) IsLeader() bool

IsLeader tells if this node is the current raft leader

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) Monitor added in v1.0.4

func (store *Store) Monitor()

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

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, ttlMinutes int64, 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