status

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// DefaultEventsTTLSeconds is the default value for EventsTTLSeconds used by NewSNutsDBStatusBuilder
	DefaultEventsTTLSeconds uint32 = 3600
	// DefaultBufferSize is the default size of the total events buffer manged by Status
	// implementation
	DefaultBufferSize uint = 500000
	// DefaultFilesToConsolidateDb is the default value used when NutsDBStatusBuilder.FilesToConsolidateDb
	// is not called or not set
	DefaultFilesToConsolidateDb = 5
	// DefaultRecreateDbClientAfterConsolidation is the default value used when
	// NutsDBStatusBuilder.RecreateDbClientAfterConsolidation is not called
	DefaultRecreateDbClientAfterConsolidation = true
)

Variables

View Source
var (
	// ErrRecordEvicted is the error returned when EventRecord was expired
	ErrRecordEvicted error = errors.New("EventRecord evicted")
	// ErrRecordNotFoundInIdx is the error returned when EventRecord was not found in the index
	ErrRecordNotFoundInIdx error = errors.New("EventRecord not found in index")
	// ErrIdxNoIntialized is the error returned when Internal index was not propertly initialized
	ErrIdxNoIntialized = fmt.Errorf("index was not properly initialized")
)

Functions

func IsNotFoundErr

func IsNotFoundErr(err error) bool

IsNotFoundErr check and return if error parameter is one of the "Not found" recognized errors returned by nutsdb operations.

func NumberOfFiles

func NumberOfFiles(path string) int

NumberOfFiles return the number of files, really non directories elements, in a directory path without entering in sub-directories

Types

type Builder

type Builder interface {
	Build() (Status, error)
}

Builder is the abstrastraction of any Status Builder implementation

type EventRecord

type EventRecord struct {
	AsyncIDs   []string
	Timestamp  time.Time
	Tag        string
	Msg        string
	Compressor *compressor.Compressor
	LastError  error
}

EventRecord is the record to save and retrieve events in/from status The events are the messages that can be send used the client to Devo

func (*EventRecord) EffectiveID

func (er *EventRecord) EffectiveID() string

EffectiveID return the last value of ID, that is the updated value of the ID in EventRecord

func (*EventRecord) Serialize

func (er *EventRecord) Serialize() ([]byte, error)

Serialize transforms EventRecord to byte slice

type NutsDBStatus

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

NutsDBStatus is the nutsdb implementation of Status interface

Example (FindAll)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_findAll")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_findAll").
	EventsTTLSeconds(1).
	Build()
if err != nil {
	panic(err)
}

// The record
r := &EventRecord{
	Timestamp: time.Now(),
	Msg:       "the msg",
	Tag:       "the tag",
}

for i := 1; i <= 9; i++ {
	r.AsyncIDs = []string{fmt.Sprintf("id-%d", i)}
	err = status.New(r)
	if err != nil {
		panic(err)
	}
}

ids, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Println("All ids", ids)

ers, err := status.FindAll()
if err != nil {
	panic(err)
}
for i, v := range ers {
	fmt.Printf("i: %d v.AssyncIds: %v\n", i, v.AsyncIDs)
}

// Wait for expiration event
time.Sleep(time.Millisecond * 1010)
ers, err = status.FindAll()
fmt.Printf("All expired ers %+v, error: %v\n", ers, err)

ids, err = status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Println("All ids after records expired", ids)

fmt.Printf("Stats: %+v\n", status.Stats())

err = status.Close()
if err != nil {
	panic(err)
}

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_findAll")
Output:

All ids [id-1 id-2 id-3 id-4 id-5 id-6 id-7 id-8 id-9]
i: 0 v.AssyncIds: [id-1]
i: 1 v.AssyncIds: [id-2]
i: 2 v.AssyncIds: [id-3]
i: 3 v.AssyncIds: [id-4]
i: 4 v.AssyncIds: [id-5]
i: 5 v.AssyncIds: [id-6]
i: 6 v.AssyncIds: [id-7]
i: 7 v.AssyncIds: [id-8]
i: 8 v.AssyncIds: [id-9]
All expired ers [], error: <nil>
All ids after records expired []
Stats: {BufferCount:0 Updated:0 Finished:0 Dropped:0 Evicted:9 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:-1}
Example (FinishRecord)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_finishRecord")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_finishRecord").
	Build()
