apihelper

package
v0.3.9-5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	ErrSync = errors.Error("sync error")
)

Variables

View Source
var PseudoZeroTime = time.Time{}.Add(time.Nanosecond)

A hack to workaround the IsZero() in timeutils.Utcify. This depends on the fact that database time has a resolution of 1-second

Functions

func GetModels

func GetModels(opts *GetModelsOptions) error

func InitializeModelSetFromJSON

func InitializeModelSetFromJSON(set IModelSet, entriesJson []jsonutils.JSONObject) error

func ModelSetMaxUpdatedAt

func ModelSetMaxUpdatedAt(set IModelSet) time.Time

Types

type APIHelper

type APIHelper struct {
	// contains filtered or unexported fields
}

func NewAPIHelper

func NewAPIHelper(opts *Options, modelSets IModelSets) (*APIHelper, error)

func (*APIHelper) ModelSets

func (h *APIHelper) ModelSets() <-chan IModelSets

func (*APIHelper) RunManually

func (h *APIHelper) RunManually(ctx context.Context)

func (*APIHelper) Start

func (h *APIHelper) Start(ctx context.Context)

type GetModelsOptions

type GetModelsOptions struct {
	ClientSession *mcclient.ClientSession
	ModelManager  mcclient_modulebase.IBaseManager
	ModelSet      IModelSet

	BatchListSize        int
	MinUpdatedAt         time.Time
	IncludeDetails       bool
	IncludeEmulated      bool
	InCludeOtherCloudEnv bool
}

type IModelListParam

type IModelListParam interface {
	ModelParamFilter() jsonutils.JSONObject
}

type IModelSet

type IModelSet interface {
	ModelManager() mcclient_modulebase.IBaseManager
	NewModel() db.IModel
	AddModel(db.IModel)
	Copy() IModelSet
}

type IModelSetEmulatedIncluder

type IModelSetEmulatedIncluder interface {
	IncludeEmulated() bool
}

type IModelSetFilter

type IModelSetFilter interface {
	ModelFilter() []string
}

type IModelSets

type IModelSets interface {
	NewEmpty() IModelSets
	ModelSetList() []IModelSet
	ApplyUpdates(IModelSets) ModelSetsUpdateResult
	Copy() IModelSets
	CopyJoined() IModelSets
}

type ModelSetUpdateResult

type ModelSetUpdateResult struct {
	Changed      bool
	MaxUpdatedAt time.Time
}

func ModelSetApplyUpdates

func ModelSetApplyUpdates(aSet, bSet IModelSet) *ModelSetUpdateResult

ModelSetApplyUpdates applies bSet to aSet.

  • PendingDeleted in bSet are removed from aSet
  • Newer models in bSet are updated in aSet

type ModelSetsUpdateResult

type ModelSetsUpdateResult struct {
	Correct bool
	Changed bool
}

func SyncModelSets

func SyncModelSets(mssOld IModelSets, s *mcclient.ClientSession, opt *Options) (r ModelSetsUpdateResult, err error)

type Options

type Options struct {
	common_options.CommonOptions

	SyncInterval         int
	ListBatchSize        int
	IncludeDetails       bool
	IncludeOtherCloudEnv bool
}

Jump to

Keyboard shortcuts

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