vault: github.com/hashicorp/vault/helper/storagepacker Index | Files

package storagepacker

import "github.com/hashicorp/vault/helper/storagepacker"

Index

Package Files

storagepacker.go types.pb.go

Constants

const (

    // StoragePackerBucketsPrefix is the default storage key prefix under which
    // bucket data will be stored.
    StoragePackerBucketsPrefix = "packer/buckets/"
)

type Bucket Uses

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]*any.Any `sentinel:"" protobuf:"bytes,3,rep,name=item_map,json=itemMap,proto3" json:"item_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
    XXX_NoUnkeyedLiteral struct{}            `json:"-"`
    XXX_unrecognized     []byte              `json:"-"`
    XXX_sizecache        int32               `json:"-"`
}

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 Uses

func (*Bucket) Descriptor() ([]byte, []int)

func (*Bucket) GetItemMap Uses

func (m *Bucket) GetItemMap() map[string]*any.Any

func (*Bucket) GetItems Uses

func (m *Bucket) GetItems() []*Item

func (*Bucket) GetKey Uses

func (m *Bucket) GetKey() string

func (*Bucket) ProtoMessage Uses

func (*Bucket) ProtoMessage()

func (*Bucket) Reset Uses

func (m *Bucket) Reset()

func (*Bucket) String Uses

func (m *Bucket) String() string

func (*Bucket) XXX_DiscardUnknown Uses

func (m *Bucket) XXX_DiscardUnknown()

func (*Bucket) XXX_Marshal Uses

func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Bucket) XXX_Merge Uses

func (m *Bucket) XXX_Merge(src proto.Message)

func (*Bucket) XXX_Size Uses

func (m *Bucket) XXX_Size() int

func (*Bucket) XXX_Unmarshal Uses

func (m *Bucket) XXX_Unmarshal(b []byte) error

type Item Uses

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              *any.Any `sentinel:"" protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

Item represents an entry that gets inserted into the storage packer

func (*Item) Descriptor Uses

func (*Item) Descriptor() ([]byte, []int)

func (*Item) GetID Uses

func (m *Item) GetID() string

func (*Item) GetMessage Uses

func (m *Item) GetMessage() *any.Any

func (*Item) ProtoMessage Uses

func (*Item) ProtoMessage()

func (*Item) Reset Uses

func (m *Item) Reset()

func (*Item) String Uses

func (m *Item) String() string

func (*Item) XXX_DiscardUnknown Uses

func (m *Item) XXX_DiscardUnknown()

func (*Item) XXX_Marshal Uses

func (m *Item) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Item) XXX_Merge Uses

func (m *Item) XXX_Merge(src proto.Message)

func (*Item) XXX_Size Uses

func (m *Item) XXX_Size() int

func (*Item) XXX_Unmarshal Uses

func (m *Item) XXX_Unmarshal(b []byte) error

type StoragePacker Uses

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 Uses

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 Uses

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 Uses

func (s *StoragePacker) DeleteItem(_ context.Context, itemID string) error

DeleteItem removes the item from the respective bucket

func (*StoragePacker) DeleteMultipleItems Uses

func (s *StoragePacker) DeleteMultipleItems(ctx context.Context, logger hclog.Logger, itemIDs ...string) error

func (*StoragePacker) GetBucket Uses

func (s *StoragePacker) GetBucket(key string) (*Bucket, error)

GetBucket returns a bucket for a given key

func (*StoragePacker) GetItem Uses

func (s *StoragePacker) GetItem(itemID string) (*Item, error)

GetItem fetches the storage entry for a given key from its corresponding bucket.

func (*StoragePacker) PutItem Uses

func (s *StoragePacker) PutItem(_ context.Context, item *Item) error

PutItem stores the given item in its respective bucket

func (*StoragePacker) View Uses

func (s *StoragePacker) View() logical.Storage

View returns the storage view configured to be used by the packer

Package storagepacker imports 13 packages (graph) and is imported by 3 packages. Updated 2019-07-02. Refresh now. Tools for package owners.