tindex

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VF_SKIP_IF_LOCKED = 1
	VF_DO_NOT_RELEASE = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemConfig

type InMemConfig struct {
	// DoNotSave flag indicates that the data should not be persisted. Used for testing.
	DoNotSave bool

	// WorkingDir contains path to the folder for persisting the index data
	WorkingDir string
}

InMemConfig struct contains configuration for inmemService

type Service

type Service interface {
	// GetOrCreateJournal returns the journal name for the unique Tags combination. It will try
	// to create the new journal Id if it is not found in the index. If the result
	// is returned with no error, the JournalName MUST be released using the Release method later
	GetOrCreateJournal(tags string) (string, tag.Set, error)

	// GetJournal returns the journal name for the unique Tags combination. If the result
	// is returned with no error, the JournalName MUST be released using the Release method later
	GetJournal(tags string) (string, tag.Set, error)

	// GetJournalTags returns the journal Tags combination by its name. If the result
	// is returned with no error, and the lock == true, the journal src MUST be released
	// using the Release method later. If lock == false either an error happens or not
	// the source must not be released.
	// The function returns NotFound if the source is not found
	GetJournalTags(src string, lock bool) (tag.Set, error)

	// Visit walks over the tags-sources that corresponds to the srcCond. VF_SKIP_IF_LOCKED allows to skip the source if it
	// is locked. If VF_SKIP_IF_LOCKED is not set, the Visit will wait until the source become available or removed.
	// VF_DO_NOT_RELEASE will not release the partition automatically, but it is the client responsibility to release
	// the partition later
	Visit(srcCond *lql.Source, v VisitorF, visitFlags int) error

	// LockExclusively changes the acquired source jn (via GetOrCreateJournal or Visit) to exclusive lock.
	// If it returns true, the partition will not be returned in Visit and GetOrCreateJournal will be blocked unitl
	// it is released. The partition must be un-locked the exclusivelies, it was not deleted.
	LockExclusively(jn string) bool

	// UnlockExclusively removes the exclusive lock from the partition. If the lock is not acquired, will panic
	UnlockExclusively(jn string)

	// Release allows to release the journal name which could be acquired by GetOrCreateJournal
	Release(jn string)

	// Delete allows to delete a partition. It must be exclusively locked before the call. If the partition
	// was deleted, the consequireve Release() call will not have any effect. If the Delete returns any
	// error, the partition must be unlocked and released if it was acquired before
	Delete(jn string) error
}

Service interface provides an access to the Tags index. It is used for selecting a partition sources by the tag lines provided and by selecting journals by an expression.

func NewInmemService

func NewInmemService() Service

func NewInmemServiceWithConfig

func NewInmemServiceWithConfig(cfg InMemConfig) Service

type VisitorF

type VisitorF func(tags tag.Set, jrnl string) bool

VisitorF is the callback function which si called by Service.Visit for all matches found. It will iterate over the visit set until it is over or the function returns false. While the function is called the partition name will be hold as acquired, so delete will not work at the moment.

Jump to

Keyboard shortcuts

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