objects

package
v0.0.0-...-39628cf Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJSON

func CreateJSON(b Objects, v interface{}) (string, error)

CreateJSON creates an object blob that is the marshalling of the object.

func DestroyPsql

func DestroyPsql(db *sqlx.DB) error

DestroyPsql destroys the object store database.

func InitPsql

func InitPsql(b *sqlx.DB) error

InitPsql initializes the object store database.

func ReadJSON

func ReadJSON(b Objects, k string, v interface{}) error

ReadJSON reads an object blob and unmarshals it into a JSON object.

Types

type Objects

type Objects interface {
	// Open opens a new blob.
	Open(key string) (io.ReadCloser, error)

	// Create a new object for writing.
	Create(r io.Reader) (string, error)

	// Has checks if an object exists.
	Has(key string) (bool, error)
}

Objects provides a simple immutable key value store interface for saving blob objects.

func NewFS

func NewFS(dir string) (Objects, error)

NewFS returns a new file system based object store.

func NewMapped

func NewMapped(s Store) Objects

NewMapped creates a Objects Store from the old-fashioned Store interface.

func NewMem

func NewMem() Objects

NewMem creates a new in-memory object store that support streaming.

type Store

type Store interface {
	// New creates a blob, returning the blob key.
	Put(bs []byte) (string, error)

	// Get fetches the content of a blob, returning the blob content.
	Get(key string) ([]byte, error)

	// Has checks if a blob of the key exists.
	Has(key string) (bool, error)
}

Store provides a simple immutable key value store interface for saving blob objects.

func NewMemStore

func NewMemStore() Store

NewMemStore creates a new in-memory object store.

func NewPsql

func NewPsql(db *sqlx.DB) Store

NewPsql wraps a database connection into a store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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