Documentation ¶
Index ¶
- Constants
- Variables
- type BlockstoreLevel
- func (b *BlockstoreLevel) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (b *BlockstoreLevel) Clear() error
- func (b *BlockstoreLevel) Close() error
- func (b *BlockstoreLevel) Delete(ctx context.Context, c cid.Cid) error
- func (b *BlockstoreLevel) Get(ctx context.Context, c cid.Cid) ([]byte, error)
- func (b *BlockstoreLevel) Has(ctx context.Context, c cid.Cid) (bool, error)
- func (b *BlockstoreLevel) IsEmpty() (bool, error)
- func (b *BlockstoreLevel) Open() error
- func (b *BlockstoreLevel) Partition(tenant string) (*BlockstoreLevel, error)
- func (b *BlockstoreLevel) Put(ctx context.Context, c cid.Cid, block []byte) error
- func (b *BlockstoreLevel) PutMany(ctx context.Context, blocks map[cid.Cid][]byte) error
- type DataStoreLevel
- func (d *DataStoreLevel) Clear(ctx context.Context) error
- func (d *DataStoreLevel) Close() error
- func (d *DataStoreLevel) Delete(ctx context.Context, tenant, messageCid, dataCid string) error
- func (d *DataStoreLevel) Get(ctx context.Context, tenant, messageCid, dataCid string) (*GetResult, error)
- func (d *DataStoreLevel) Open() error
- func (d *DataStoreLevel) Put(ctx context.Context, tenant, messageCid, dataCid string, dataReader io.Reader) (*PutResult, error)
- type DataStoreLevelConfig
- type EqualFilter
- type Filter
- type GenericMessage
- type GetResult
- type IndexLevel
- func (il *IndexLevel) Clear() error
- func (il *IndexLevel) Close() error
- func (il *IndexLevel) Delete(tenant string, itemId string, options *IndexLevelOptions) error
- func (il *IndexLevel) Put(tenant string, itemId string, indexes KeyValues, options *IndexLevelOptions) error
- func (il *IndexLevel) Query(tenant string, filters []Filter, queryOptions QueryOptions, ...) ([]string, error)
- type IndexLevelConfig
- type IndexLevelOptions
- type IndexedItem
- type KeyValues
- type LevelWrapper
- func (lw *LevelWrapper) Batch(operations []LevelWrapperBatchOperation, options *LevelWrapperOptions) error
- func (lw *LevelWrapper) Clear() error
- func (lw *LevelWrapper) Close() error
- func (lw *LevelWrapper) Delete(key string, options *LevelWrapperOptions) error
- func (lw *LevelWrapper) Get(key string, options *LevelWrapperOptions) ([]byte, error)
- func (lw *LevelWrapper) Has(key string, options *LevelWrapperOptions) (bool, error)
- func (lw *LevelWrapper) IsEmpty(options *LevelWrapperOptions) (bool, error)
- func (lw *LevelWrapper) Iterator(iterOptions *LevelWrapperIteratorOptions, options *LevelWrapperOptions) (iterator.Iterator, error)
- func (lw *LevelWrapper) Keys(options *LevelWrapperOptions) (iterator.Iterator, error)
- func (lw *LevelWrapper) Open() error
- func (lw *LevelWrapper) Partition(name string) (*LevelWrapper, error)
- func (lw *LevelWrapper) Put(key string, value []byte, options *LevelWrapperOptions) error
- type LevelWrapperBatchOperation
- type LevelWrapperConfig
- type LevelWrapperIteratorOptions
- type LevelWrapperOptions
- type MessageSort
- type MessageStoreLevel
- func (msl *MessageStoreLevel) Clear() error
- func (msl *MessageStoreLevel) Close() error
- func (msl *MessageStoreLevel) Delete(tenant, cidString string, options *MessageStoreOptions) error
- func (msl *MessageStoreLevel) Get(tenant, cidString string, options *MessageStoreOptions) (GenericMessage, error)
- func (msl *MessageStoreLevel) Open() error
- func (msl *MessageStoreLevel) Put(tenant string, message GenericMessage, indexes KeyValues, ...) error
- func (msl *MessageStoreLevel) Query(tenant string, filters []Filter, messageSort *MessageSort, ...) ([]GenericMessage, string, error)
- type MessageStoreLevelConfig
- type MessageStoreOptions
- type Pagination
- type PutResult
- type QueryOptions
- type RangeFilter
- type SortDirection
Constants ¶
const ( INDEX_SUBLEVEL_NAME = "index" DELIMITER = "\x00" NEGATIVE_PREFIX = "!" NEGATIVE_OFFSET = int64(^uint64(0) >> 1) MAX_INT_STRING_LEN = 19 // Length of string representation of max int64 )
const ( SortDirectionAscending = "ascending" SortDirectionDescending = "descending" )
Variables ¶
var PlaceholderValue = []byte{0}
PlaceholderValue is used as a placeholder value for reference counting
Functions ¶
This section is empty.
Types ¶
type BlockstoreLevel ¶
type BlockstoreLevel struct {
// contains filtered or unexported fields
}
BlockstoreLevel implements the Blockstore interface using LevelDB
func NewBlockstoreLevel ¶
func NewBlockstoreLevel(path string) (*BlockstoreLevel, error)
NewBlockstoreLevel creates a new BlockstoreLevel
func (*BlockstoreLevel) AllKeysChan ¶
func (b *BlockstoreLevel) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
AllKeysChan returns a channel of all CIDs in the database
func (*BlockstoreLevel) Clear ¶
func (b *BlockstoreLevel) Clear() error
Clear deletes all entries in the database
func (*BlockstoreLevel) Delete ¶
func (b *BlockstoreLevel) Delete(ctx context.Context, c cid.Cid) error
Delete removes a block from the database
func (*BlockstoreLevel) Get ¶
func (b *BlockstoreLevel) Get(ctx context.Context, c cid.Cid) ([]byte, error)
Get retrieves a block from the database
func (*BlockstoreLevel) Has ¶
func (b *BlockstoreLevel) Has(ctx context.Context, c cid.Cid) (bool, error)
Has checks if a block exists in the database
func (*BlockstoreLevel) IsEmpty ¶
func (b *BlockstoreLevel) IsEmpty() (bool, error)
IsEmpty checks if the database is empty
func (*BlockstoreLevel) Partition ¶
func (b *BlockstoreLevel) Partition(tenant string) (*BlockstoreLevel, error)
Add a Partition method to BlockstoreLevel
type DataStoreLevel ¶
type DataStoreLevel struct {
// contains filtered or unexported fields
}
DataStoreLevel is a simple implementation of DataStore that works in both the browser and server-side. Leverages LevelDB under the hood.
It has the following structure (`+` represents a sublevel and `->` represents a key->value pair):
'data' + <tenant> + <dataCid> -> <data> 'references' + <tenant> + <dataCid> + <messageCid> -> PlaceholderValue
This allows for the <data> to be shared for everything that uses the same <dataCid> while also making sure that the <data> can only be deleted if there are no <messageCid> for any <tenant> still using it.
func NewDataStoreLevel ¶
func NewDataStoreLevel(config DataStoreLevelConfig) (*DataStoreLevel, error)
NewDataStoreLevel creates a new instance of DataStoreLevel
func (*DataStoreLevel) Clear ¶
func (d *DataStoreLevel) Clear(ctx context.Context) error
Clear deletes everything in the store
func (*DataStoreLevel) Delete ¶
func (d *DataStoreLevel) Delete(ctx context.Context, tenant, messageCid, dataCid string) error
Delete removes the reference and deletes data if it's no longer referenced
func (*DataStoreLevel) Get ¶
func (d *DataStoreLevel) Get(ctx context.Context, tenant, messageCid, dataCid string) (*GetResult, error)
Get retrieves the data if the caller has access
func (*DataStoreLevel) Open ¶
func (d *DataStoreLevel) Open() error
Open opens the datastore (no-op for LevelDB)
type DataStoreLevelConfig ¶
type DataStoreLevelConfig struct {
BlockstoreLocation string
}
DataStoreLevelConfig holds configuration options for DataStoreLevel
type EqualFilter ¶
type EqualFilter interface{}
type GenericMessage ¶
type GenericMessage interface{}
type GetResult ¶
type GetResult struct { DataCid string DataSize uint64 DataReader io.ReadCloser }
GetResult is the result of a Get operation
type IndexLevel ¶
type IndexLevel struct {
// contains filtered or unexported fields
}
func NewIndexLevel ¶
func NewIndexLevel(config IndexLevelConfig) (*IndexLevel, error)
func (*IndexLevel) Clear ¶
func (il *IndexLevel) Clear() error
func (*IndexLevel) Close ¶
func (il *IndexLevel) Close() error
func (*IndexLevel) Delete ¶
func (il *IndexLevel) Delete(tenant string, itemId string, options *IndexLevelOptions) error
func (*IndexLevel) Put ¶
func (il *IndexLevel) Put(tenant string, itemId string, indexes KeyValues, options *IndexLevelOptions) error
func (*IndexLevel) Query ¶
func (il *IndexLevel) Query(tenant string, filters []Filter, queryOptions QueryOptions, options *IndexLevelOptions) ([]string, error)
type IndexLevelConfig ¶
type IndexLevelConfig struct {
Location string
}
type IndexLevelOptions ¶
type IndexedItem ¶
type LevelWrapper ¶
type LevelWrapper struct {
// contains filtered or unexported fields
}
LevelWrapper provides a wrapper around LevelDB with partitioning support.
func NewLevelWrapper ¶
func NewLevelWrapper(config LevelWrapperConfig) *LevelWrapper
NewLevelWrapper creates a new LevelWrapper instance.
func (*LevelWrapper) Batch ¶
func (lw *LevelWrapper) Batch(operations []LevelWrapperBatchOperation, options *LevelWrapperOptions) error
Batch executes a batch of operations.
func (*LevelWrapper) Clear ¶
func (lw *LevelWrapper) Clear() error
Clear removes all entries from the database.
func (*LevelWrapper) Close ¶
func (lw *LevelWrapper) Close() error
Close closes the LevelDB database.
func (*LevelWrapper) Delete ¶
func (lw *LevelWrapper) Delete(key string, options *LevelWrapperOptions) error
Delete removes a key-value pair.
func (*LevelWrapper) Get ¶
func (lw *LevelWrapper) Get(key string, options *LevelWrapperOptions) ([]byte, error)
Get retrieves a value by key.
func (*LevelWrapper) Has ¶
func (lw *LevelWrapper) Has(key string, options *LevelWrapperOptions) (bool, error)
Has checks if a key exists.
func (*LevelWrapper) IsEmpty ¶
func (lw *LevelWrapper) IsEmpty(options *LevelWrapperOptions) (bool, error)
IsEmpty checks if the database is empty.
func (*LevelWrapper) Iterator ¶
func (lw *LevelWrapper) Iterator(iterOptions *LevelWrapperIteratorOptions, options *LevelWrapperOptions) (iterator.Iterator, error)
Iterator returns an iterator over key-value pairs with options.
func (*LevelWrapper) Keys ¶
func (lw *LevelWrapper) Keys(options *LevelWrapperOptions) (iterator.Iterator, error)
Keys returns an iterator over the keys.
func (*LevelWrapper) Partition ¶
func (lw *LevelWrapper) Partition(name string) (*LevelWrapper, error)
Partition creates a new LevelWrapper for a sublevel (partition).
func (*LevelWrapper) Put ¶
func (lw *LevelWrapper) Put(key string, value []byte, options *LevelWrapperOptions) error
Put stores a key-value pair.
type LevelWrapperBatchOperation ¶
LevelWrapperBatchOperation represents a batch operation.
type LevelWrapperConfig ¶
LevelWrapperConfig holds configuration for LevelWrapper.
type LevelWrapperIteratorOptions ¶
LevelWrapperIteratorOptions represents options for iterators.
type LevelWrapperOptions ¶
LevelWrapperOptions represents options for LevelWrapper methods.
type MessageSort ¶
type MessageSort struct { DateCreated *SortDirection DatePublished *SortDirection MessageTimestamp *SortDirection }
MessageSort specifies sorting options for messages
type MessageStoreLevel ¶
type MessageStoreLevel struct {
// contains filtered or unexported fields
}
MessageStoreLevel represents a message store using LevelDB
func NewMessageStoreLevel ¶
func NewMessageStoreLevel(config MessageStoreLevelConfig) (*MessageStoreLevel, error)
NewMessageStoreLevel creates a new MessageStoreLevel instance
func (*MessageStoreLevel) Clear ¶
func (msl *MessageStoreLevel) Clear() error
Clear removes all messages from the store
func (*MessageStoreLevel) Close ¶
func (msl *MessageStoreLevel) Close() error
Close closes the message store
func (*MessageStoreLevel) Delete ¶
func (msl *MessageStoreLevel) Delete(tenant, cidString string, options *MessageStoreOptions) error
Delete removes a message from the store
func (*MessageStoreLevel) Get ¶
func (msl *MessageStoreLevel) Get(tenant, cidString string, options *MessageStoreOptions) (GenericMessage, error)
Get retrieves a message by its CID
func (*MessageStoreLevel) Open ¶
func (msl *MessageStoreLevel) Open() error
Open opens the message store
func (*MessageStoreLevel) Put ¶
func (msl *MessageStoreLevel) Put(tenant string, message GenericMessage, indexes KeyValues, options *MessageStoreOptions) error
Put stores a new message in the store
func (*MessageStoreLevel) Query ¶
func (msl *MessageStoreLevel) Query(tenant string, filters []Filter, messageSort *MessageSort, pagination *Pagination, options *MessageStoreOptions) ([]GenericMessage, string, error)
Query retrieves messages based on filters and sorting options
type MessageStoreLevelConfig ¶
type MessageStoreLevelConfig struct { BlockstoreLocation string IndexLocation string CreateLevelDatabase func(string) (*LevelWrapper, error) }
MessageStoreLevelConfig holds configuration for MessageStoreLevel
type MessageStoreOptions ¶
MessageStoreOptions contains options for message store operations
type Pagination ¶
Pagination specifies pagination options
type QueryOptions ¶
type RangeFilter ¶
type RangeFilter map[string]interface{}
type SortDirection ¶
type SortDirection string
SortDirection represents the direction of sorting
const ( SortAscending SortDirection = "asc" SortDescending SortDirection = "desc" )
Sort direction constants