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"
|
2018-11-16 13:59:27 +00:00
|
|
|
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
2018-11-06 11:40:06 +00:00
|
|
|
|
|
|
|
"storj.io/storj/internal/memory"
|
2018-11-14 09:26:18 +00:00
|
|
|
"storj.io/storj/pkg/pointerdb/pdbclient"
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2018-11-16 13:59:27 +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 {
|
2018-11-14 09:26:18 +00:00
|
|
|
buckets buckets.Store
|
|
|
|
streams streams.Store
|
|
|
|
segments segments.Store
|
|
|
|
pointers pdbclient.Client
|
|
|
|
|
|
|
|
rootKey *storj.Key
|
2018-11-06 11:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// New creates a new metainfo database
|
2018-11-14 09:26:18 +00:00
|
|
|
func New(buckets buckets.Store, streams streams.Store, segments segments.Store, pointers pdbclient.Client, rootKey *storj.Key) *DB {
|
2018-11-06 11:40:06 +00:00
|
|
|
return &DB{
|
2018-11-14 09:26:18 +00:00
|
|
|
buckets: buckets,
|
|
|
|
streams: streams,
|
|
|
|
segments: segments,
|
|
|
|
pointers: pointers,
|
|
|
|
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: int64(memory.KB), // TODO: is this needed here?
|
|
|
|
MaximumInlineSegmentSize: int64(memory.MB),
|
|
|
|
}, nil
|
|
|
|
}
|