if err != nil {
	panic(err)
}

// The record
r := &EventRecord{
	AsyncIDs:  []string{"id-1"},
	Timestamp: time.Now(),
	Msg:       "the msg",
	Tag:       "the tag",
}

// Add the record
err = status.New(r)
if err != nil {
	panic(err)
}

fmt.Printf("Stats: %+v\n", status.Stats())

// Finish the record
err = status.FinishRecord("id-1")
if err != nil {
	panic(err)
}

fmt.Printf("Stats after record finished: %+v\n", status.Stats())

err = status.FinishRecord("id-1")
fmt.Println("Error while finish record previously finished", err)

ids, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Println("All IDs", ids)

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_finishRecord")
Output:

Stats: {BufferCount:1 Updated:0 Finished:0 Dropped:0 Evicted:0 DbIdxSize:1 DbMaxFileID:0 DbDataEntries:-1}
Stats after record finished: {BufferCount:0 Updated:0 Finished:1 Dropped:0 Evicted:0 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:-1}
Error while finish record previously finished EventRecord not found in index
All IDs []
Example (GetRecord)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_getRecord")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_getRecord").
	EventsTTLSeconds(1).
	Build()
if err != nil {
	panic(err)
}

// The record
r := &EventRecord{
	AsyncIDs:  []string{"id-1"},
	Timestamp: time.Now(),
	Msg:       "the msg",
	Tag:       "the tag",
}

err = status.New(r)
if err != nil {
	panic(err)
}
allIDs, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Printf("All IDs: %v\n", allIDs)

theRecord, order, err := status.Get("id-1")
fmt.Printf(
	"Order: %d, Error: %v, Record {AsyncIDs: %v, Tag: %s, Msg: %s}\n",
	order,
	err,
	theRecord.AsyncIDs,
	theRecord.Tag,
	theRecord.Msg)

_, order, err = status.Get("id-2")
fmt.Printf("ID does not exists, order: %d, err: %v\n", order, err)

fmt.Printf("Stats: %+v\n", status.Stats())

// Wait for expiration event
time.Sleep(time.Millisecond * 1010)

_, order, err = status.Get("id-1")
fmt.Printf("Event expired: %d, err: %v\n", order, err)

fmt.Printf("Stats: %+v\n", status.Stats())

err = status.Close()
if err != nil {
	panic(err)
}

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_getRecord")
Output:

All IDs: [id-1]
Order: 0, Error: <nil>, Record {AsyncIDs: [id-1], Tag: the tag, Msg: the msg}
ID does not exists, order: -1, err: EventRecord not found in index
Stats: {BufferCount:1 Updated:0 Finished:0 Dropped:0 Evicted:0 DbIdxSize:1 DbMaxFileID:0 DbDataEntries:-1}
Event expired: -1, err: EventRecord evicted
Stats: {BufferCount:0 Updated:0 Finished:0 Dropped:0 Evicted:1 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:-1}
Example (HouseKeeping)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_houseKeeping")

status, err := NewNutsDBStatusBuilder().
	DbSegmentSize(10240).    // To ensure several files will be created
	FilesToConsolidateDb(2). // To ensure that HouseKeeping call with generate files
	DbPath("/tmp/test-ExampleNutsDBStatus_houseKeeping").
	Build()
if err != nil {
	panic(err)
}

// We create and finish 1000 event records of 64 bytes size this will ensure files are recreated
// The record
r := &EventRecord{
	AsyncIDs: []string{"id-1"},
	Msg:      strings.Repeat("X", 64),
	Tag:      "test.keep.free",
}
for i := 0; i < 1000; i++ {
	r.Timestamp = time.Now()
	// Add the record
	err = status.New(r)
	if err != nil {
		panic(err)
	}

	err = status.FinishRecord("id-1")
}

fmt.Println("BEFORE HouseKeeping")
fmt.Printf(
	"Number of files: %d\n",
	NumberOfFiles("/tmp/test-ExampleNutsDBStatus_houseKeeping"))
