entity

package
v0.0.0-...-7899014 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Select        = index.Select
	Desc          = index.Desc
	Tap           = index.Tap
	Unmarshal     = index.Unmarshal
	TapPre        = index.TapPre
	Count         = index.Count
	Asc           = index.Asc
	NewEntry      = index.NewEntry
	MatchEntry    = index.MatchEntry
	MatchPreEntry = index.MatchPreEntry

	ErrKeyNotFound = store.ErrKeyNotFound
	ErrKeyNotMatch = store.ErrKeyNotMatch
)
View Source
var IdxEmbeddedBy = idxEmbeddedBy{}
View Source
var IdxName = idxName(func(name Name) IndexEntry {
	return NewEntry(idxName(nil), name)
})
View Source
var IdxPairObjectReferred = idxReferTo{}
View Source
var IdxPairObjectSummary = idxSummaryKey{}
View Source
var IdxPairReferredObject = idxReferedBy{}
View Source
var IdxPairSummaryObject = idxSummaryOf{}
View Source
var IdxReferTo = idxReferTo{}
View Source
var IdxReferedBy = idxReferedBy{}
View Source
var IdxSummaryKey = idxSummaryKey{}
View Source
var IdxSummaryOf = idxSummaryOf{}
View Source
var IdxTest = idxTest{}
View Source
var IdxType = idxType(func(_type string) IndexEntry {
	return NewEntry(idxType(nil), _type)
})
View Source
var IdxVersion = idxVersion(func(version int64) IndexEntry {
	return NewEntry(idxVersion(nil), version)
})
View Source
var NSEntity = key.Namespace{'c', '-', 'e', 'n', 't', 'i', 't', 'y'}
View Source
var NSSummary = key.Namespace{'c', '-', 's', 'u', 'm', 'a', 'r', 'y'}

Functions

func MatchType

func MatchType(o any) index.Entry

func TestDelete

func TestDelete(
	t *testing.T,
	save Save,
	del Delete,
	checkRef CheckRef,
	sel index.SelectIndex,
	wg *pr2.WaitGroup,
)

func TestEmbeddingSameObject

func TestEmbeddingSameObject(
	t *testing.T,
	save SaveEntity,
	del Delete,
	updateIndex UpdateIndex,
	sel index.SelectIndex,
	wg *pr2.WaitGroup,
)

func TestFetch

func TestFetch(
	t *testing.T,
	fetch Fetch,
	save SaveEntity,
	wg *pr2.WaitGroup,
)

func TestGC

func TestGC(
	t *testing.T,
	store store.Store,
	saveEntity SaveEntity,
	fetch Fetch,
	gc GC,
	checkRef CheckRef,
	index Index,
	deleteSummary DeleteSummary,
	wg *pr2.WaitGroup,
)

func TestGCWithEmptyIndex

func TestGCWithEmptyIndex(
	t *testing.T,
	save Save,
	newMemStore storemem.New,
	scope Scope,
	gc GC,
	wg *pr2.WaitGroup,
)

func TestIndex

func TestIndex(
	t *testing.T,
	store store.Store,
	save SaveEntity,
	fetch Fetch,
	checkRef CheckRef,
	cleanIndex CleanIndex,
	index Index,
	indexGC IndexGC,
	wg *pr2.WaitGroup,
)

func TestIntegrity

func TestIntegrity(
	t *testing.T,
	saveEntity SaveEntity,
	store Store,
	wg *pr2.WaitGroup,
)

func TestLock

func TestLock(
	t *testing.T,
	newHashState key.NewHashState,
)

func TestNewName

func TestNewName(
	t *testing.T,
	newName NewName,
	machineName naming.MachineName,
)

func TestPush

func TestPush(
	t *testing.T,
	newMem storemem.New,
	newKV storekv.New,
	scope Scope,
	wg *pr2.WaitGroup,
)

func TestSave

func TestSave(
	t *testing.T,
	save SaveEntity,
	store store.Store,
	rebuildIndex RebuildIndex,
	updateIndex UpdateIndex,
	checkRef CheckRef,
	cleanIndex CleanIndex,
	newMemStore storemem.New,
	scope Scope,
	newHashState NewHashState,
	index Index,
	resave Resave,
	indexGC IndexGC,
	wg *pr2.WaitGroup,
)

func TestSummary

