Fixes
This commit is contained in:
parent
db24e8e871
commit
d792263e86
@ -92,7 +92,7 @@ $settings = [
|
||||
],
|
||||
'serialization' => [
|
||||
'serialization_interval' => 30,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$MadelineProto = new API('bot.madeline', $settings);
|
||||
|
@ -32,6 +32,7 @@ abstract class DriverArray implements DbArray
|
||||
}
|
||||
|
||||
abstract public function initConnection($settings): \Generator;
|
||||
abstract public function initStartup(): \Generator;
|
||||
|
||||
/**
|
||||
* @param self $new
|
||||
|
@ -35,7 +35,7 @@ class MemoryArray extends \ArrayIterator implements DbArray
|
||||
if ($value instanceof DbArray) {
|
||||
Logger::log("Loading database to memory. Please wait.", Logger::WARNING);
|
||||
if ($value instanceof DriverArray) {
|
||||
yield from $value->initConnection($value->dbSettings);
|
||||
yield from $value->initStartup();
|
||||
}
|
||||
$value = yield $value->getArrayCopy();
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use function Amp\call;
|
||||
class RedisArray extends SqlArray
|
||||
{
|
||||
protected string $table;
|
||||
public DatabaseRedis $dbSettings;
|
||||
protected DatabaseRedis $dbSettings;
|
||||
private RedisRedis $db;
|
||||
|
||||
// Legacy
|
||||
@ -56,6 +56,7 @@ class RedisArray extends SqlArray
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return ['table', 'dbSettings'];
|
||||
|
@ -19,6 +19,16 @@ abstract class SqlArray extends DriverArray
|
||||
|
||||
abstract protected function renameTable(string $from, string $to): \Generator;
|
||||
|
||||
/**
|
||||
* Initialize on startup.
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function initStartup(): \Generator
|
||||
{
|
||||
return $this->initConnection($this->dbSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param DbArray|array|null $value
|
||||
@ -49,7 +59,7 @@ abstract class SqlArray extends DriverArray
|
||||
// Skip migrations if its same object
|
||||
if ($instance !== $value) {
|
||||
if ($value instanceof DriverArray) {
|
||||
yield from $value->initConnection($value->dbSettings);
|
||||
yield from $value->initStartup();
|
||||
}
|
||||
yield from static::renameTmpTable($instance, $value);
|
||||
yield from static::migrateDataToDb($instance, $value);
|
||||
|
@ -194,7 +194,7 @@ abstract class Serialization
|
||||
$unserialized = yield from $session->unserialize();
|
||||
if ($unserialized instanceof DriverArray) {
|
||||
Logger::log("Extracting session from database...");
|
||||
yield from $unserialized->initConnection($unserialized->dbSettings);
|
||||
yield from $unserialized->initStartup();
|
||||
$unserialized = yield $unserialized['data'];
|
||||
if (!$unserialized) {
|
||||
throw new Exception("Could not extract session from database!");
|
||||
|
@ -29,7 +29,7 @@ class Ipc extends SettingsAbstract
|
||||
|
||||
/**
|
||||
* Whether to force full deserialization of instance, without using the IPC server/client.
|
||||
*
|
||||
*
|
||||
* WARNING: this will cause slow startup if enabled.
|
||||
*
|
||||
* @param bool $slow WARNING: this will cause slow startup if enabled.
|
||||
|
Loading…
Reference in New Issue
Block a user