apihelper

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinSyncIntervalSeconds  = 10
	MinRunDelayMilliseconds = 100
)

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 GetDBModels

func GetDBModels(opts *GetDBModelsOptions) error

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, app *appsrv.Application, prefix string)

type GetDBModelsOptions

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

func (GetDBModelsOptions) BatchListSize

func (o GetDBModelsOptions) BatchListSize() int

func (GetDBModelsOptions) GetModelSet

func (o GetDBModelsOptions) GetModelSet() IModelSet

func (GetDBModelsOptions) InCludeOtherCloudEnv

func (o GetDBModelsOptions) InCludeOtherCloudEnv() bool

func (GetDBModelsOptions) IncludeDetails

func (o GetDBModelsOptions) IncludeDetails() bool

func (GetDBModelsOptions) IncludeEmulated

func (o GetDBModelsOptions) IncludeEmulated() bool

func (GetDBModelsOptions) IncludeOtherCloudEnv

func (o GetDBModelsOptions) IncludeOtherCloudEnv() bool

type GetModelsOptions

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

	BatchListSize        int
	IncludeDetails       bool
	IncludeEmulated      bool
	InCludeOtherCloudEnv bool
}

type IDBModelSet

type IDBModelSet interface {
	IModelSet
	DBModelManager() db.IModelManager
}

type IDBModelSets

type IDBModelSets interface {
	IModelSets
	FetchFromAPIMap(s *mcclient.ClientSession) (IModelSets, error)
}

type IModelListParam

type IModelListParam interface {
	ModelParamFilter() jsonutils.JSONObject
}

type IModelListSetParams

type IModelListSetParams interface {
	SetModelListParams(params *jsonutils.JSONDict) *jsonutils.JSONDict
}

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 SyncDBModelSets

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

func SyncModelSets

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

type Options

type Options struct {
	common_options.CommonOptions

	SyncIntervalSeconds     int
	RunDelayMilliseconds    int
	ListBatchSize           int
	IncludeDetails          bool
	IncludeOtherCloudEnv    bool
	FetchFromComputeService bool
}

Jump to

Keyboard shortcuts

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