func TestSummary(
	t *testing.T,
	save SaveEntity,
	wg *pr2.WaitGroup,
)

func TestSummaryUpdate

func TestSummaryUpdate(
	t *testing.T,
	save Save,
	fetch Fetch,
	checkRef CheckRef,
	cleanIndex CleanIndex,
	indexGC IndexGC,
	wg *pr2.WaitGroup,
)

Types

type BeingRefered

type BeingRefered struct {
	Key Key
	By  map[Key]struct{}
}

func (*BeingRefered) Error

func (e *BeingRefered) Error() string

type CheckRef

type CheckRef func(
	ctx context.Context,
	options ...CheckRefOption,
) error

type CheckRefOption

type CheckRefOption interface {
	IsCheckRefOption()
}

type CleanIndex

type CleanIndex func(
	ctx context.Context,
	options ...CleanIndexOption,
) error

type CleanIndexOption

type CleanIndexOption interface {
	IsCleanIndexOption()
}

type DeadObject

type DeadObject struct {
	Key     Key
	Summary *Summary
}

type Def

type Def struct{}

func (Def) CheckRef

func (Def) CheckRef(
	store Store,
	parallel sys.Parallel,
) CheckRef

func (Def) CleanIndex

func (Def) CleanIndex(
	deleteIndex DeleteIndex,
	store store.Store,
) CleanIndex

func (Def) Delete

func (Def) Delete(
	fetch Fetch,
	store Store,
	index Index,
	sel index.SelectIndex,
	deleteSummary DeleteSummary,
) Delete

func (Def) DeleteIndex

func (Def) DeleteIndex(
	index Index,
	parallel sys.Parallel,
) DeleteIndex

func (Def) DeleteSummary

func (_ Def) DeleteSummary(
	store store.Store,
	index Index,
	locks *_EntityLocks,
	onDel OnSummaryIndexDelete,
) DeleteSummary

func (Def) EntityLocks

func (_ Def) EntityLocks() *_EntityLocks

func (Def) Fetch

func (Def) Fetch(
	store store.Store,
	newHashState key.NewHashState,
) Fetch

func (Def) GC

func (Def) GC(
	store Store,
	selIndex index.SelectIndex,
	index Index,
	parallel sys.Parallel,
	deleteSummary DeleteSummary,
) GC

func (Def) HashIndexSet

func (_ Def) HashIndexSet(
	newHashState key.NewHashState,
) HashIndexSet

func (Def) IdxReferToFuncs

func (Def) IdxReferToFuncs() (
	add OnSummaryIndexAdd,
	del OnSummaryIndexDelete,
)

func (Def) IdxReferedByFuncs

func (_ Def) IdxReferedByFuncs() (
	add OnSummaryIndexAdd,
	del OnSummaryIndexDelete,
)

func (Def) IdxSummaryKeyFuncs

func (Def) IdxSummaryKeyFuncs() (
	add OnSummaryIndexAdd,
	del OnSummaryIndexDelete,
)

func (Def) IdxSummaryOfFuncs

func (Def) IdxSummaryOfFuncs() (
	add OnSummaryIndexAdd,
	del OnSummaryIndexDelete,
)

func (Def) IndexFuncs

func (Def) IndexFuncs(
	store Store,
	saveSummary SaveSummary,
	sel index.SelectIndex,
	parallel sys.Parallel,
) (rebuild RebuildIndex, update UpdateIndex)

func (Def) IndexGC

func (Def) IndexGC(
	store Store,
	newMem storemem.New,
	scope dscope.Scope,
	newKV storekv.New,
	fetch Fetch,
	index Index,
	parallel sys.Parallel,
) IndexGC

func (Def) NewName

func (_ Def) NewName(
	machineName naming.MachineName,
	index Index,
) NewName

func (Def) Push

func (Def) Push(
	scope dscope.Scope,
	selIndex index.SelectIndex,
	store Store,
	fetch Fetch,
	parallel sys.Parallel,
) Push

func (Def) Resave

func (Def) Resave(
	sel index.SelectIndex,
	fetch Fetch,
	save Save,
	parallel sys.Parallel,
) Resave

func (Def) Save

func (Def) Save(
	store store.Store,
	scope dscope.Scope,
	newHashState key.NewHashState,
	saveSummary SaveSummary,
) (
	save Save,
)

func (Def) SaveEntity