fmt.Printf("Stats: %+v\n", status.Stats())

err = status.HouseKeeping()
if err != nil {
	panic(err)
}

fmt.Println("AFTER HouseKeeping")
fmt.Printf(
	"Number of files: %d\n",
	NumberOfFiles("/tmp/test-ExampleNutsDBStatus_houseKeeping"))
fmt.Printf("Stats: %+v\n", status.Stats())

status.Close()

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_houseKeeping")
Output:

BEFORE HouseKeeping
Number of files: 41
Stats: {BufferCount:0 Updated:0 Finished:1000 Dropped:0 Evicted:0 DbIdxSize:0 DbMaxFileID:40 DbDataEntries:-1}
AFTER HouseKeeping
Number of files: 1
Stats: {BufferCount:0 Updated:0 Finished:1000 Dropped:0 Evicted:0 DbIdxSize:0 DbMaxFileID:41 DbDataEntries:-1}
Example (NewRecord)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_newRecord")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_newRecord").
	Build()
if err != nil {
	panic(err)
}

// The record
r := &EventRecord{
	Msg: "the msg",
	Tag: "the tag",
}

err = status.New(r)
fmt.Println("Error id is missing:", err)

r.AsyncIDs = []string{"id-1"}
err = status.New(r)
if err != nil {
	panic(err)
}
fmt.Printf("Default timestamp implies event is evicted: %+v\n", status.Stats())

r.Timestamp = time.Now()
err = status.New(r)
if err != nil {
	panic(err)
}
allIDs, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Printf("IDs after event added: %v\n", allIDs)
fmt.Printf("Stats: %+v\n", status.Stats())

err = status.New(r)
fmt.Println("Error ID exists:", err)

r.AsyncIDs = []string{"id-2", "id-3"}
err = status.New(r)
fmt.Println("Error more than one ID:", err)

err = status.Close()
if err != nil {
	panic(err)
}
fmt.Printf("Stats after close: %+v\n", status.Stats())

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_newRecord")
Output:

Error id is missing: AsyncIDs must be formed by one and only one value
Default timestamp implies event is evicted: {BufferCount:0 Updated:0 Finished:0 Dropped:0 Evicted:1 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:-1}
IDs after event added: [id-1]
Stats: {BufferCount:1 Updated:0 Finished:0 Dropped:0 Evicted:1 DbIdxSize:1 DbMaxFileID:0 DbDataEntries:-1}
Error ID exists: while update nutsdb: record with id-1 id is present in status db
Error more than one ID: AsyncIDs must be formed by one and only one value
Stats after close: {BufferCount:0 Updated:0 Finished:0 Dropped:0 Evicted:0 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:0}
Example (NewRecord_bufferOverflow)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_newRecord_bufferOverflow")

status, err := NewNutsDBStatusBuilder().
	BufferSize(1). // Force buffer size to 1
	DbPath("/tmp/test-ExampleNutsDBStatus_newRecord_bufferOverflow").
	Build()
if err != nil {
	panic(err)
}

// The record template
r := &EventRecord{

	Msg: "the msg",
	Tag: "the tag",
}

// Add record 1
r.Timestamp = time.Now()
r.AsyncIDs = []string{"id-1"}
err = status.New(r)
if err != nil {
	panic(err)
}

// Wait some millisencods to ensure timestamp of event 2 is significativally greater than on event 1
time.Sleep(time.Millisecond * 50)

// Add record 2
r.Timestamp = time.Now()
r.AsyncIDs = []string{"id-2"}
err = status.New(r)
if err != nil {
	panic(err)
}

// Print ids only event with id equal to id-2 must be present
allIDs, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Printf("IDs: %v\n", allIDs)
fmt.Printf("Stats: %+v\n", status.Stats())

status.Close()

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_newRecord_bufferOverflow")
Output:

IDs: [id-2]
Stats: {BufferCount:1 Updated:0 Finished:0 Dropped:1 Evicted:0 DbIdxSize:1 DbMaxFileID:0 DbDataEntries:-1}
Example (RebuiltCorruptIdx)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_rebuiltCorruptIdx")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_rebuiltCorruptIdx").
	Build()
if err != nil {
	panic(err)
}

