fstorage

package
v0.0.0-...-432d548 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// For these you don't care the write/read sequence
	StorePoolLBTypeRR   = 1
	StorePoolLBTypeHash = 2
)

Store pool load balancing type

View Source
const DefaultTimeout = 10 // seconds

DefaultTimeout is the timeout to operate on remote kv storage.

View Source
const OptionKey = "__options__"

OptionKey ...

View Source
const Prefix = "kv://"

Prefix ...

Variables

This section is empty.

Functions

func JoinPath

func JoinPath(urlStr string, sub ...string) string

JoinPath joins a sub directory(location) to url.

func Register

func Register(name string, factory LocationFactory) error

Register regists a new location implementation.

func SetZkSilentLogger

func SetZkSilentLogger()

SetZkSilentLogger disable zk logger.

Types

type CompressStorage

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

CompressStorage is a wrapper storage which compress the data.

func (*CompressStorage) Close

func (c *CompressStorage) Close() error

Close close the storage.

func (*CompressStorage) Create

func (c *CompressStorage) Create() error

Create creates the storage.

func (*CompressStorage) Exists

func (c *CompressStorage) Exists() (bool, error)

Exists check if the storage exists.

func (*CompressStorage) Read

func (c *CompressStorage) Read() ([]byte, error)

Read reads data from storage.

func (*CompressStorage) Remove

func (c *CompressStorage) Remove() error

Remove removes the storage.

func (*CompressStorage) Write

func (c *CompressStorage) Write(bs []byte) error

Write writes data to storage.

type FStorage

type FStorage interface {
	Write([]byte) error
	Read() ([]byte, error)
	Exists() (bool, error)
	Create() error
	Remove() error
	Close() error
}

FStorage abstracs a file-like storage.

func MakeCompressive

func MakeCompressive(fs FStorage) FStorage

MakeCompressive wraps a storage compressive.

func MakeCompressiveNotify

func MakeCompressiveNotify(fs FStorage, cb func([]byte)) FStorage

MakeCompressiveNotify same as MakeCompressive but with a notifier which notified the compressed data.

type KVStore

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

KVStore is a kv storage implementation.

func (*KVStore) Close

func (k *KVStore) Close() error

Close close the storage.

func (*KVStore) Create

func (k *KVStore) Create() error

Create creates the storage.

func (*KVStore) Exists

func (k *KVStore) Exists() (bool, error)

Exists check if the storage exists.

func (*KVStore) Read

func (k *KVStore) Read() ([]byte, error)

func (*KVStore) Remove

func (k *KVStore) Remove() error

Remove remove the storage.

func (*KVStore) Write

func (k *KVStore) Write(bs []byte) error

type KVStoreFactory

type KVStoreFactory struct{}

KVStoreFactory creates kv store location.

func (*KVStoreFactory) Create

func (k *KVStoreFactory) Create(u *url.URL) (Location, error)

Create create a location.

type KVStoreFactoryZfs

type KVStoreFactoryZfs struct{}

KVStoreFactoryZfs is a wrapper to create storage location by zk url.

func (*KVStoreFactoryZfs) Create

func (k *KVStoreFactoryZfs) Create(u *url.URL) (Location, error)

Create creates a zk location.

type KVStoreLocation

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

KVStoreLocation implements kv storage location.

func (*KVStoreLocation) Close

func (k *KVStoreLocation) Close() error

Close close this location

func (*KVStoreLocation) Create

func (k *KVStoreLocation) Create(sub string) (FStorage, error)

Create creates the location.

func (*KVStoreLocation) List

func (k *KVStoreLocation) List() ([]string, error)

List lists the storage(file) in this location.

func (*KVStoreLocation) New

func (k *KVStoreLocation) New(sub string) (FStorage, error)

New new a sub storage object.

func (*KVStoreLocation) NewSubLocation

func (k *KVStoreLocation) NewSubLocation(sub ...string) (Location, error)

NewSubLocation new sub location by this location. All sub locations share the same store (usually connection) with root location. It's ok to close or not close the sub locaiton

type KVURL