func (Def) SaveEntity(
	save Save,
) SaveEntity

func (Def) SaveSummary

func (_ Def) SaveSummary(
	store store.Store,
	sel index.SelectIndex,
	fetch Fetch,
	index Index,
	locks *_EntityLocks,
	onAdd OnSummaryIndexAdd,
	onDel OnSummaryIndexDelete,
) SaveSummary

func (Def) SummaryIndexFuncs

func (_ Def) SummaryIndexFuncs(
	sel index.SelectIndex,
) (
	add OnSummaryIndexAdd,
	del OnSummaryIndexDelete,
)

type Delete

type Delete func(
	ctx context.Context,
	key Key,
) (
	err error,
)

type DeleteIndex

type DeleteIndex func(
	ctx context.Context,
	predict func(sb.Stream) (*IndexEntry, error),
	options ...DeleteIndexOption,
) error

type DeleteIndexOption

type DeleteIndexOption interface {
	IsDeleteIndexOption()
}

type DeleteSummary

type DeleteSummary func(
	ctx context.Context,
	summary *Summary,
	summaryKey Key,
) (
	err error,
)

type Fetch

type Fetch func(key any, targets ...any) error

type GC

type GC func(
	ctx context.Context,
	roots []Key,
	options ...GCOption,
) error

type GCOption

type GCOption interface {
	IsGCOption()
}

type HasIndex

type HasIndex interface {
	EntityIndexes() (
		set IndexSet,
		version int64,
		err error,
	)
}

type HasSlotKeys

type HasSlotKeys interface {
	SlotKeys() (any, error)
}

type Hash

type Hash = key.Hash

type HashIndexSet

type HashIndexSet func(
	set IndexSet,
) (
	Hash,
	error,
)

type IgnoreSummary

type IgnoreSummary func(Summary) bool

func (IgnoreSummary) IsPushOption

func (IgnoreSummary) IsPushOption()

type Index

type Index = index.Index

type IndexEntry

type IndexEntry = index.Entry

type IndexGC

type IndexGC func(
	ctx context.Context,
	options ...IndexGCOption,
) error

type IndexGCOption

type IndexGCOption interface {
	IsIndexGCOption()
}

type IndexManager

type IndexManager = index.IndexManager

type IndexOption

type IndexOption interface {
	IsIndexOption()
}

type IndexPreEntry

type IndexPreEntry = index.PreEntry

type IndexSaveOption

type IndexSaveOption = index.SaveOption

type IndexSet

type IndexSet []IndexEntry

type IndexTapEntry

type IndexTapEntry = index.TapEntry

type Key

type Key = key.Key

type KeyPath

type KeyPath = key.KeyPath

type Limit

type Limit = index.Limit

type Name

type Name string

func (Name) Valid

func (n Name) Valid() bool

type NewHashState

type NewHashState = key.NewHashState

type NewName

type NewName func(prefix string) Name

type OnSummaryIndexAdd

type OnSummaryIndexAdd func(
	ctx context.Context,
	summary *Summary,
	summaryKey Key,
) (
	entries []IndexEntry,
	err error,
)

func (OnSummaryIndexAdd) Reduce

type OnSummaryIndexDelete

type OnSummaryIndexDelete func(
	ctx context.Context,
	summary *Summary,
	summaryKey Key,
) (
	entries []IndexEntry,
	err error,
)

func (OnSummaryIndexDelete) Reduce

type Order

type Order = index.Order

type Parallel

type Parallel int

func (Parallel) IsPushOption

func (Parallel) IsPushOption()

type Push

type Push func(
	ctx context.Context,
	to Store,
	toIndex IndexManager,
	keys []Key,
	options ...PushOption,
) error

type PushOption

type PushOption interface {
	IsPushOption()
}

type RebuildIndex

type RebuildIndex func(
	ctx context.Context,
	options ...IndexOption,
) (
	n int64,
	err error,
)

type Resave

type Resave func(
	ctx context.Context,
	objs []any,
	options ...ResaveOption,
) error

type ResaveOption

type ResaveOption interface {
	IsResaveOption()
}

type Save

type Save func(
	ctx context.Context,
	ns key.Namespace,
	value any,
	options ...SaveOption,
) (
	summary *Summary,
	err error,
)

save entity

type SaveEntity

