storj/pkg/metainfo/kvmetainfo/metainfo.go

59 lines
1.5 KiB
Go
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
2018-11-06 11:40:06 +00:00
// See LICENSE for copying information.
package kvmetainfo
import (
"github.com/zeebo/errs"
monkit "gopkg.in/spacemonkeygo/monkit.v2"
2018-11-06 11:40:06 +00:00
"storj.io/storj/internal/memory"
"storj.io/storj/pkg/eestream"
"storj.io/storj/pkg/storage/buckets"
"storj.io/storj/pkg/storage/segments"
"storj.io/storj/pkg/storage/streams"
2018-11-06 11:40:06 +00:00
"storj.io/storj/pkg/storj"
"storj.io/storj/storage"
2019-03-22 09:01:49 +00:00
"storj.io/storj/uplink/metainfo"
2018-11-06 11:40:06 +00:00
)
var mon = monkit.Package()
2018-11-06 11:40:06 +00:00
var errClass = errs.Class("kvmetainfo")
const defaultSegmentLimit = 8 // TODO
var _ storj.Metainfo = (*DB)(nil)
// DB implements metainfo database
type DB struct {
*Project
2019-03-22 09:01:49 +00:00
metainfo metainfo.Client
streams streams.Store
segments segments.Store
rootKey *storj.Key
2018-11-06 11:40:06 +00:00
}
// New creates a new metainfo database
func New(metainfo metainfo.Client, buckets buckets.Store, streams streams.Store, segments segments.Store, rootKey *storj.Key, encryptedBlockSize int32, redundancy eestream.RedundancyStrategy, segmentsSize int64) *DB {
2018-11-06 11:40:06 +00:00
return &DB{
Project: NewProject(buckets, encryptedBlockSize, redundancy, segmentsSize),
2019-03-22 09:01:49 +00:00
metainfo: metainfo,
streams: streams,
segments: segments,
rootKey: rootKey,
2018-11-06 11:40:06 +00:00
}
}
// Limits returns limits for this metainfo database
func (db *DB) Limits() (storj.MetainfoLimits, error) {
return storj.MetainfoLimits{
ListLimit: storage.LookupLimit,
MinimumRemoteSegmentSize: memory.KiB.Int64(), // TODO: is this needed here?
MaximumInlineSegmentSize: memory.MiB.Int64(),
2018-11-06 11:40:06 +00:00
}, nil
}