type KVURL struct {
	Schema   string
	Endpoint string
	Option   *options
}

KVURL ...

type KVURLParser

type KVURLParser struct {
}

KVURLParser ... Schema: kv://endpoint?_options_=k:v[,k:v]

type LocalFile

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

LocalFile local file implementation.

func (*LocalFile) Close

func (l *LocalFile) Close() error

Close close the storage.

func (*LocalFile) Create

func (l *LocalFile) Create() error

Create creates the storage.

func (*LocalFile) Exists

func (l *LocalFile) Exists() (bool, error)

Exists check if the storage exists.

func (*LocalFile) Read

func (l *LocalFile) Read() ([]byte, error)

func (*LocalFile) Remove

func (l *LocalFile) Remove() error

Remove removes the storage.

func (*LocalFile) Write

func (l *LocalFile) Write(bs []byte) error

Write writes storage.

type LocalFileFactory

type LocalFileFactory struct{}

LocalFileFactory creates a local file location.

func (*LocalFileFactory) Create

func (l *LocalFileFactory) Create(u *url.URL) (Location, error)

Create creates a location.

type LocalFileLocation

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

LocalFileLocation implements the local file location.

func (*LocalFileLocation) Close

func (l *LocalFileLocation) Close() error

Close close this location

func (*LocalFileLocation) Create

func (l *LocalFileLocation) Create(sub string) (FStorage, error)

Create creates a sub storage in this location.

func (*LocalFileLocation) List

func (l *LocalFileLocation) List() ([]string, error)

List lists the file in this location.

func (*LocalFileLocation) New

func (l *LocalFileLocation) New(sub string) (FStorage, error)

New new a sub storage from this location.

func (*LocalFileLocation) NewSubLocation

func (l *LocalFileLocation) NewSubLocation(sub ...string) (Location, error)

NewSubLocation new a sub location.

type Location

type Location interface {
	List() ([]string, error)
	New(sub string) (FStorage, error)
	Create(sub string) (FStorage, error)
	NewSubLocation(sub ...string) (Location, error)
	Close() error
}

Location abstracs storage location, like a file direcotry.

func Create

func Create(urlStr string) (Location, error)

Create creates a location object by file url.

func CreateWithBackup

func CreateWithBackup(urlStr, backupURLStr string) (Location, error)

CreateWithBackup creates a location object by file url.

type LocationFactory

type LocationFactory interface {
	Create(u *url.URL) (Location, error)
}

LocationFactory creates a location.

type MasterSlaveLocation

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

MasterSlaveLocation implements the master&slave location.

func (*MasterSlaveLocation) Close

func (m *MasterSlaveLocation) Close() error

Close close this location

func (*MasterSlaveLocation) Create

func (m *MasterSlaveLocation) Create(sub string) (FStorage, error)

Create creates a sub storage in this locatio with cache

func (*MasterSlaveLocation) List

func (m *MasterSlaveLocation) List() ([]string, error)

List lists the file in this location.

func (*MasterSlaveLocation) New

func (m *MasterSlaveLocation) New(sub string) (FStorage, error)

New new a sub storage from this location.

func (*MasterSlaveLocation) NewSubLocation

func (m *MasterSlaveLocation) NewSubLocation(sub ...string) (Location, error)

NewSubLocation new a sub location.

type MasterSlaveStore

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

MasterSlaveStore master&slave store implementation.

func (*MasterSlaveStore) Close

func (l *MasterSlaveStore) Close() error

Close close the storage.

func (*MasterSlaveStore) Create

func (l *MasterSlaveStore) Create() error

Create creates the storage.

func (*MasterSlaveStore) Exists

func (l *MasterSlaveStore) Exists() (bool, error)

Exists check if the storage exists.

func (*MasterSlaveStore) Read

func (l *MasterSlaveStore) Read() ([]byte, error)

func (*MasterSlaveStore) Remove

func (l *MasterSlaveStore) Remove() error

Remove removes the storage.

func (*MasterSlaveStore) Write

func (l *MasterSlaveStore) Write(bs []byte) error

Write writes storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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