type SaveEntity func(
	ctx context.Context,
	value any,
	options ...SaveOption,
) (
	summary *Summary,
	err error,
)

type SaveOption

type SaveOption interface {
	IsSaveOption()
}

type SaveOptions

type SaveOptions []SaveOption

func (SaveOptions) IsResaveOption

func (SaveOptions) IsResaveOption()

type SaveSummary

type SaveSummary func(
	ctx context.Context,
	summary *Summary,
	isLatest bool,
	options ...SaveSummaryOption,
) error

SaveSummary

type SaveSummaryOption

type SaveSummaryOption interface {
	IsSaveSummaryOption()
}

type SaveSummaryOptions

type SaveSummaryOptions []SaveSummaryOption

func (SaveSummaryOptions) IsSaveOption

func (SaveSummaryOptions) IsSaveOption()

type SaveValue

type SaveValue any

type Scope

type Scope = dscope.Scope

type Store

type Store = store.Store

type Summary

type Summary struct {
	Key         Key
	SlotHash    *Hash
	Indexes     *[]IndexEntry // IndexEntry without Key in Tuple
	Subs        []*Summary
	ReferedKeys []Key // all in NSEntity

}

func (Summary) MarshalSB

func (s Summary) MarshalSB(ctx sb.Ctx, cont sb.Proc) sb.Proc

func (Summary) SBDeprecatedFields

func (s Summary) SBDeprecatedFields() []string

func (Summary) Valid

func (s Summary) Valid() bool

type TapBadSummary

type TapBadSummary func(*Summary)

func (TapBadSummary) IsSyncOption

func (TapBadSummary) IsSyncOption()

type TapDeadObjects

type TapDeadObjects func([]DeadObject)

func (TapDeadObjects) IsGCOption

func (TapDeadObjects) IsGCOption()

type TapDeleteIndex

type TapDeleteIndex func(IndexEntry)

func (TapDeleteIndex) IsCleanIndexOption

func (TapDeleteIndex) IsCleanIndexOption()

func (TapDeleteIndex) IsDeleteIndexOption

func (TapDeleteIndex) IsDeleteIndexOption()

func (TapDeleteIndex) IsIndexGCOption

func (TapDeleteIndex) IsIndexGCOption()

type TapEntry

type TapEntry = index.TapEntry

type TapIterKey

type TapIterKey func(Key)

func (TapIterKey) IsGCOption

func (TapIterKey) IsGCOption()

type TapKey

type TapKey = opts.TapKey

type TapMarkKey

type TapMarkKey func(Key)

OnMark is called when key is marked, may call more than once for the same key

func (TapMarkKey) IsGCOption

func (TapMarkKey) IsGCOption()

type TapPushCheckSummary

type TapPushCheckSummary func(summaryKey Key)

func (TapPushCheckSummary) IsPushOption

func (TapPushCheckSummary) IsPushOption()

type TapPushSave

type TapPushSave func(summaryKey Key, summary *Summary)

func (TapPushSave) IsPushOption

func (TapPushSave) IsPushOption()

type TapReachableObjects

type TapReachableObjects func(*sync.Map)

func (TapReachableObjects) IsGCOption

func (TapReachableObjects) IsGCOption()

type TapSummary

type TapSummary func(*Summary)

func (TapSummary) IsSaveOption

func (TapSummary) IsSaveOption()

func (TapSummary) IsSyncOption

func (TapSummary) IsSyncOption()

type TapSweepDeadObject

type TapSweepDeadObject func(DeadObject)

func (TapSweepDeadObject) IsGCOption

func (TapSweepDeadObject) IsGCOption()

type TapTokens

type TapTokens = index.TapTokens

type TapWriteResult

type TapWriteResult = store.TapWriteResult

type UpdateIndex

type UpdateIndex func(
	ctx context.Context,
	options ...IndexOption,
) (
	n int64,
	err error,
)

type WithIndexSaveOptions

type WithIndexSaveOptions []IndexSaveOption

func (WithIndexSaveOptions) IsIndexOption

func (WithIndexSaveOptions) IsIndexOption()

func (WithIndexSaveOptions) IsSaveSummaryOption

func (_ WithIndexSaveOptions) IsSaveSummaryOption()

type WriteOption

type WriteOption = store.WriteOption

type WriteResult

type WriteResult = store.WriteResult

Jump to

Keyboard shortcuts

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