Documentation
¶
Index ¶
- Constants
- Variables
- func Add(registry Registry, key K, value interface{})
- func MakePath(parentDir string, fileName string) (string, error)
- func Store(persistence Persistence, key Key, value interface{})
- func ToFile(path string, name string, ext string, content []fmt.Stringer) (string, error)
- type EventRegistry
- type K
- type Key
- type MockRegistry
- func (m *MockRegistry) Add(key K, value interface{}) error
- func (m *MockRegistry) Check(key K) (map[string]RegistryPath, error)
- func (m *MockRegistry) GetAll(key K, value interface{}) error
- func (m *MockRegistry) GetFor(key K, value interface{}, filter func(s string) bool) error
- func (m *MockRegistry) Root() string
- type MockStorage
- type Persistence
- type Registry
- type RegistryPath
- type Shard
- type VoidRegistry
- func (v VoidRegistry) Add(key K, value interface{}) error
- func (v VoidRegistry) Check(key K) (map[string]RegistryPath, error)
- func (v VoidRegistry) GetAll(key K, value interface{}) error
- func (v VoidRegistry) GetFor(key K, value interface{}, filter func(s string) bool) error
- func (v VoidRegistry) Root() string
- type VoidStorage
Constants ¶
View Source
const ( BookDir = "book" HistoryDir = "history" RegistryDir = "registry" BackTestRegistryPath = "backtest-events" EventsPath = "events" SignalsPath = "signals" BackTestInternalPath = "backtest-internal" InternalPath = "internal" )
Variables ¶
View Source
var ( NotFoundErr = errors.New("not found") CouldNotLoadErr = errors.New("could not load") UnrecoverableErr = errors.New("unrecoverable error") )
View Source
var ( // DefaultDir is the default storage directory // TODO : leaving this for now to be able to adjust for the tests DefaultDir = "file-storage" )
Functions ¶
func Store ¶
func Store(persistence Persistence, key Key, value interface{})
Types ¶
type EventRegistry ¶
EventRegistry creates a registry for the given path
func MockEventRegistry ¶
func MockEventRegistry() EventRegistry
type MockRegistry ¶
type MockRegistry struct {
Events map[K][]interface{}
}
func NewMockRegistry ¶
func NewMockRegistry() *MockRegistry
func (*MockRegistry) Add ¶
func (m *MockRegistry) Add(key K, value interface{}) error
func (*MockRegistry) Check ¶
func (m *MockRegistry) Check(key K) (map[string]RegistryPath, error)
func (*MockRegistry) GetAll ¶
func (m *MockRegistry) GetAll(key K, value interface{}) error
func (*MockRegistry) GetFor ¶
func (m *MockRegistry) GetFor(key K, value interface{}, filter func(s string) bool) error
func (*MockRegistry) Root ¶
func (m *MockRegistry) Root() string
type MockStorage ¶
type MockStorage struct {
Elements map[Key]interface{}
}
func NewMockStorage ¶
func NewMockStorage() *MockStorage
func (*MockStorage) FileName ¶
func (m *MockStorage) FileName() string
func (*MockStorage) Load ¶
func (m *MockStorage) Load(k Key, value interface{}) error
func (*MockStorage) Store ¶
func (m *MockStorage) Store(k Key, value interface{}) error
type Persistence ¶
type Persistence interface { Store(k Key, value interface{}) error Load(k Key, value interface{}) error }
Persistence is a batch storage that offers the functionality to store and load large objects at once.
type Registry ¶
type Registry interface { Add(key K, value interface{}) error GetAll(key K, value interface{}) error GetFor(key K, value interface{}, filter func(s string) bool) error Check(key K) (map[string]RegistryPath, error) Root() string }
Registry is a storage pattern like a logger or event registry. It receives events one by one, but loads all of them at once.
type RegistryPath ¶
RegistryPath defines a registry path with including files
type Shard ¶
type Shard func(shard string) (Persistence, error)
Shard creates a new storage implementation for the given shard.
type VoidRegistry ¶
type VoidRegistry struct { }
VoidRegistry is a dummy event logger which ignores all calls
func NewVoidRegistry ¶
func NewVoidRegistry() *VoidRegistry
NewVoidRegistry creates a new noop registry
func (VoidRegistry) Add ¶
func (v VoidRegistry) Add(key K, value interface{}) error
func (VoidRegistry) Check ¶
func (v VoidRegistry) Check(key K) (map[string]RegistryPath, error)
func (VoidRegistry) GetAll ¶
func (v VoidRegistry) GetAll(key K, value interface{}) error
func (VoidRegistry) GetFor ¶
func (v VoidRegistry) GetFor(key K, value interface{}, filter func(s string) bool) error
func (VoidRegistry) Root ¶
func (v VoidRegistry) Root() string
type VoidStorage ¶
type VoidStorage struct { }
VoidStorage is a noop storage
func (VoidStorage) FileName ¶
func (d VoidStorage) FileName() string
func (VoidStorage) Load ¶
func (d VoidStorage) Load(k Key, value interface{}) error
func (VoidStorage) Store ¶
func (d VoidStorage) Store(k Key, value interface{}) error
Click to show internal directories.
Click to hide internal directories.