chore(deploy): add prod env template, improve ansible deploy, prune old workflows
- Add deployment/ansible/templates/.env.production.j2 used by secrets playbook - Enhance deploy-update.yml to read registry creds from vault or CI - Update production-deploy workflow to pass registry credentials to Ansible - Remove obsolete GitHub-style workflows under .gitea (conflicted naming) Why: make the production pipeline executable end-to-end with Ansible and consistent secrets handling; avoid legacy CI configs interfering.
This commit is contained in:
@@ -8,12 +8,18 @@ use InvalidArgumentException;
|
||||
|
||||
final readonly class Duration
|
||||
{
|
||||
private function __construct(
|
||||
private int $nanoseconds
|
||||
private int $nanoseconds;
|
||||
public function __construct(
|
||||
float|int $value,
|
||||
TimeUnit $unit = TimeUnit::NANOSECOND,
|
||||
) {
|
||||
if ($nanoseconds < 0) {
|
||||
if ($value < 0) {
|
||||
throw new InvalidArgumentException('Duration cannot be negative');
|
||||
}
|
||||
|
||||
$seconds = $value * $unit->getMultiplierToSeconds();
|
||||
|
||||
$this->nanoseconds = (int) round($seconds * 1_000_000_000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,27 +27,18 @@ final readonly class Duration
|
||||
*/
|
||||
public static function fromNanoseconds(int $nanoseconds): self
|
||||
{
|
||||
return new self($nanoseconds);
|
||||
return new self($nanoseconds, TimeUnit::NANOSECOND);
|
||||
}
|
||||
|
||||
// Factory Methods
|
||||
public static function fromSeconds(float $seconds): self
|
||||
{
|
||||
if ($seconds < 0) {
|
||||
throw new InvalidArgumentException('Duration cannot be negative');
|
||||
}
|
||||
|
||||
return new self((int) round($seconds * 1_000_000_000));
|
||||
return new self($seconds, TimeUnit::SECOND);
|
||||
}
|
||||
|
||||
public static function fromUnit(float $value, TimeUnit $unit): self
|
||||
{
|
||||
if ($value < 0) {
|
||||
throw new InvalidArgumentException('Duration cannot be negative');
|
||||
}
|
||||
$seconds = $value * $unit->getMultiplierToSeconds();
|
||||
|
||||
return new self((int) round($seconds * 1_000_000_000));
|
||||
return new self($value, $unit);
|
||||
}
|
||||
|
||||
public static function fromMilliseconds(float $milliseconds): self
|
||||
@@ -109,24 +106,24 @@ final readonly class Duration
|
||||
return round($seconds / $unit->getMultiplierToSeconds(), $precision);
|
||||
}
|
||||
|
||||
public function toMilliseconds(): float
|
||||
public function toMilliseconds(int $precision = 0): float
|
||||
{
|
||||
return $this->toUnit(TimeUnit::MILLISECOND, 0);
|
||||
return $this->toUnit(TimeUnit::MILLISECOND, $precision);
|
||||
}
|
||||
|
||||
public function toMicroseconds(): float
|
||||
public function toMicroseconds(int $precision = 0): float
|
||||
{
|
||||
return $this->toUnit(TimeUnit::MICROSECOND, 0);
|
||||
return $this->toUnit(TimeUnit::MICROSECOND, $precision);
|
||||
}
|
||||
|
||||
public function toMinutes(): float
|
||||
public function toMinutes(int $precision = 0): float
|
||||
{
|
||||
return $this->toUnit(TimeUnit::MINUTE);
|
||||
return $this->toUnit(TimeUnit::MINUTE, $precision);
|
||||
}
|
||||
|
||||
public function toHours(): float
|
||||
public function toHours(int $precision = 0): float
|
||||
{
|
||||
return $this->toUnit(TimeUnit::HOUR);
|
||||
return $this->toUnit(TimeUnit::HOUR, $precision);
|
||||
}
|
||||
|
||||
// Human-readable format
|
||||
@@ -192,7 +189,7 @@ final readonly class Duration
|
||||
|
||||
public function isNotZero(): bool
|
||||
{
|
||||
return $this->nanoseconds > 0;
|
||||
return !$this->isZero();
|
||||
}
|
||||
|
||||
// Framework Integration
|
||||
@@ -219,7 +216,7 @@ final readonly class Duration
|
||||
|
||||
public static function oneSecond(): self
|
||||
{
|
||||
return new self(1_000_000_000);
|
||||
return new self(1, TimeUnit::SECOND);
|
||||
}
|
||||
|
||||
public static function oneMinute(): self
|
||||
|
||||
Reference in New Issue
Block a user