// Create some records
// The record template
r := &EventRecord{
	Msg: strings.Repeat("X", 64),
	Tag: "test.keep.free",
}
for i := 0; i < 10; i++ {
	r.AsyncIDs = []string{
		fmt.Sprintf("id-%d", i),
	}
	r.Timestamp = time.Now()
	// Add the record
	err = status.New(r)
	if err != nil {
		panic(err)
	}
}

// Close status
err = status.Close()
if err != nil {
	panic(err)
}

// Manually corrupt the index
opts := nutsdb.DefaultOptions
opts.Dir = "/tmp/test-ExampleNutsDBStatus_rebuiltCorruptIdx"
db, err := nutsdb.Open(opts)
if err != nil {
	panic(err)
}

err = db.Update(func(tx *nutsdb.Tx) error {
	return tx.Delete("idx", []byte("idx")) // See idxBucket constant and idxKey var with updated values
})
if err != nil {
	panic(err)
}
db.Close()

// Reopen status and
status, err = NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_rebuiltCorruptIdx").
	Build()
if err != nil {
	panic(err)
}

// Stats should display righ index value
fmt.Printf("Stats: %+v\n", status.Stats())
status.Close()

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_rebuiltCorruptIdx")
Output:

Stats: {BufferCount:10 Updated:0 Finished:0 Dropped:0 Evicted:0 DbIdxSize:10 DbMaxFileID:0 DbDataEntries:-1}
Example (UpdateRecord)
// Ensure tmp path is clean
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_updateRecord")

status, err := NewNutsDBStatusBuilder().
	DbPath("/tmp/test-ExampleNutsDBStatus_updateRecord").
	EventsTTLSeconds(1).
	Build()
if err != nil {
	panic(err)
}

// The record
r := &EventRecord{
	AsyncIDs:  []string{"id-1"},
	Timestamp: time.Now(),
	Msg:       "the msg",
	Tag:       "the tag",
}

err = status.New(r)
if err != nil {
	panic(err)
}

err = status.Update("id-99", "id-100")
fmt.Printf("Error update not existint record: %v\n", err)

err = status.Update("id-1", "id-2")
if err != nil {
	panic(err)
}

ids, err := status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Println("1 update: All ids", ids)

er, order, err := status.Get("id-2")
if err != nil {
	panic(err)
}
fmt.Printf("1 update: event record.AsyncIDs: er.AsyncIDs: %v, order: %d\n", er.AsyncIDs, order)

err = status.Update("id-2", "id-3")
if err != nil {
	panic(err)
}

ids, err = status.AllIDs()
if err != nil {
	panic(err)
}
fmt.Println("2 update: All ids", ids)

er, order, err = status.Get("id-3")
if err != nil {
	panic(err)
}
fmt.Printf("2 update: event record.AsyncIDs: er.AsyncIDs: %v, order: %d\n", er.AsyncIDs, order)

fmt.Printf("Stats: %+v\n", status.Stats())

// Wait for expiration event
time.Sleep(time.Millisecond * 1010)

err = status.Update("id-3", "id-4")
fmt.Println("Error when update after event expiration", err)

fmt.Printf("Stats: %+v\n", status.Stats())

err = status.Close()
if err != nil {
	panic(err)
}

// Cleant tmp path
os.RemoveAll("/tmp/test-ExampleNutsDBStatus_updateRecord")
Output:

Error update not existint record: EventRecord not found in index
1 update: All ids [id-2]
1 update: event record.AsyncIDs: er.AsyncIDs: [id-1 id-2], order: 0
2 update: All ids [id-3]
2 update: event record.AsyncIDs: er.AsyncIDs: [id-1 id-2 id-3], order: 0
Stats: {BufferCount:1 Updated:2 Finished:0 Dropped:0 Evicted:0 DbIdxSize:1 DbMaxFileID:0 DbDataEntries:-1}
Error when update after event expiration EventRecord evicted
Stats: {BufferCount:0 Updated:2 Finished:0 Dropped:0 Evicted:1 DbIdxSize:0 DbMaxFileID:0 DbDataEntries:-1}

func (*NutsDBStatus) AllIDs

