lib

package
v0.0.0-...-d8f7d12 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package lib implements some of the core computations in the dominator.

Package lib provides functions for computing differences between a sub and desired image to generate lists of objects for fetching and pushing and update requests. It contains some common code that both the dominator and the push-image subcommand of subtool share.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorFailedToGetObject = errors.New("get object failed")
)

Functions

func BuildMissingLists

func BuildMissingLists(sub Sub, image *image.Image, pushComputedFiles bool,
	ignoreMissingComputedFiles bool, logger log.Logger) (
	map[hash.Hash]uint64, map[hash.Hash]struct{})

BuildMissingLists will construct lists of objects to be fetched by the sub from an object server and the list of computed objects that should be pushed to the sub. The lists are generated by comparing the contents of sub.FileSystem and sub.ObjectCache with the desired image. If pushComputedFiles is true then the list of computed files to be pushed is generated. If ignoreMissingComputedFiles is true then missing computed files are ignored, otherwise these missing files lead to an error and early termination of the function. Computed file metadata are specified by sub.ComputedInodes. BuildMissingLists returns a slice of objects to fetch and a map of files to push. The map is nil if there are missing computed files.

func BuildUpdateRequest

func BuildUpdateRequest(sub Sub, image *image.Image,
	request *subproto.UpdateRequest, deleteMissingComputedFiles bool,
	ignoreMissingComputedFiles bool, logger log.Logger) bool

BuildUpdateRequest will build an update request which can be sent to the sub. If deleteMissingComputedFiles is true then missing computed files are deleted on the sub, else missing computed files lead to the function failing. If deleteMissingComputedFiles is false and ignoreMissingComputedFiles is true then missing computed files are ignored. It returns true if the function failed due to missing computed files.

func PushObjects

func PushObjects(sub Sub, objectsToPush map[hash.Hash]struct{},
	logger log.Logger) error

PushObjects will push the list of files given by objectsToPush to the sub. File data are obtained from sub.ObjectGetter.

Types

type Sub

type Sub struct {
	Hostname       string
	Client         *srpc.Client
	FileSystem     *filesystem.FileSystem
	ComputedInodes map[string]*filesystem.RegularInode
	ObjectCache    objectcache.ObjectCache
	ObjectGetter   objectserver.ObjectGetter
	// contains filtered or unexported fields
}

Sub should be initialised with data to be used in the package functions.

func (*Sub) String

func (sub *Sub) String() string

String returns the hostname of the sub.

Jump to

Keyboard shortcuts

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