Documentation ¶
Index ¶
- Constants
- Variables
- type Bucket
- func (*Bucket) Descriptor() ([]byte, []int)deprecated
- func (x *Bucket) GetItemMap() map[string]*anypb.Any
- func (x *Bucket) GetItems() []*Item
- func (x *Bucket) GetKey() string
- func (*Bucket) ProtoMessage()
- func (x *Bucket) ProtoReflect() protoreflect.Message
- func (x *Bucket) Reset()
- func (x *Bucket) String() string
- type Item
- type StoragePacker
- func (s *StoragePacker) BucketKey(itemID string) string
- func (s *StoragePacker) DeleteItem(ctx context.Context, itemID string) error
- func (s *StoragePacker) DeleteMultipleItems(ctx context.Context, logger hclog.Logger, itemIDs []string) error
- func (s *StoragePacker) GetBucket(ctx context.Context, key string) (*Bucket, error)
- func (s *StoragePacker) GetItem(itemID string) (*Item, error)
- func (s *StoragePacker) PutItem(ctx context.Context, item *Item) error
- func (s *StoragePacker) View() logical.Storage
Constants ¶
const ( // StoragePackerBucketsPrefix is the default storage key prefix under which // bucket data will be stored. StoragePackerBucketsPrefix = "packer/buckets/" )
Variables ¶
var File_helper_storagepacker_types_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { // Key is the storage path where the bucket gets stored Key string `sentinel:"" protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // Items holds the items contained within this bucket. Used by v1. Items []*Item `sentinel:"" protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"` // ItemMap stores a mapping of item ID to message. Used by v2. ItemMap map[string]*anypb.Any `` /* 182-byte string literal not displayed */ // contains filtered or unexported fields }
Bucket is a construct to hold multiple items within itself. This abstraction contains multiple buckets of the same kind within itself and shares amont them the items that get inserted. When the bucket as a whole gets too big to hold more items, the contained buckets gets pushed out only to become independent buckets. Hence, this can grow infinitely in terms of storage space for items that get inserted.
func (*Bucket) Descriptor
deprecated
func (*Bucket) ProtoMessage ¶
func (*Bucket) ProtoMessage()
func (*Bucket) ProtoReflect ¶ added in v1.5.0
func (x *Bucket) ProtoReflect() protoreflect.Message
type Item ¶
type Item struct { // ID must be provided by the caller; the same value, if used with GetItem, // can be used to fetch the item. However, when iterating through a bucket, // this ID will be an internal ID. In other words, outside of the use-case // described above, the caller *must not* rely on this value to be // consistent with what they passed in. ID string `sentinel:"" protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // message is the contents of the item Message *anypb.Any `sentinel:"" protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
Item represents an entry that gets inserted into the storage packer
func (*Item) Descriptor
deprecated
func (*Item) GetMessage ¶
func (*Item) ProtoMessage ¶
func (*Item) ProtoMessage()
func (*Item) ProtoReflect ¶ added in v1.5.0
func (x *Item) ProtoReflect() protoreflect.Message
type StoragePacker ¶
type StoragePacker struct {
// contains filtered or unexported fields
}
StoragePacker packs items into a specific number of buckets by hashing its identifier and indexing on it. Currently this supports only 256 bucket entries and hence relies on the first byte of the hash value for indexing.
func NewStoragePacker ¶
func NewStoragePacker(view logical.Storage, logger log.Logger, viewPrefix string) (*StoragePacker, error)
NewStoragePacker creates a new storage packer for a given view
func (*StoragePacker) BucketKey ¶
func (s *StoragePacker) BucketKey(itemID string) string
BucketKey returns the storage key of the bucket where the given item will be stored.
func (*StoragePacker) DeleteItem ¶
func (s *StoragePacker) DeleteItem(ctx context.Context, itemID string) error
DeleteItem removes the item from the respective bucket
func (*StoragePacker) DeleteMultipleItems ¶ added in v1.1.4
func (s *StoragePacker) DeleteMultipleItems(ctx context.Context, logger hclog.Logger, itemIDs []string) error
func (*StoragePacker) GetItem ¶
func (s *StoragePacker) GetItem(itemID string) (*Item, error)
GetItem fetches the storage entry for a given key from its corresponding bucket.
func (*StoragePacker) PutItem ¶
func (s *StoragePacker) PutItem(ctx context.Context, item *Item) error
PutItem stores the given item in its respective bucket
func (*StoragePacker) View ¶
func (s *StoragePacker) View() logical.Storage
View returns the storage view configured to be used by the packer