Documentation
¶
Index ¶
- Constants
- func JoinPath(urlStr string, sub ...string) string
- func Register(name string, factory LocationFactory) error
- func SetZkSilentLogger()
- type CompressStorage
- type FStorage
- type KVStore
- type KVStoreFactory
- type KVStoreFactoryZfs
- type KVStoreLocation
- type KVURL
- type KVURLParser
- type LocalFile
- type LocalFileFactory
- type LocalFileLocation
- type Location
- type LocationFactory
- type MasterSlaveLocation
- func (m *MasterSlaveLocation) Close() error
- func (m *MasterSlaveLocation) Create(sub string) (FStorage, error)
- func (m *MasterSlaveLocation) List() ([]string, error)
- func (m *MasterSlaveLocation) New(sub string) (FStorage, error)
- func (m *MasterSlaveLocation) NewSubLocation(sub ...string) (Location, error)
- type MasterSlaveStore
Constants ¶
const ( // For these you don't care the write/read sequence StorePoolLBTypeRR = 1 StorePoolLBTypeHash = 2 )
Store pool load balancing type
const DefaultTimeout = 10 // seconds
DefaultTimeout is the timeout to operate on remote kv storage.
const OptionKey = "__options__"
OptionKey ...
const Prefix = "kv://"
Prefix ...
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, factory LocationFactory) error
Register regists a new location implementation.
Types ¶
type CompressStorage ¶
type CompressStorage struct {
// contains filtered or unexported fields
}
CompressStorage is a wrapper storage which compress the data.
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 ¶
MakeCompressive wraps a storage compressive.
func MakeCompressiveNotify ¶
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.
type KVStoreFactoryZfs ¶
type KVStoreFactoryZfs struct{}
KVStoreFactoryZfs is a wrapper to create storage location by zk url.
type KVStoreLocation ¶
type KVStoreLocation struct {
// contains filtered or unexported fields
}
KVStoreLocation implements kv storage 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 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.
type LocalFileFactory ¶
type LocalFileFactory struct{}
LocalFileFactory creates a local file 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 CreateWithBackup ¶
CreateWithBackup creates a location object by file url.
type LocationFactory ¶
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) 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.