Skip to content

Commit

Permalink
OpenCodeCo Enhancements (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
leocavalcante authored Dec 20, 2023
1 parent ff0ac0e commit 712a09d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/Listener/CommandListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function process(object $event): void
$process->exec($executable, $args);
});
$this->process->start();
sleep(1);
}
}
}
8 changes: 3 additions & 5 deletions src/MongoClient/Type/UpdateResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Hyperf\GoTask\MongoClient\Type;

use MongoDB\BSON\ObjectId;
use MongoDB\BSON\Unserializable;

class UpdateResult implements Unserializable
Expand All @@ -22,7 +23,7 @@ class UpdateResult implements Unserializable

private int $upsertedCount;

private ?string $upsertedId;
private ObjectId|string|null $upsertedId;

public function bsonUnserialize(array $data): void
{
Expand All @@ -32,10 +33,7 @@ public function bsonUnserialize(array $data): void
$this->upsertedId = $data['upsertedid'];
}

/**
* @return mixed
*/
public function getUpsertedId(): ?string
public function getUpsertedId(): ObjectId|string|null
{
return $this->upsertedId;
}
Expand Down
12 changes: 7 additions & 5 deletions src/Relay/CoroutineSocketRelay.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ public function connect(): bool

$this->socket = $this->createSocket();
try {
// Port type needs to be int, so we convert null to 0
if ($this->socket->connect($this->address, $this->port ?? 0) === false) {
throw new RelayException(sprintf('%s (%s)', $this->socket->errMsg, $this->socket->errCode));
}
\Hyperf\Support\retry(20, function(): void {
// Port type needs to be int, so we convert null to 0
if ($this->socket->connect($this->address, $this->port ?? 0) === false) {
throw new RelayException(sprintf('%s (%s)', $this->socket->errMsg, $this->socket->errCode));
}
}, 100);
} catch (Exception $e) {
throw new RelayException("unable to establish connection {$this}: {$e->getMessage()}", 0, $e);
throw new RelayException("unable to establish connection (20x) {$this}: {$e->getMessage()}", 0, $e);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Wrapper/LoggerWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
) {
}

public function log(array $payload): ?mixed
public function log(array $payload): mixed
{
$this->logger->log($payload['level'], $payload['message'], $payload['context']);
return null;
Expand Down

0 comments on commit 712a09d

Please sign in to comment.