Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewPurger = NewRelayPurger
NewPurger creates a new 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 interface { // Start starts strategies by config Start() // Close stops the started strategies Close() // Purging returns whether the purger is purging Purging() bool // Do does the purge process one time Do(ctx context.Context, req *pb.PurgeRelayRequest) error }
Purger purges relay log according to some strategies
func NewDummyPurger ¶
func NewDummyPurger(cfg Config, baseRelayDir string, operators []RelayOperator, interceptors []PurgeInterceptor) Purger
NewDummyPurger returns a dummy purger
func NewRelayPurger ¶
func NewRelayPurger(cfg Config, baseRelayDir string, operators []RelayOperator, interceptors []PurgeInterceptor) Purger
NewRelayPurger 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 RelayPurger ¶
type RelayPurger struct {
// contains filtered or unexported fields
}
RelayPurger purges relay log according to some strategies
func (*RelayPurger) Do ¶
func (p *RelayPurger) Do(ctx context.Context, req *pb.PurgeRelayRequest) error
Do does the purge process one time
func (*RelayPurger) Purging ¶
func (p *RelayPurger) Purging() bool
Purging returns whether the purger is purging
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