Esempio n. 1
0
        /// <summary>
        /// Construct
        /// </summary>
        /// <param name="connectionResolver">Host app function to get an open database connection, which will be disposed after each use</param>
        public Retroverse(SqlFlavorizer.VendorKind dbVendor, DataDictionary ddict, Func <int, DbConnection> connectionResolver,
                          int lockDatabaseNumber = 0, bool integrationTestMode = false)
        {
            if (!ddict.IsFinalized)
            {
                throw new Exception("DataDictionary must be finalized first");
            }
            DatabaseVendor  = dbVendor;
            DataDictionary  = ddict;
            GetDbConnection = connectionResolver;
            LockManager     = new LockManager(() => GetDbConnection(lockDatabaseNumber), PropogatePersistonChanged);
            DefaultSql      = new RetroSql();
            DefaultSql.Initialize(DatabaseVendor);
            Diagnostics         = new Diagnostics(ClientPlex, DatonCache);
            IntegrationTestMode = integrationTestMode;

            //set up process to clean cache
            BackgroundWorker.Register(() =>
            {
                DatonCache.Clean(ClientPlex);
                return(Task.CompletedTask);
            }, 60);

            //set up process to clean abandoned sessions
            void clientCleanerCallback(string sessionKey) => LockManager.ReleaseLocksForSession(sessionKey);

            if (!integrationTestMode)
            {
                BackgroundWorker.Register(() =>
                {
                    ClientPlex.Clean(clientCleanerCallback);
                    return(Task.CompletedTask);
                }, 70);
            }

            //set up process for communication with other servers about locks
            int interServerInterval = integrationTestMode ? 4 : 30; //seconds

            BackgroundWorker.Register(DoLockRefresh, interServerInterval);
        }
Esempio n. 2
0
 /// <summary>
 /// Inject the implementation of RetroSql for the given type name
 /// </summary>
 /// <param name="typeName">matches Daton subclass name</param>
 public void OverrideSql(string typeName, RetroSql r)
 {
     r.Initialize(DatabaseVendor);
     SqlOverrides[typeName] = r;
 }
Esempio n. 3
0
 /// <summary>
 /// Inject the implementation of RetroSql for all types.
 /// </summary>
 public void OverrideAllSql(RetroSql r)
 {
     r.Initialize(DatabaseVendor);
     DefaultSql = r;
 }