inmemdatastore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RecFieldId = "id"
)

Variables

This section is empty.

Functions

func GetAvroCodec added in v0.2.0

func GetAvroCodec(schema string) (*goavro.Codec, error)

func GetDatastoreShardId added in v0.2.0

func GetDatastoreShardId(key string, numShards int) uint64

Types

type AvroFileWriter added in v0.2.0

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

func NewAvroFileWriter added in v0.2.0

func NewAvroFileWriter(ctx context.Context, wg *sync.WaitGroup, cfg AvroFileWriterConfig) *AvroFileWriter

func (*AvroFileWriter) Shutdown added in v0.2.0

func (a *AvroFileWriter) Shutdown()

func (*AvroFileWriter) Write added in v0.2.0

func (a *AvroFileWriter) Write(data interface{}) error

type AvroFileWriterConfig added in v0.2.0

type AvroFileWriterConfig struct {
	Id         int
	AvroSchema string
	OutputDir  string
}

type AvroSerializer added in v0.2.0

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

func (*AvroSerializer) Serialize added in v0.2.0

func (a *AvroSerializer) Serialize(record map[string]interface{}) (interface{}, error)

type Config

type Config struct {
	NumDatastoreShards      int
	PersistenceChan         PersistenceChan
	PersistanceChanBuffSize int
	Persisters              Persisters
	// The top-level key in the map[string]interface{} records that will be stored in the
	// InMemoryDataStore.  This is required for the Put method to process a new record.
	RecordTimestampKey string
}

type Datastore added in v0.2.0

type Datastore struct {
	Id        uint64
	Data      map[string]interface{}
	NumReads  int64
	NumWrites int64
	// contains filtered or unexported fields
}

func NewDatastore added in v0.2.0

func NewDatastore(id uint64) *Datastore

type Datastores added in v0.2.0

type Datastores map[uint64]*Datastore

type InMemDataStore

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

func NewInMemDatastore

func NewInMemDatastore(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, cfg Config) *InMemDataStore

func (*InMemDataStore) Get

func (ds *InMemDataStore) Get(key string) (interface{}, error)

func (*InMemDataStore) GetAll

func (ds *InMemDataStore) GetAll() map[string]interface{}

GetAll will return the entire in memory data store. For a production grade piece of software we would have to do something other than just returning a reference to the private map, such as a deep copy. For now, this is just here to facilitate testing.

func (*InMemDataStore) GetDatastores added in v0.2.0

func (ds *InMemDataStore) GetDatastores() Datastores

func (*InMemDataStore) Put

func (ds *InMemDataStore) Put(key string, val map[string]interface{}) error

func (*InMemDataStore) Shutdown

func (ds *InMemDataStore) Shutdown()

Shutdown will signal the Serializers to close their open file handles and shutdown the IMDS.

func (*InMemDataStore) Start

func (ds *InMemDataStore) Start()

Start will spin up the Persisters and when it returns will be ready for reads and writes.

type NoopSerializer added in v0.2.0

type NoopSerializer struct{}

func (*NoopSerializer) Serialize added in v0.2.0

func (n *NoopSerializer) Serialize(record map[string]interface{}) (interface{}, error)

type PersistenceChan added in v0.2.0

type PersistenceChan chan map[string]interface{}

type Persister added in v0.2.0

type Persister struct {
	Serializer
	Writer
	// contains filtered or unexported fields
}

func NewPersister added in v0.2.0

func NewPersister(ctx context.Context, wg *sync.WaitGroup, cfg PersisterConfig) *Persister

func (*Persister) Run added in v0.2.0

func (p *Persister) Run()

type PersisterConfig added in v0.2.0

type PersisterConfig struct {
	Id         int
	Serializer Serializer
	Writer     Writer
	InputChan  PersistenceChan
}

type Persisters added in v0.2.0

type Persisters map[int]*Persister

type Serializer

type Serializer interface {
	Serialize(map[string]interface{}) (interface{}, error)
}

func NewAvroSerializer added in v0.2.0

func NewAvroSerializer(avroSchema string) Serializer

func NewNoopSerializer added in v0.2.0

func NewNoopSerializer() Serializer

type Writer added in v0.2.0

type Writer interface {
	Write(interface{}) error
	Shutdown()
}

Jump to

Keyboard shortcuts

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