group

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 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))

	SkipHost(hostName string, ttlMinutes int64, expireAt time.Time) error
	RecoverHost(hostName string) error
	SkippedHostsMap() (result map[string]time.Time)

	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

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

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

func NewConsensusServiceProvider

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

func (*ConsensusServiceProvider) GetConsensusService

func (p *ConsensusServiceProvider) GetConsensusService() ConsensusService

func (*ConsensusServiceProvider) Monitor

func (p *ConsensusServiceProvider) Monitor()

type ConsensusServiceStatus

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

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

func NewMySQLBackend

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

func (*MySQLBackend) AttemptLeadership

func (backend *MySQLBackend) AttemptLeadership() error

func (*MySQLBackend) ForceLeadership

func (backend *MySQLBackend) ForceLeadership() error

func (*MySQLBackend) GetHealthyDomainServices

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

func (backend *MySQLBackend) GetLeader() string

func (*MySQLBackend) GetSharedDomainServices

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

func (backend *MySQLBackend) GetStateDescription() string

func (*MySQLBackend) GetStatus

func (backend *MySQLBackend) GetStatus() *ConsensusServiceStatus

func (*MySQLBackend) IsHealthy

func (backend *MySQLBackend) IsHealthy() bool

func (*MySQLBackend) IsLeader

func (backend *MySQLBackend) IsLeader() bool

func (*MySQLBackend) Monitor

func (backend *MySQLBackend) Monitor()

func (*MySQLBackend) ReadLeadership

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

func (*MySQLBackend) RecentAppsMap

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

func (*MySQLBackend) RecoverHost added in v1.3.0

func (backend *MySQLBackend) RecoverHost(hostName string) error

func (*MySQLBackend) Reelect

func (backend *MySQLBackend) Reelect() error

func (*MySQLBackend) RegisterHealth

func (backend *MySQLBackend) RegisterHealth() error

func (*MySQLBackend) SkipHost added in v1.3.0

func (backend *MySQLBackend) SkipHost(hostName string, ttlMinutes int64, expireAt time.Time) error

func (*MySQLBackend) SkippedHostsMap added in v1.3.0

func (backend *MySQLBackend) SkippedHostsMap() map[string]time.Time

func (*MySQLBackend) ThrottleApp

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

func (*MySQLBackend) ThrottledAppsMap

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

func (*MySQLBackend) UnthrottleApp

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

func (store *Store) GetLeader() string

GetLeader returns identity of raft leader

func (*Store) GetSharedDomainServices

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

func (*Store) GetState

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

GetState returns current raft state

func (*Store) GetStateDescription

func (store *Store) GetStateDescription() string

GetState returns current raft state

func (*Store) GetStatus

func (store *Store) GetStatus() *ConsensusServiceStatus

func (*Store) IsHealthy

func (store *Store) IsHealthy() bool

func (*Store) IsLeader

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

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) RecoverHost added in v1.3.0

func (store *Store) RecoverHost(hostName string) error

func (*Store) SkipHost added in v1.3.0

func (store *Store) SkipHost(hostName string, ttlMinutes int64, expireAt time.Time) error

func (*Store) SkippedHostsMap added in v1.3.0

func (store *Store) SkippedHostsMap() map[string]time.Time

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