extension

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMarshal         = errors.New("extension config doesn't include '" + extensionName + "' string")
	ErrNotLayout       = errors.New("not a layout extension")
	ErrUnknown         = errors.New("unrecognized extension name")
	ErrInvalidLayoutID = errors.New("invalid object id for layout")
)

Functions

This section is empty.

Types

type Algorithm added in v0.4.0

type Algorithm interface {
	digest.Algorithm
	// Extension returns the AlgorithRegistry extension that provides the
	// algorithm.
	Extension() AlgorithmRegistry
}

Algorithm is a digest.Algorithm provided by an extension

type AlgorithmRegistry added in v0.4.0

type AlgorithmRegistry interface {
	Extension
	Algorithms() digest.AlgorithmRegistry
}

AlgorithmRegistry is an extension that provides a registry of digest algorithms

type Base added in v0.4.0

type Base struct {
	ExtensionName string `json:"extensionName"`
}

Base is a type that can be embedded by types that implement the Extension.

func (Base) Doc added in v0.4.0

func (b Base) Doc() string

Doc returns documentation string (markdown format) for the extension, if available.

func (Base) Name added in v0.4.0

func (b Base) Name() string

type Extension

type Extension interface {
	Name() string // Name returns the extension name
	Doc() string  // Extension documentation in markdown format (if available)
}

Extension is implemented by types that represent specific OCFL Extensions. See https://github.com/OCFL/extensions

func Ext0001 added in v0.4.0

func Ext0001() Extension

func Ext0002

func Ext0002() Extension

Ext0002 returns new instance of 0002-flat-direct-storage-layout with default values

func Ext0003

func Ext0003() Extension

Ext0003 returns a new instance of 0003-hash-and-id-n-tuple-storage-layout with default values

func Ext0004

func Ext0004() Extension

Ext0004 returns a new instance of 0004-hashed-n-tuple-storage-layout

func Ext0006

func Ext0006() Extension

Ext0006 returns a new instance of 0006-flat-omit-prefix-storage-layout with default values

func Ext0007

func Ext0007() Extension

Ext0007 returns a new instance of 0007-n-tuple-omit-prefix-storage-layout with default values

func Ext0009 added in v0.4.0

func Ext0009() Extension

func Get

func Get(name string) (Extension, error)

Get returns a new instance of the named extension with default values. DEPRECATED.

type Layout

type Layout interface {
	Extension
	// Resolve resolves an object ID into a storage root path
	Resolve(id string) (path string, err error)
	// Valid returns an error if the layout configuation is invalid
	Valid() error
}

Layout is an extension that provides a function for resolving object IDs to Storage Root Paths

type LayoutFlatDirect

type LayoutFlatDirect struct {
	Base
}

LayoutFlatDirect implements 0002-flat-direct-storage-layout

func (LayoutFlatDirect) Resolve

func (l LayoutFlatDirect) Resolve(id string) (string, error)

func (LayoutFlatDirect) Valid added in v0.2.0

func (l LayoutFlatDirect) Valid() error

type LayoutFlatOmitPrefix

type LayoutFlatOmitPrefix struct {
	Base
	Delimiter string `json:"delimiter"`
}

LayoutFlatOmitPrefix implements 0006-flat-omit-prefix-storage-layout

func (LayoutFlatOmitPrefix) Resolve

func (l LayoutFlatOmitPrefix) Resolve(id string) (string, error)

func (LayoutFlatOmitPrefix) Valid added in v0.2.0

func (l LayoutFlatOmitPrefix) Valid() error

type LayoutHashIDTuple

type LayoutHashIDTuple struct {
	Base
	DigestAlgorithm string `json:"digestAlgorithm"`
	TupleSize       int    `json:"tupleSize"`
	TupleNum        int    `json:"numberOfTuples"`
}

LayoutHashIDTuple implements 0003-hash-and-id-n-tuple-storage-layout

func (LayoutHashIDTuple) Resolve

func (l LayoutHashIDTuple) Resolve(id string) (string, error)

func (LayoutHashIDTuple) Valid added in v0.2.0

func (l LayoutHashIDTuple) Valid() error

type LayoutHashTuple

type LayoutHashTuple struct {
	Base
	DigestAlgorithm string `json:"digestAlgorithm"`
	TupleSize       int    `json:"tupleSize"`
	TupleNum        int    `json:"numberOfTuples"`
	Short           bool   `json:"shortObjectRoot"`
}

LayoutHashTuple implements 0004-hashed-n-tuple-storage-layout

func (LayoutHashTuple) Resolve

func (l LayoutHashTuple) Resolve(id string) (string, error)

func (LayoutHashTuple) Valid added in v0.2.0

func (l LayoutHashTuple) Valid() error

type LayoutTupleOmitPrefix

type LayoutTupleOmitPrefix struct {
	Base
	Delimiter string `json:"delimiter"`
	TupleSize int    `json:"tupleSize"`
	TupleNum  int    `json:"numberOfTuples"`
	Padding   string `json:"zeroPadding"`
	Reverse   bool   `json:"reverseObjectRoot"`
}

LayoutTupleOmitPrefix implements 0007-n-tuple-omit-prefix-storage-layout

func (LayoutTupleOmitPrefix) MarshalJSON

func (l LayoutTupleOmitPrefix) MarshalJSON() ([]byte, error)

func (LayoutTupleOmitPrefix) Resolve

func (l LayoutTupleOmitPrefix) Resolve(id string) (string, error)

func (LayoutTupleOmitPrefix) Valid added in v0.2.0

func (l LayoutTupleOmitPrefix) Valid() error

type Registry added in v0.4.0

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

Registry is an immutable container of Extension constructors.

func DefaultRegistry added in v0.4.0

func DefaultRegistry() Registry

DefaultRegistry returns a new Registry with default Extension constructors.

func NewRegistry added in v0.4.0

func NewRegistry(extFns ...func() Extension) Registry

NewRegistry returns a Registry for the given extension constructors

func (Registry) Append added in v0.4.0

func (r Registry) Append(extFns ...func() Extension) Registry

Append returns a new Registry that includes extension constructors from r plus additional constructors. If the added extension constructors have the same name as those in r, the new registry will use the added constructor.

func (Registry) Names added in v0.4.0

func (r Registry) Names() []string

Names returns names of all Extensions constructors in r.

func (Registry) New added in v0.4.0

func (r Registry) New(name string) (Extension, error)

New returns a new Extension value for the given extension name or returns an error if the extension is not present in the registry. The returned Extension should have default values (or zero-values where defaults are not defined).

func (Registry) NewLayout added in v0.4.0

func (r Registry) NewLayout(name string) (Layout, error)

NewLayout is the same as New with an additional check that the extension is a layout.

func (Registry) Unmarshal added in v0.4.0

func (r Registry) Unmarshal(jsonBytes []byte) (Extension, error)

Unmarshal decodes the extension config json and returns a new extension instance.

Jump to

Keyboard shortcuts

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