sstore

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 19 Imported by: 2

README

sstore

stream store

Documentation

Overview

Copyright 2020-2026 The sstore Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const KB = 1024
View Source
const MB = 1024 * 1024

Variables

View Source
var (
	ErrOffset            = errors.New("offset error")
	ErrNoFindStream      = errors.New("no find stream")
	ErrNoFindIndexInfo   = errors.New("no find index info")
	ErrNoFindOffsetIndex = errors.New("no find offset index")
	ErrNoFindSegment     = errors.New("no find segment")
	ErrWhence            = errors.New("whence error")
	ErrWal               = errors.New("journal error")
	ErrClose             = errors.New("SStore close")
)

Functions

This section is empty.

Types

type JournalMeta

type JournalMeta struct {
	Old          bool   `json:"old"`
	Filename     string `json:"filename"`
	Version      string `json:"version"`
	FirstEntryID int64  `json:"first_entry_id"`
	LastEntryID  int64  `json:"last_entry_id"`
}

type Options

type Options struct {
	Path                          string `json:"path"`
	ManifestDir                   string `json:"manifest_dir"`
	WalDir                        string `json:"wal_dir"`
	SegmentDir                    string `json:"segment_dir"`
	MaxSegmentCount               int    `json:"max_segment_count"`
	BlockSize                     int    `json:"block_size"`
	MaxMStreamTableSize           int64  `json:"max_mStream_table_size"`
	MaxImmutableMStreamTableCount int    `json:"max_immutable_mStream_table_count"`
	EntryQueueCap                 int    `json:"entry_queue_cap"`
	MaxWalSize                    int64  `json:"max_wal_size"`
}

func DefaultOptions

func DefaultOptions(Path string) Options

func (Options) WithBlockSize

func (opt Options) WithBlockSize(val int) Options

WithBlockSize

func (Options) WithEntryQueueCap

func (opt Options) WithEntryQueueCap(val int) Options

EntryQueueCap

func (Options) WithFilesDir

func (opt Options) WithFilesDir(val string) Options

WithFilesDir

func (Options) WithMaxImmutableMStreamTableCount

func (opt Options) WithMaxImmutableMStreamTableCount(val int) Options

MaxImmutableMStreamTableCount

func (Options) WithMaxMStreamTableSize

func (opt Options) WithMaxMStreamTableSize(val int64) Options

WithMaxMStreamTableSize

func (Options) WithMaxSegmentCount

func (opt Options) WithMaxSegmentCount(val int) Options

WithMaxSegmentCount

func (Options) WithMaxWalSize

func (opt Options) WithMaxWalSize(val int64) Options

WithMaxWalSize

func (Options) WithSegmentDir

func (opt Options) WithSegmentDir(val string) Options

WithSegmentDir

func (Options) WithWalPath

func (opt Options) WithWalPath(val string) Options

WithWalPath

type SStore

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

func Open

func Open(options Options) (*SStore, error)

func (*SStore) Append

func (sstore *SStore) Append(streamID int64, data []byte, offset int64) (int64, error)

Append append the data to end of the stream return offset to the data

func (*SStore) AsyncAppend

func (sstore *SStore) AsyncAppend(streamID int64, data []byte, offset int64, cb func(offset int64, err error))

AsyncAppend async append the data to end of the stream

func (*SStore) Begin

func (sstore *SStore) Begin(streamID int64) (int64, bool)

base return the begin of stream. return 0,false when the stream no exist

func (*SStore) Close

func (sstore *SStore) Close() error

Close sstore

func (*SStore) End

func (sstore *SStore) End(streamID int64) (int64, bool)

size return the end of stream. return _,false when the stream no exist

func (*SStore) Exist

func (sstore *SStore) Exist(streamID int64) bool

Exist return true if the stream exist otherwise return false

func (*SStore) GC

func (sstore *SStore) GC() error

GC will delete useless journal manifest,segments

func (*SStore) GetSnapshot

func (sstore *SStore) GetSnapshot() Snapshot

func (*SStore) Options

func (sstore *SStore) Options() Options

func (*SStore) Reader

func (sstore *SStore) Reader(streamID int64) (io.ReadSeeker, error)

Reader create Reader of the stream

func (*SStore) Watcher

func (sstore *SStore) Watcher(streamID int64) Watcher

Watcher create watcher of the stream

type Snapshot

type Snapshot struct {
	EndMap  map[int64]int64 `json:"end_map"`
	Version Version         `json:"version"`
}

type Version

type Version struct {
	Term  int64
	Index int64
}

type Watcher

type Watcher interface {
	//Watch return chan for watching the end of stream
	Watch() chan int64
	Close()
}

Jump to

Keyboard shortcuts

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