repomodel

package
v0.17.0 Latest Latest
Warning

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

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

Documentation

Overview

Package repomodel provides simplified model of repository operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenRepository

type OpenRepository struct {
	RepoData          *RepositoryData           // +checklocksignore
	ReadableContents  *TrackingSet[content.ID]  // +checklocksignore
	ReadableManifests *TrackingSet[manifest.ID] // +checklocksignore

	EnableMaintenance bool
	// contains filtered or unexported fields
}

OpenRepository models the behavior of an open repository.

func (*OpenRepository) NewSession

func (o *OpenRepository) NewSession(sessionID string) *RepositorySession

NewSession creates new model for a session to access a repository.

func (*OpenRepository) Refresh

func (o *OpenRepository) Refresh(ctx context.Context, cids *TrackingSet[content.ID], mids *TrackingSet[manifest.ID])

Refresh refreshes the set of committed Contents and manifest from repositor.

type RepositoryData

type RepositoryData struct {
	CommittedContents  *TrackingSet[content.ID]
	CommittedManifests *TrackingSet[manifest.ID]
	// contains filtered or unexported fields
}

RepositoryData models the data stored in the repository.

func NewRepositoryData

func NewRepositoryData() *RepositoryData

NewRepositoryData creates new RepositoryData model.

func (*RepositoryData) OpenRepository

func (d *RepositoryData) OpenRepository(openID string) *OpenRepository

OpenRepository returns an OpenRepository model based on current snapshot of RepositoryData.

type RepositorySession

type RepositorySession struct {
	OpenRepo *OpenRepository

	WrittenContents  *TrackingSet[content.ID]
	WrittenManifests *TrackingSet[manifest.ID]
}

RepositorySession models the behavior of a single session in an repository.

func (*RepositorySession) Flush

Flush flushes the changes written in this RepositorySession and makes them available to other RepositoryData model.

func (*RepositorySession) Refresh

func (s *RepositorySession) Refresh(ctx context.Context, cids *TrackingSet[content.ID], mids *TrackingSet[manifest.ID])

Refresh refreshes the set of committed contents and manifest from repositor.

func (*RepositorySession) WriteContent

func (s *RepositorySession) WriteContent(ctx context.Context, cid content.ID)

WriteContent adds the provided content ID to the model.

func (*RepositorySession) WriteManifest

func (s *RepositorySession) WriteManifest(ctx context.Context, mid manifest.ID)

WriteManifest adds the provided manifest ID to the model.

type TrackingSet added in v0.17.0

type TrackingSet[T comparable] struct {
	// contains filtered or unexported fields
}

TrackingSet represents a set of items with built-in.

func NewChangeSet added in v0.17.0

func NewChangeSet[T comparable](setID string) *TrackingSet[T]

NewChangeSet creates new tracking set.

func (*TrackingSet[T]) Add added in v0.17.0

func (s *TrackingSet[T]) Add(ctx context.Context, d ...T)

Add adds the provided items to the set.

func (*TrackingSet[T]) Clear added in v0.17.0

func (s *TrackingSet[T]) Clear(ctx context.Context) TrackingSet[T]

Clear removes all elements from the set.

func (*TrackingSet[T]) PickRandom added in v0.17.0

func (s *TrackingSet[T]) PickRandom(ctx context.Context) T

PickRandom picks one random manifest from the set or empty string.

func (*TrackingSet[T]) RemoveAll added in v0.17.0

func (s *TrackingSet[T]) RemoveAll(ctx context.Context, d ...T)

RemoveAll removes the provided items from the set.

func (*TrackingSet[T]) Replace added in v0.17.0

func (s *TrackingSet[T]) Replace(ctx context.Context, ids []T)

Replace replaces all elements in the set.

func (*TrackingSet[T]) Snapshot added in v0.17.0

func (s *TrackingSet[T]) Snapshot(name string) *TrackingSet[T]

Snapshot returns the snapshot of all IDs.

Jump to

Keyboard shortcuts

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