Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSelfPurging = errors.New("this strategy is purging") MsgOtherPurging = "%s is purging" )
errors created by Purger
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Interval int64 `toml:"interval" json:"interval"` // check whether need to purge at this @Interval (seconds)
Expires int64 `toml:"expires" json:"expires"` // if file's modified time is older than @Expires (hours), then it can be purged
RemainSpace int64 `toml:"remain-space" json:"remain-space"` // if remain space in @RelayBaseDir less than @RemainSpace (GB), then it can be purged
}
Config is the configuration for Purger
type PurgeInterceptor ¶
type PurgeInterceptor interface {
// ForbidPurge returns whether forbidding purge currently and an optional message
ForbidPurge() (bool, string)
}
PurgeInterceptor represents an interceptor may forbid the purge process
type PurgeStrategy ¶
type PurgeStrategy interface {
// Check checks whether need to do the purge in the background automatically
Check(args interface{}) (bool, error)
// Do does the purge process one time
Do(args interface{}) error
// Purging indicates whether is doing purge
Purging() bool
// Type returns the strategy type
Type() strategyType
}
PurgeStrategy represents a relay log purge strategy two purge behaviors
- purge in the background
- do one time purge process
a strategy can support both or one of them
type Purger ¶
type Purger struct {
// contains filtered or unexported fields
}
Purger purges relay log according to some strategies
func NewPurger ¶
func NewPurger(cfg Config, baseRelayDir string, operators []RelayOperator, interceptors []PurgeInterceptor) *Purger
NewPurger creates a new purger
type RelayOperator ¶
type RelayOperator interface {
// EarliestActiveRelayLog returns the earliest active relay log info in this operator
EarliestActiveRelayLog() *streamer.RelayLogInfo
}
RelayOperator represents an operator for relay log files, like writer, reader
type StrategyArgs ¶
type StrategyArgs interface {
// SetActiveRelayLog sets active relay log info in args
// this should be called before do the purging
SetActiveRelayLog(active *streamer.RelayLogInfo)
}
StrategyArgs represents args needed by purge strategy
Click to show internal directories.
Click to hide internal directories.