packages

package
v0.42.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package packages contains utilities and manager to sync Viam packages defined in the RDK config from the Viam app to the local robot.

Index

Constants

View Source
const SubtypeName = "packagemanager"

SubtypeName is a constant that identifies the internal package manager resource subtype string.

Variables

API is the fully qualified API for the internal package manager service.

View Source
var DeferredServiceName = resource.NewName(resource.APINamespaceRDKInternal.WithServiceType(SubtypeName), "deferred-manager")

DeferredServiceName is used to refer to/depend on this service internally.

View Source
var ErrInvalidPackageRef = errors.New("invalid package reference")

ErrInvalidPackageRef is an error when a invalid package reference syntax.

View Source
var ErrPackageMissing = errors.New("package missing")

ErrPackageMissing is an error when a package cannot be found.

View Source
var InternalServiceName = resource.NewName(API, "builtin")

InternalServiceName is used to refer to/depend on this service internally.

Functions

func LocalPackagesDir added in v0.28.0

func LocalPackagesDir(packagesDir string) string

LocalPackagesDir transforms a packagesDir string to the suffixed version for localManager. local + cloud manager need separate parent dirs so they don't delete each other in Cleanup.

Types

type Manager

type Manager interface {
	resource.Resource

	// PackagePath returns the package if it exists and is already downloaded. If it does not exist it returns a ErrPackageMissing error.
	PackagePath(name PackageName) (string, error)
}

Manager provides a managed interface for looking up package paths. This is separated from ManagerSyncer to avoid passing the full sync interface to all components.

type ManagerSyncer

type ManagerSyncer interface {
	Manager

	// Sync will download and create the symbolic logic links to all the given PackageConfig. Sync will not remove any unused
	// data packages. You must call Cleanup() to remove leftovers. Sync will block until all packages are loaded to the file system.
	// Sync should only be used by one goroutine at once.
	// If errors occur during sync the manager should continue trying to download all packages and then return any errors that occurred.
	// If the context is canceled the manager will stop syncing and return an interrupted error.
	Sync(ctx context.Context, packages []config.PackageConfig, modules []config.Module) error

	// SyncOne syncs a single module (inferring the package). It is more aggressive than Sync in that it will re-sync in more cases.
	// Not every package manager needs this.
	SyncOne(ctx context.Context, mod config.Module) error

	// Cleanup removes any unused packages known to the Manager that are no longer used. It removes the packages from the file system.
	// Returns any errors during the cleanup process.
	Cleanup(ctx context.Context) error
}

ManagerSyncer provides a managed interface for both reading package paths and syncing packages from the RDK config.

func NewCloudManager

func NewCloudManager(
	cloudConfig *config.Cloud,
	client pb.PackageServiceClient,
	packagesDir string,
	logger logging.Logger,
) (ManagerSyncer, error)

NewCloudManager creates a new manager with the given package service client and directory to sync to.

func NewDeferredPackageManager added in v0.23.0

func NewDeferredPackageManager(
	ctx context.Context,
	establishConnection func(ctx context.Context) (pb.PackageServiceClient, error),
	cloudConfig *config.Cloud,
	packagesDir string,
	logger logging.Logger,
) ManagerSyncer

NewDeferredPackageManager returns a DeferredPackageManager. See deferred_package_manager.go for more details.

func NewLocalManager added in v0.28.0

func NewLocalManager(conf *config.Config, logger logging.Logger) (ManagerSyncer, error)

NewLocalManager returns a noop package manager that does nothing. On path requests it returns the name of the package.

func NewNoopManager

func NewNoopManager() ManagerSyncer

NewNoopManager returns a noop package manager that does nothing. On path requests it returns the name of the package.

type PackageID

type PackageID string

PackageID is a gobally unique package id.

type PackageName

type PackageName string

PackageName is the logical name of the package on the local rdk. Can point to ID/Version of an actual package.

type PackageVersion

type PackageVersion string

PackageVersion is an immutable package version for a given package id.

Directories

Path Synopsis
Package testutils is test helpers for packages.
Package testutils is test helpers for packages.

Jump to

Keyboard shortcuts

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