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