func (ns *NutsDBStatus) AllIDs() ([]string, error)

AllIDs is the Status.AllIDs implementation for NutsDBStatus: Return all ids based on index information only

func (*NutsDBStatus) BatchUpdate

func (ns *NutsDBStatus) BatchUpdate(f func(old string) string) error

BatchUpdate is similar to update but new Id is based on a function parameter Function parameter will receive the current id value and it should return new id or empty string "" if update should not be done

func (*NutsDBStatus) Close

func (ns *NutsDBStatus) Close() error

Close is the implementation of Status.Close,

func (*NutsDBStatus) FindAll

func (ns *NutsDBStatus) FindAll() ([]*EventRecord, error)

FindAll is the Status.FindAll implementation for NutsDBStatus: Return all EventRecords from status Bear in mind that this operation is heavy use resources. Order is not WARRANTIED, Use AllIDs and Get to get all records in order

func (*NutsDBStatus) FinishRecord

func (ns *NutsDBStatus) FinishRecord(ID string) error

FinishRecord is the Status.FinishRecord implementation for NutsDBStatus: Mark as record as finished and remove it from status

func (*NutsDBStatus) Get

func (ns *NutsDBStatus) Get(ID string) (*EventRecord, int, error)

Get is the Status.Get implementation for NutsDBStatus: Returns EventRecord based on ID

func (*NutsDBStatus) HouseKeeping

func (ns *NutsDBStatus) HouseKeeping() error

HouseKeeping the implementation of Status.HouseKeeping, It runs a set of tasks like consolidate status db, fix and regenerat index if needed, etc.

func (*NutsDBStatus) Initialize

func (ns *NutsDBStatus) Initialize() error

Initialize is the Intialize implementation of Status interface for NutsDBStatus. Checks and ensure that required buckets and keys exists, and try to fix problems on internal data structures and references.

func (*NutsDBStatus) New

func (ns *NutsDBStatus) New(er *EventRecord) error

New is the New implementation of Status interface for NutsDBStatus. This will create new record in the status db.

func (*NutsDBStatus) Stats

func (ns *NutsDBStatus) Stats() Stats

Stats return Stas generated by NutsDBStatus

func (*NutsDBStatus) String

func (ns *NutsDBStatus) String() string

func (*NutsDBStatus) Update

func (ns *NutsDBStatus) Update(oldID, newID string) error

Update is the Status.Update implementation for NutsDBStatus: Update the record with new ID

type NutsDBStatusBuilder

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

NutsDBStatusBuilder represents the Builder for NutsDBstatus

func NewNutsDBStatusBuilder

func NewNutsDBStatusBuilder() *NutsDBStatusBuilder

NewNutsDBStatusBuilder is the factory method for instantiate *NutsDBStatusBuilder with default values

func (*NutsDBStatusBuilder) BufferSize

func (nsb *NutsDBStatusBuilder) BufferSize(size uint) *NutsDBStatusBuilder

BufferSize sets the BufferSize builder value

func (*NutsDBStatusBuilder) Build

func (nsb *NutsDBStatusBuilder) Build() (Status, error)

Build builds NutsDBStatus instance based on Builder config but return as Status interface. This method makes NutsDBStatusBuilder as Builder interface implementation

func (*NutsDBStatusBuilder) BuildNutsDBStatus

func (nsb *NutsDBStatusBuilder) BuildNutsDBStatus() (*NutsDBStatus, error)

BuildNutsDBStatus builds NutsDBStatus instance based on Builder config. NutsDBStatus.Initialize is called just after build connection

func (*NutsDBStatusBuilder) DbEntryIdxMode

func (nsb *NutsDBStatusBuilder) DbEntryIdxMode(mode nutsdb.EntryIdxMode) *NutsDBStatusBuilder

