state

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SaveIntervalSecs = saveIntervalSecsDefault

Functions

func ConvertRFC3339ToTime

func ConvertRFC3339ToTime(timeToConvert string) (time.Time, error)

func ConvertTimeToEpochMilliseconds

func ConvertTimeToEpochMilliseconds(timeToConvert time.Time) string

func ConvertTimeToRFC3339

func ConvertTimeToRFC3339(timeToConvert time.Time) string

func GetRunningTime added in v2.24.0

func GetRunningTime() (runningTime string, isRunning bool, err error)

func UpdateChunkInState added in v2.24.0

func UpdateChunkInState(stateManager *TransferStateManager, repoKey string, chunk *api.ChunkStatus) error

Types

type ActionOnStateFunc

type ActionOnStateFunc func(state *TransferState) error

type ActionOnStatusFunc

type ActionOnStatusFunc func(transferRunStatus *TransferRunStatus) error

type AlreadyLockedError

type AlreadyLockedError struct{}

func (*AlreadyLockedError) Error

func (m *AlreadyLockedError) Error() string

type DiffDetails

type DiffDetails struct {
	// The start and end time of a complete transferring Files Diff phase
	FilesDiffRunTime PhaseDetails `json:"files_diff,omitempty"`
	// The start and end time of the last handled range
	HandledRange PhaseDetails `json:"handled_range,omitempty"`
	// If false, start the Diff phase from the start time of the full transfer
	Completed bool `json:"completed,omitempty"`
}

type PhaseDetails

type PhaseDetails struct {
	Started string `json:"started,omitempty"`
	Ended   string `json:"ended,omitempty"`
}

type ProgressState

type ProgressState struct {
	TotalSizeBytes       int64 `json:"total_size_bytes,omitempty"`
	TransferredSizeBytes int64 `json:"transferred_size_bytes,omitempty"`
	ProgressStateUnits
}

type ProgressStateUnits added in v2.24.0

type ProgressStateUnits struct {
	TotalUnits       int64 `json:"total_units,omitempty"`
	TransferredUnits int64 `json:"transferred_units,omitempty"`
}

type Repository

type Repository struct {
	ProgressState
	Name         string        `json:"name,omitempty"`
	FullTransfer PhaseDetails  `json:"full_transfer,omitempty"`
	Diffs        []DiffDetails `json:"diffs,omitempty"`
}

type TimeEstimationManager added in v2.24.0

type TimeEstimationManager struct {
	// Speeds of the last done chunks, in bytes/ms
	LastSpeeds []float64 `json:"last_speeds,omitempty"`
	// Sum of the speeds in LastSpeeds. The speeds are in bytes/ms.
	LastSpeedsSum float64 `json:"last_speeds_sum,omitempty"`
	// The last calculated sum of speeds, in bytes/ms
	SpeedsAverage float64 `json:"speeds_average,omitempty"`
	// Data estimated remaining time is saved so that it can be used when handling a build-info repository and speed cannot be calculated.
	DataEstimatedRemainingTime int64 `json:"data_estimated_remaining_time,omitempty"`
	// contains filtered or unexported fields
}

func (*TimeEstimationManager) AddChunkStatus added in v2.24.0

func (tem *TimeEstimationManager) AddChunkStatus(chunkStatus api.ChunkStatus, durationMillis int64)

func (*TimeEstimationManager) GetEstimatedRemainingTimeString added in v2.24.0

func (tem *TimeEstimationManager) GetEstimatedRemainingTimeString() string

GetEstimatedRemainingTimeString gets the estimated remaining time in an easy-to-read string.

func (*TimeEstimationManager) GetSpeedString added in v2.24.0

func (tem *TimeEstimationManager) GetSpeedString() string

GetSpeedString gets the transfer speed in an easy-to-read string.

type TransferRunStatus

type TransferRunStatus struct {

	// This variable holds the total/transferred number of repositories (not their files).
	TotalRepositories ProgressState      `json:"total_repositories,omitempty"`
	OverallBiFiles    ProgressStateUnits `json:"overall_bi_files,omitempty"`
	// Version of the TransferRunStatus file.
	Version     int    `json:"version,omitempty"`
	CurrentRepo string `json:"current_repo,omitempty"`
	// True if currently transferring a build info repository.
	BuildInfoRepo         bool `json:"build_info_repo,omitempty"`
	CurrentRepoPhase      int  `json:"current_repo_phase,omitempty"`
	WorkingThreads        int  `json:"working_threads,omitempty"`
	TransferFailures      uint `json:"transfer_failures,omitempty"`
	TimeEstimationManager `json:"time_estimation,omitempty"`
	// contains filtered or unexported fields
}

