Documentation
¶
Index ¶
- Variables
- func Disconnect(ctx context.Context, f storage.FS, repo *localrepo.Repo, logger log.Logger, ...) error
- func Link(ctx context.Context, pool, repo *localrepo.Repo, txManager transaction.Manager) (returnedErr error)
- type LocalRepoFactory
- type ObjectPool
- func Create(ctx context.Context, logger log.Logger, locator storage.Locator, ...) (*ObjectPool, error)
- func FromProto(ctx context.Context, logger log.Logger, locator storage.Locator, ...) (*ObjectPool, error)
- func FromRepo(ctx context.Context, logger log.Logger, locator storage.Locator, ...) (*ObjectPool, error)
- func (o *ObjectPool) Exists(ctx context.Context) bool
- func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo, newLocalRepo LocalRepoFactory) error
- func (o *ObjectPool) IsValid(ctx context.Context) bool
- func (o *ObjectPool) Link(ctx context.Context, repo *localrepo.Repo) error
- func (o *ObjectPool) ToProto() *gitalypb.ObjectPool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPoolDir is returned when the object pool relative path is malformed. ErrInvalidPoolDir = errors.New("invalid object pool directory") // ErrInvalidPoolRepository indicates the directory the alternates file points to is not a valid git repository ErrInvalidPoolRepository = errors.New("object pool is not a valid git repository") // ErrAlternateObjectDirNotExist indicates a repository does not have an alternates file ErrAlternateObjectDirNotExist = errors.New("no alternates directory exists") )
Functions ¶
func Disconnect ¶
func Disconnect(ctx context.Context, f storage.FS, repo *localrepo.Repo, logger log.Logger, txManager transaction.Manager) error
Disconnect disconnects the specified repository from its object pool. If the repository does not utilize an alternate object database, no error is returned. For repositories that depend on alternate objects, the following steps are performed:
- Alternate objects are hard-linked to the main repository.
- The repository's Git alternates file is backed up and object pool disconnected.
- A connectivity check is performed to ensure the repository is complete. If this check fails, the repository is reconnected to the object pool via the backup and an error returned.
This operation carries some risk. If the repository is in a broken state, it will not be restored until after the connectivity check completes. If Gitaly crashes before the backup is restored, the repository may be in a broken state until an administrator intervenes and restores the backed up copy of objects/info/alternates.
func Link ¶
func Link(ctx context.Context, pool, repo *localrepo.Repo, txManager transaction.Manager) (returnedErr error)
Link will link the given repository to the object pool. This is done by writing the object pool's path relative to the repository into the repository's "alternates" file. This does not trigger deduplication, which is the responsibility of the caller.
Types ¶
type LocalRepoFactory ¶
type LocalRepoFactory func(repo *gitalypb.Repository) *localrepo.Repo
LocalRepoFactory is a function that returns a new localrepo.Repo for the given repository.
type ObjectPool ¶
ObjectPool are a way to de-dupe objects between repositories, where the objects live in a pool in a distinct repository which is used as an alternate object store for other repositories.
func Create ¶
func Create( ctx context.Context, logger log.Logger, locator storage.Locator, gitCmdFactory gitcmd.CommandFactory, catfileCache catfile.Cache, txManager transaction.Manager, housekeepingManager housekeepingmgr.Manager, proto *gitalypb.ObjectPool, sourceRepo *localrepo.Repo, ) (*ObjectPool, error)
Create creates an object pool for the given source repository. This is done by creating a local clone of the source repository where source and target repository will then have the same references afterwards.
The source repository will not join the object pool. Thus, its objects won't get deduplicated.
func FromProto ¶
func FromProto( ctx context.Context, logger log.Logger, locator storage.Locator, gitCmdFactory gitcmd.CommandFactory, catfileCache catfile.Cache, txManager transaction.Manager, housekeepingManager housekeepingmgr.Manager, proto *gitalypb.ObjectPool, ) (*ObjectPool, error)
FromProto returns an object pool object from its Protobuf representation. This function verifies that the object pool exists and is a valid pool repository.
func FromRepo ¶
func FromRepo( ctx context.Context, logger log.Logger, locator storage.Locator, gitCmdFactory gitcmd.CommandFactory, catfileCache catfile.Cache, txManager transaction.Manager, housekeepingManager housekeepingmgr.Manager, repo *localrepo.Repo, ) (*ObjectPool, error)
FromRepo returns an instance of ObjectPool that the repository points to
func (*ObjectPool) Exists ¶
func (o *ObjectPool) Exists(ctx context.Context) bool
Exists will return true if the pool path exists and is a directory
func (*ObjectPool) FetchFromOrigin ¶
func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo, newLocalRepo LocalRepoFactory) error
FetchFromOrigin initializes the pool and fetches the objects from its origin repository
func (*ObjectPool) IsValid ¶
func (o *ObjectPool) IsValid(ctx context.Context) bool
IsValid checks if a repository exists, and if its valid.
func (*ObjectPool) Link ¶
Link calls the non-receiver method version of Link with the parameters injected from the object pool.
func (*ObjectPool) ToProto ¶
func (o *ObjectPool) ToProto() *gitalypb.ObjectPool
ToProto returns a new struct that is the protobuf definition of the ObjectPool