DbEntryIdxMode sets the EntryIdxMode (See https://pkg.go.dev/github.com/xujiajun/nutsdb@v0.6.0#section-readme) property in nutsdb.Options builder value

func (*NutsDBStatusBuilder) DbPath

func (nsb *NutsDBStatusBuilder) DbPath(path string) *NutsDBStatusBuilder

DbPath sets the Dir property in nutsdb.Options builder value

func (*NutsDBStatusBuilder) DbRWMode

DbRWMode sets the RWMode and StartFileLoadingMode (Database read-write mode, see https://pkg.go.dev/github.com/xujiajun/nutsdb@v0.6.0#section-readme) properties in nutsdb.Options builder value

func (*NutsDBStatusBuilder) DbSegmentSize

func (nsb *NutsDBStatusBuilder) DbSegmentSize(size int64) *NutsDBStatusBuilder

DbSegmentSize sets the SegmentSize (Maximum size for each status persisted file) property in nutsdb.Options builder value:

func (*NutsDBStatusBuilder) EventsTTLSeconds

func (nsb *NutsDBStatusBuilder) EventsTTLSeconds(ttl uint32) *NutsDBStatusBuilder

EventsTTLSeconds sets the EventsTTLSeconds builder value

func (*NutsDBStatusBuilder) FilesToConsolidateDb

func (nsb *NutsDBStatusBuilder) FilesToConsolidateDb(files int) *NutsDBStatusBuilder

FilesToConsolidateDb sets the minimum number of files threshold to run consolidate nutsdb files (Merge) when HouseKeeping func is called. files value will be internally assigned only if it is greater than 1

func (*NutsDBStatusBuilder) NutsDBOptions

func (nsb *NutsDBStatusBuilder) NutsDBOptions(opts nutsdb.Options) *NutsDBStatusBuilder

NutsDBOptions sets the nutsdb.Options builder value

func (*NutsDBStatusBuilder) RecreateDbClientAfterConsolidation

func (nsb *NutsDBStatusBuilder) RecreateDbClientAfterConsolidation(b bool) *NutsDBStatusBuilder

RecreateDbClientAfterConsolidation enable the close and open nutsdb client when a consolidation operation (Merge) is done during HouseKeeping call. This feature prevents some memory leaks related with internal nutsdb objects management.

type SorteableStringTime

type SorteableStringTime struct {
	Values     []string
	Timestamps []time.Time
}

SorteableStringTime represent a slice of string, time.Time tuples that can be sorted by time.Time value using sort.Sort() method

func (*SorteableStringTime) Add

func (sst *SorteableStringTime) Add(v string, t time.Time)

Add add new (string, time) tuple

func (*SorteableStringTime) Len

func (sst *SorteableStringTime) Len() int

Len is part of by sort.Interface

func (*SorteableStringTime) Less

func (sst *SorteableStringTime) Less(i, j int) bool

Less is part of by sort.Interface

func (*SorteableStringTime) Swap

func (sst *SorteableStringTime) Swap(i, j int)

Swap is part of by sort.Interface

type Stats

type Stats struct {
	// Number of events in buffer
	BufferCount int
	// UPdaTotal events that are in buffer and daemon was tried to re-send
	Updated int
	// Finished is the total number of events that were processed (out of buffer)
	Finished int
	// Dropped is the total number of events that were removed from buffer without send because
	// limit of the buffer size was reached
	Dropped int
	// Evicted is the total number of events that were removed from buffer because they were expired
	// before stablish connection
	Evicted int

	// DbIdxSize is the number of IDs saved in the ordered index
	DbIdxSize int
	// DbMaxFileID is the file number(id) used by status db
	DbMaxFileID int64
	// DbDataEntries is the number of status records saved on the status db, or -1 if this metric was
	// not solved. Resolution of this metric seriously affects the performance. For this reason this metric
	// will only resolve it if value of DEVOGO_DEBUG_SENDER_STATS_COUNT_DATA environment varaiblable is "yes"
	DbDataEntries int
}

Stats represent the counter ando other metric values extracted from status db implementation

type Status

type Status interface {
	New(er *EventRecord) error
	Update(oldID, newID string) error
	BatchUpdate(f func(old string) string) error
	Get(ID string) (*EventRecord, int, error)
	FinishRecord(ID string) error
	AllIDs() ([]string, error)
	FindAll() ([]*EventRecord, error)
	Stats() Stats
	HouseKeeping() error
	Close() error
	String() string
}

Status is the engine abstranction to save and retrieve EventRecord instances from status implementation.

Jump to

Keyboard shortcuts

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