This struct holds the run status of the current transfer. It is saved to a file in JFrog CLI's home, but gets reset every time the transfer begins. This state is used to allow showing the current run status by the 'jf rt transfer-files --status' command. It is also used for the time estimation and more.

type TransferState

type TransferState struct {
	Repositories []Repository `json:"repositories,omitempty"`
	// contains filtered or unexported fields
}

This struct holds the current state of the whole transfer of the source Artifactory instance. It is saved to a file in JFrog CLI's home. The transfer-files command uses this state to determine which phases need to be executed for each a repository, as well as other decisions related to the process execution.

func NewTransferState

func NewTransferState() *TransferState

type TransferStateManager

type TransferStateManager struct {
	TransferState
	TransferRunStatus
	// contains filtered or unexported fields
}

func InitStateTest added in v2.24.0

func InitStateTest(t *testing.T) (stateManager *TransferStateManager, cleanUp func())

func NewTransferStateManager

func NewTransferStateManager(loadRunStatus bool) (*TransferStateManager, error)

func (*TransferStateManager) AddNewDiffToState

func (ts *TransferStateManager) AddNewDiffToState(repoKey string, startTime time.Time) error

Adds new diff details to the repo's diff array in state. Marks files handling as started, and sets the handling range.

func (*TransferStateManager) ChangeTransferFailureCountBy added in v2.23.2

func (ts *TransferStateManager) ChangeTransferFailureCountBy(count uint, increase bool) error

func (*TransferStateManager) GetDiffHandlingRange

func (ts *TransferStateManager) GetDiffHandlingRange(repoKey string) (start, end time.Time, err error)

func (*TransferStateManager) GetReposTransferredSizeBytes

func (ts *TransferStateManager) GetReposTransferredSizeBytes(repoKeys ...string) (transferredSizeBytes int64, err error)

func (*TransferStateManager) GetTransferredSizeBytes

func (ts *TransferStateManager) GetTransferredSizeBytes() (transferredSizeBytes int64, err error)

func (*TransferStateManager) GetWorkingThreads

func (ts *TransferStateManager) GetWorkingThreads() (workingThreads int, err error)

func (*TransferStateManager) IncRepositoriesTransferred

func (ts *TransferStateManager) IncRepositoriesTransferred() error

func (*TransferStateManager) IncTransferredSizeAndFiles

func (ts *TransferStateManager) IncTransferredSizeAndFiles(repoKey string, chunkTotalFiles, chunkTotalSizeInBytes int64) error

func (*TransferStateManager) IsRepoTransferred

func (ts *TransferStateManager) IsRepoTransferred(repoKey string) (isTransferred bool, err error)

func (*TransferStateManager) SaveState

func (ts *TransferStateManager) SaveState() error

func (*TransferStateManager) SetFilesDiffHandlingCompleted

func (ts *TransferStateManager) SetFilesDiffHandlingCompleted(repoKey string) error

func (*TransferStateManager) SetRepoFullTransferCompleted

func (ts *TransferStateManager) SetRepoFullTransferCompleted(repoKey string) error

func (*TransferStateManager) SetRepoFullTransferStarted

func (ts *TransferStateManager) SetRepoFullTransferStarted(repoKey string, startTime time.Time) error

func (*TransferStateManager) SetRepoPhase

func (ts *TransferStateManager) SetRepoPhase(phaseId int) error

func (*TransferStateManager) SetRepoState

func (ts *TransferStateManager) SetRepoState(repoKey string, totalSizeBytes, totalFiles int64, buildInfoRepo, reset bool) error

Set the repository state. repoKey - Repository key totalSizeBytes - Repository size in bytes totalFiles - Total files in the repository reset - Delete the transferred info

func (*TransferStateManager) SetWorkingThreads

func (ts *TransferStateManager) SetWorkingThreads(workingThreads int) error

func (*TransferStateManager) TryLockTransferStateManager

func (ts *TransferStateManager) TryLockTransferStateManager() error

Try to lock the transfer state manager. If file-transfer is already running, return "Already locked" error.

func (*TransferStateManager) UnlockTransferStateManager

func (ts *TransferStateManager) UnlockTransferStateManager() error

Jump to

Keyboard shortcuts

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