github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/appparts/interface.go (about) 1 /* 2 * Copyright (c) 2021-present Sigma-Soft, Ltd. 3 * @author: Nikolay Nikitin 4 */ 5 6 package appparts 7 8 import ( 9 "context" 10 11 "github.com/voedger/voedger/pkg/appdef" 12 "github.com/voedger/voedger/pkg/istructs" 13 ) 14 15 // Application partitions manager. 16 // 17 // @ConcurrentAccess 18 type IAppPartitions interface { 19 // Adds new application or update existing. 20 // 21 // partsCount - total partitions count for the application. 22 // 23 // If application with the same name exists, then its definition will be updated. 24 DeployApp(name istructs.AppQName, def appdef.IAppDef, partsCount istructs.NumAppPartitions, numEngines [ProcessorKind_Count]int) 25 26 // Deploys new partitions for specified application or update existing. 27 // 28 // If partition with the same app and id already exists, it will be updated. 29 // 30 // # Panics: 31 // - if application not exists 32 DeployAppPartitions(appName istructs.AppQName, partIDs []istructs.PartitionID) 33 34 // Returns application definition. 35 // 36 // Returns nil and error if app not exists. 37 AppDef(istructs.AppQName) (appdef.IAppDef, error) 38 39 // Returns _total_ application partitions count. 40 // 41 // This is a configuration value for the application, independent of how many sections are currently deployed. 42 // 43 // Returns 0 and error if app not exists. 44 AppPartsCount(istructs.AppQName) (istructs.NumAppPartitions, error) 45 46 // Returns partition ID for specified workspace 47 // 48 // Returns error if app not exists. 49 AppWorkspacePartitionID(istructs.AppQName, istructs.WSID) (istructs.PartitionID, error) 50 51 // Borrows and returns a partition. 52 // 53 // If partition not exist, returns error. 54 Borrow(istructs.AppQName, istructs.PartitionID, ProcessorKind) (IAppPartition, error) 55 56 // Waits for partition to be available and borrows it. 57 // 58 // If partition not exist, returns error. 59 WaitForBorrow(context.Context, istructs.AppQName, istructs.PartitionID, ProcessorKind) (IAppPartition, error) 60 } 61 62 // Application partition. 63 type IAppPartition interface { 64 App() istructs.AppQName 65 ID() istructs.PartitionID 66 67 AppStructs() istructs.IAppStructs 68 69 // Releases borrowed partition 70 Release() 71 72 DoSyncActualizer(ctx context.Context, work interface{}) (err error) 73 74 // Invoke extension engine. 75 Invoke(ctx context.Context, name appdef.QName, state istructs.IState, intents istructs.IIntents) error 76 } 77 78 // dependency cycle: func requires IAppPartitions, provider of IAppPartitions requires already filled AppConfigsType -> impossible to provide AppConfigsType because we're filling it now 79 // TODO: eliminate this workaround 80 // type BuiltInAppsDeploymentDescriptors map[istructs.AppQName]AppDeploymentDescriptor