object

package
v0.3.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Overview

Package object implements repository support for content-addressable objects of arbitrary size.

Index

Constants

View Source
const DefaultSplitter = "DYNAMIC-4M-BUZHASH"

DefaultSplitter is the name of the splitter used by default for new repositories.

Variables

View Source
var ErrObjectNotFound = errors.New("object not found")

ErrObjectNotFound is returned when an object cannot be found.

View Source
var SupportedSplitters []string

SupportedSplitters is a list of supported object splitters.

Functions

This section is empty.

Types

type Format

type Format struct {
	Splitter string `json:"splitter,omitempty"` // splitter used to break objects into pieces of content
}

Format describes the format of objects in a repository.

type HasObjectID

type HasObjectID interface {
	ObjectID() ID
}

HasObjectID exposes the identifier of an object.

type ID

type ID string

ID is an identifier of a repository object. Repository objects can be stored.

  1. In a single content block, this is the most common case for small objects.
  2. In a series of content blocks with an indirect block pointing at them (multiple indirections are allowed). This is used for larger files. Object IDs using indirect blocks start with "I"

func DirectObjectID

func DirectObjectID(contentID content.ID) ID

DirectObjectID returns direct object ID based on the provided block ID.

func IndirectObjectID

func IndirectObjectID(indexObjectID ID) ID

IndirectObjectID returns indirect object ID based on the underlying index object ID.

func ParseID

func ParseID(s string) (ID, error)

ParseID converts the specified string into object ID

func (ID) ContentID

func (i ID) ContentID() (content.ID, bool)

ContentID returns the ID of the underlying content.

func (ID) IndexObjectID

func (i ID) IndexObjectID() (ID, bool)

IndexObjectID returns the object ID of the underlying index object.

func (ID) String

func (i ID) String() string

String returns string representation of ObjectID that is suitable for displaying in the UI.

func (ID) Validate

func (i ID) Validate() error

Validate checks the ID format for validity and reports any errors.

type Manager

type Manager struct {
	Format Format
	// contains filtered or unexported fields
}

Manager implements a content-addressable storage on top of blob storage.

func NewObjectManager

func NewObjectManager(ctx context.Context, bm contentManager, f Format, opts ManagerOptions) (*Manager, error)

NewObjectManager creates an ObjectManager with the specified content manager and format.

func (*Manager) NewWriter

func (om *Manager) NewWriter(ctx context.Context, opt WriterOptions) Writer

NewWriter creates an ObjectWriter for writing to the repository.

func (*Manager) Open

func (om *Manager) Open(ctx context.Context, objectID ID) (Reader, error)

Open creates new ObjectReader for reading given object from a repository.

func (*Manager) VerifyObject

func (om *Manager) VerifyObject(ctx context.Context, oid ID) (int64, []content.ID, error)

VerifyObject ensures that all objects backing ObjectID are present in the repository and returns the total length of the object and content IDs of which it is composed.

type ManagerOptions

type ManagerOptions struct {
	Trace func(message string, args ...interface{})
}

ManagerOptions specifies object manager options.

type Reader

type Reader interface {
	io.Reader
	io.Seeker
	io.Closer
	Length() int64
}

Reader allows reading, seeking, getting the length of and closing of a repository object.

type Splitter

type Splitter interface {
	ShouldSplit(b byte) bool
}

Splitter determines when to split a given object. It must return true if the object should be split after byte b is processed.

type SplitterFactory

type SplitterFactory func() Splitter

SplitterFactory creates instances of Splitter

func GetSplitterFactory

func GetSplitterFactory(name string) SplitterFactory

GetSplitterFactory gets splitter factory with a specified name or nil if not found.

type Writer

type Writer interface {
	io.WriteCloser

	Result() (ID, error)
}

Writer allows writing content to the storage and supports automatic deduplication and encryption of written data.

type WriterOptions

type WriterOptions struct {
	Description string
	Prefix      content.ID // empty string or a single-character ('g'..'z')
}

WriterOptions can be passed to Repository.NewWriter()

Jump to

Keyboard shortcuts

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