forked from TrueCloudLab/frostfs-node
[#1634] meta: Add epoch state
It allows performing expiration checks on the stored objects. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
a97dee008c
commit
9aba0ba512
9 changed files with 76 additions and 7 deletions
|
@ -24,6 +24,13 @@ type matcher struct {
|
|||
matchBucket func(*bbolt.Bucket, string, string, func([]byte, []byte) error) error
|
||||
}
|
||||
|
||||
// EpochState is an interface that provides access to the
|
||||
// current epoch number.
|
||||
type EpochState interface {
|
||||
// CurrentEpoch must return current epoch height.
|
||||
CurrentEpoch() uint64
|
||||
}
|
||||
|
||||
// DB represents local metabase of storage node.
|
||||
type DB struct {
|
||||
*cfg
|
||||
|
@ -50,6 +57,8 @@ type cfg struct {
|
|||
info Info
|
||||
|
||||
log *logger.Logger
|
||||
|
||||
epochState EpochState
|
||||
}
|
||||
|
||||
func defaultCfg() *cfg {
|
||||
|
@ -71,6 +80,10 @@ func New(opts ...Option) *DB {
|
|||
opts[i](c)
|
||||
}
|
||||
|
||||
if c.epochState == nil {
|
||||
panic("metabase: epoch state is not specified")
|
||||
}
|
||||
|
||||
return &DB{
|
||||
cfg: c,
|
||||
matchers: map[object.SearchMatchType]matcher{
|
||||
|
@ -311,3 +324,10 @@ func WithMaxBatchDelay(d time.Duration) Option {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithEpochState return option to specify a source of current epoch height.
|
||||
func WithEpochState(s EpochState) Option {
|
||||
return func(c *cfg) {
|
||||
c.epochState = s
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue