storagepacker

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2019 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoragePackerBucketsPrefix = "packer/buckets/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Key                  string   `sentinel:"" protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Items                []*Item  `sentinel:"" protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Bucket) Descriptor

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

func (*Bucket) GetItems

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

func (*Bucket) GetKey

func (m *Bucket) GetKey() string

func (*Bucket) ProtoMessage

func (*Bucket) ProtoMessage()

func (*Bucket) Reset

func (m *Bucket) Reset()

func (*Bucket) String

func (m *Bucket) String() string

func (*Bucket) XXX_DiscardUnknown added in v0.10.2

func (m *Bucket) XXX_DiscardUnknown()

func (*Bucket) XXX_Marshal added in v0.10.2

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

func (*Bucket) XXX_Merge added in v0.10.2

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

func (*Bucket) XXX_Size added in v0.10.2

func (m *Bucket) XXX_Size() int

func (*Bucket) XXX_Unmarshal added in v0.10.2

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

type Item

type Item struct {
	ID                   string   `sentinel:"" protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	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:"-"`
}

func (*Item) Descriptor

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

func (*Item) GetID

func (m *Item) GetID() string

func (*Item) GetMessage

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

func (*Item) ProtoMessage

func (*Item) ProtoMessage()

func (*Item) Reset

func (m *Item) Reset()

func (*Item) String

func (m *Item) String() string

func (*Item) XXX_DiscardUnknown added in v0.10.2

func (m *Item) XXX_DiscardUnknown()

func (*Item) XXX_Marshal added in v0.10.2

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

func (*Item) XXX_Merge added in v0.10.2

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

func (*Item) XXX_Size added in v0.10.2

func (m *Item) XXX_Size() int

func (*Item) XXX_Unmarshal added in v0.10.2

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

type StoragePacker

type StoragePacker struct {
	// contains filtered or unexported fields
}

StoragePacker packs the objects into a specific number of buckets by hashing its ID and indexing it. Currently this supports only 256 bucket entries and hence relies on the first byte of the hash value for indexing. The items that gets inserted into the packer should implement StorageBucketItem interface.

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) BucketIndex

func (s *StoragePacker) BucketIndex(key string) uint8

BucketIndex returns the bucket key index for a given storage key

func (*StoragePacker) BucketKey

func (s *StoragePacker) BucketKey(itemID string) string

BucketKey returns the bucket key for a given item ID

func (*StoragePacker) BucketKeyHashByItemID

func (s *StoragePacker) BucketKeyHashByItemID(itemID string) string

BucketKeyHash returns the MD5 hash of the bucket storage key in which the item will be stored. The choice of MD5 is only for hash performance reasons since its value is not used for any security sensitive operation.

func (*StoragePacker) BucketKeyHashByKey

func (s *StoragePacker) BucketKeyHashByKey(bucketKey string) string

BucketKeyHashByKey returns the MD5 hash of the bucket storage key

func (*StoragePacker) BucketPath

func (s *StoragePacker) BucketPath(bucketKey string) string

BucketPath returns the storage entry key for a given bucket key

func (*StoragePacker) DeleteItem

func (s *StoragePacker) DeleteItem(itemID string) error

DeleteItem removes the storage entry which the given key refers to from its corresponding bucket.

func (*StoragePacker) GetBucket

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

Get returns a bucket for a given key

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) PutBucket

func (s *StoragePacker) PutBucket(bucket *Bucket) error

Put stores a packed bucket entry

func (*StoragePacker) PutItem

func (s *StoragePacker) PutItem(item *Item) error

PutItem stores a storage entry in its corresponding bucket

func (*StoragePacker) View

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL