1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:59:01 +01:00

Improvements

This commit is contained in:
Daniil Gentili 2019-06-03 22:33:53 +02:00
parent 120ff0aba9
commit e80d67037c
7 changed files with 34 additions and 10 deletions

View File

@ -1,12 +1,15 @@
# Changelog
## 4.0.0 Full async
**Fully asynchronous MadelineProto, thanks to [amphp](https://github.com/danog/amphp)!**
**Fully asynchronous MadelineProto!**
MadelineProto now features async, for **incredible speed improvements**, and **parallel processing**.
Powered by [amphp](https://amphp.org), MadelineProto wraps the AMPHP APIs to provide a simpler generator-based async API.
* Fully rewritten connection stack, with support for websockets, stuff
* updates
* simultaneous method calls
* new TL callback system
* added support for wallpapers
* Improved message splitting algorithm: performance improvements, and it will now notify you via the logs if there are too many entities in the logs, or if the entities are too long.
@ -41,6 +44,7 @@
* async HTTP requests internally
* custom HTTP client with DoH
* no more php 5
* reset PTS to 0
Things to expect in the next releases:
docs for update_2fa

2
docs

@ -1 +1 @@
Subproject commit da911f8e77afaae1ea9999a977868b87138d0b30
Subproject commit f76840d014585d3ffbe8a272cd967c3d6321c096

View File

@ -156,6 +156,7 @@ class APIFactory extends AsyncConstruct
{
if ($this->asyncInitPromise) {
yield $this->initAsync();
$this->API->logger->logger("Finished init asynchronously");
}
if (Magic::is_fork() && !Magic::$processed_fork) {
throw new Exception("Forking not supported, use async logic, instead: https://docs.madelineproto.xyz/docs/ASYNC.html");
@ -171,6 +172,7 @@ class APIFactory extends AsyncConstruct
}
if ($this->API->asyncInitPromise) {
yield $this->API->initAsync();
$this->API->logger->logger("Finished init asynchronously");
}
$lower_name = strtolower($name);

View File

@ -60,6 +60,11 @@ class GenericLoop extends ResumableSignalLoop
while (true) {
$timeout = yield $callback();
if ($timeout === self::PAUSE) {
$this->API->logger->logger("Pausing $this", \danog\MadelineProto\Logger::VERBOSE);
} else if ($timeout > 0) {
$this->API->logger->logger("Pausing $this for $timeout", \danog\MadelineProto\Logger::VERBOSE);
}
if ($timeout === self::STOP || yield $this->waitSignal($this->pause($timeout))) {
return;
}
@ -68,6 +73,6 @@ class GenericLoop extends ResumableSignalLoop
public function __toString(): string
{
return "{$this->name} loop";
return $this->name;
}
}

View File

@ -48,9 +48,7 @@ abstract class Loop implements LoopInterface
return false;
}
$this->callFork($this->loopImpl());
return true;
return $this->callFork($this->loopImpl());
}
private function loopImpl()
@ -63,7 +61,7 @@ abstract class Loop implements LoopInterface
} finally {
$this->exitedLoop();
$this->API->logger->logger("Exited $this", Logger::ULTRA_VERBOSE);
return null;
//return null;
}
}

View File

@ -883,9 +883,19 @@ class MTProto extends AsyncConstruct implements TLCallback
yield $this->get_phone_config_async();
}
public function resetUpdateSystem()
{
foreach ($this->channels_state->get() as $state) {
$channelId = $state->getChannel();
$this->channels_state->__construct([$channelId => new UpdatesState()]);
}
$this->startUpdateSystem();
}
public function startUpdateSystem()
{
if ($this->asyncInitPromise) return;
if ($this->asyncInitPromise) {
return;
}
if (!isset($this->seqUpdater)) {
$this->seqUpdater = new SeqLoop($this);

View File

@ -20,6 +20,7 @@
namespace danog\MadelineProto\Wrappers;
use Amp\Deferred;
use Amp\Promise;
/**
* Manages logging in and out.
@ -36,9 +37,13 @@ trait Loop
public function loop_async($max_forks = 0)
{
if (is_callable($max_forks)) {
$this->logger->logger('Running async callable and exiting from loop');
$this->logger->logger('Running async callable');
return yield $max_forks();
}
if ($max_forks instanceof Promise) {
$this->logger->logger('Resolving async promise');
return yield $max_forks;
}
if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) {
$this->logger->logger('Getupdates event handler is enabled, exiting from loop', \danog\MadelineProto\Logger::FATAL_ERROR);
return false;