Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@

interface Server
{
#[\NoDiscard]
public function processes(): Processes;

#[\NoDiscard]
public function volumes(): Volumes;

/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function reboot(): Attempt;

/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function shutdown(): Attempt;
}
14 changes: 14 additions & 0 deletions src/Server/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private function __construct(bool $background, string $executable)
*
* @param non-empty-string $executable
*/
#[\NoDiscard]
public static function background(string $executable): self
{
return new self(true, $executable);
Expand All @@ -87,11 +88,13 @@ public static function background(string $executable): self
*
* @param non-empty-string $executable
*/
#[\NoDiscard]
public static function foreground(string $executable): self
{
return new self(false, $executable);
}

#[\NoDiscard]
public function withArgument(string $value): self
{
$self = clone $this;
Expand All @@ -103,6 +106,7 @@ public function withArgument(string $value): self
/**
* @param non-empty-string $key
*/
#[\NoDiscard]
public function withOption(string $key, ?string $value = null): self
{
$self = clone $this;
Expand All @@ -114,6 +118,7 @@ public function withOption(string $key, ?string $value = null): self
/**
* @param non-empty-string $key
*/
#[\NoDiscard]
public function withShortOption(string $key, ?string $value = null): self
{
$self = clone $this;
Expand All @@ -125,6 +130,7 @@ public function withShortOption(string $key, ?string $value = null): self
/**
* @param non-empty-string $key
*/
#[\NoDiscard]
public function withEnvironment(string $key, string $value): self
{
$self = clone $this;
Expand All @@ -136,6 +142,7 @@ public function withEnvironment(string $key, string $value): self
/**
* @param Map<non-empty-string, string> $values
*/
#[\NoDiscard]
public function withEnvironments(Map $values): self
{
$self = clone $this;
Expand All @@ -144,6 +151,7 @@ public function withEnvironments(Map $values): self
return $self;
}

#[\NoDiscard]
public function withWorkingDirectory(Path $path): self
{
$self = clone $this;
Expand All @@ -152,6 +160,7 @@ public function withWorkingDirectory(Path $path): self
return $self;
}

#[\NoDiscard]
public function withInput(Content $input): self
{
$self = clone $this;
Expand All @@ -160,6 +169,7 @@ public function withInput(Content $input): self
return $self;
}

#[\NoDiscard]
public function overwrite(Path $path): self
{
$self = clone $this;
Expand All @@ -168,6 +178,7 @@ public function overwrite(Path $path): self
return $self;
}

#[\NoDiscard]
public function append(Path $path): self
{
$self = clone $this;
Expand All @@ -176,6 +187,7 @@ public function append(Path $path): self
return $self;
}

#[\NoDiscard]
public function pipe(self $command): self
{
$self = clone $this;
Expand All @@ -195,6 +207,7 @@ public function pipe(self $command): self
return $self;
}

#[\NoDiscard]
public function timeoutAfter(Period $timeout): self
{
$self = clone $this;
Expand All @@ -213,6 +226,7 @@ public function timeoutAfter(Period $timeout): self
* This is useful in the case you need to access the output but can't fit it
* in memory like streaming large files.
*/
#[\NoDiscard]
public function streamOutput(): self
{
$self = clone $this;
Expand Down
3 changes: 3 additions & 0 deletions src/Server/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static function background(Started $started): self
*
* @return Maybe<Pid>
*/
#[\NoDiscard]
public function pid(): Maybe
{
return $this->implementation->pid();
Expand All @@ -60,6 +61,7 @@ public function pid(): Maybe
/**
* @return Sequence<Output\Chunk>
*/
#[\NoDiscard]
public function output(): Sequence
{
return $this->implementation->output();
Expand All @@ -73,6 +75,7 @@ public function output(): Sequence
*
* @return Either<TimedOut|Failed|Signaled, Success>
*/
#[\NoDiscard]
public function wait(): Either
{
return $this->implementation->wait();
Expand Down
3 changes: 3 additions & 0 deletions src/Server/Process/ExitCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct(
) {
}

#[\NoDiscard]
public function successful(): bool
{
return $this->value === 0;
Expand All @@ -25,6 +26,7 @@ public function successful(): bool
/**
* @return int<0, 255>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
Expand All @@ -33,6 +35,7 @@ public function toInt(): int
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return (string) $this->value;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Process/Failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct(
) {
}

#[\NoDiscard]
public function exitCode(): ExitCode
{
return $this->exitCode;
Expand All @@ -25,6 +26,7 @@ public function exitCode(): ExitCode
/**
* @return Sequence<Output\Chunk>
*/
#[\NoDiscard]
public function output(): Sequence
{
return $this->output;
Expand Down
3 changes: 3 additions & 0 deletions src/Server/Process/Output/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ private function __construct(
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function of(Str $data, Type $type): self
{
return new self($data, $type);
}

#[\NoDiscard]
public function data(): Str
{
return $this->data;
}

#[\NoDiscard]
public function type(): Type
{
return $this->type;
Expand Down
1 change: 1 addition & 0 deletions src/Server/Process/Output/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum Type
case output;
case error;

#[\NoDiscard]
public function toString(): string
{
return match ($this) {
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Process/Pid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct(
/**
* @return int<2, max>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
Expand All @@ -28,6 +29,7 @@ public function toInt(): int
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return (string) $this->value;
Expand Down
1 change: 1 addition & 0 deletions src/Server/Process/Signaled.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(
/**
* @return Sequence<Output\Chunk>
*/
#[\NoDiscard]
public function output(): Sequence
{
return $this->output;
Expand Down
1 change: 1 addition & 0 deletions src/Server/Process/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(
/**
* @return Sequence<Output\Chunk>
*/
#[\NoDiscard]
public function output(): Sequence
{
return $this->output;
Expand Down
1 change: 1 addition & 0 deletions src/Server/Process/TimedOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(
/**
* @return Sequence<Output\Chunk>
*/
#[\NoDiscard]
public function output(): Sequence
{
return $this->output;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Processes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ interface Processes
/**
* @return Attempt<Process>
*/
#[\NoDiscard]
public function execute(Command $command): Attempt;

/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function kill(Pid $pid, Signal $signal): Attempt;
}
2 changes: 2 additions & 0 deletions src/Server/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(
/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function __invoke(Server $server): Attempt
{
$processes = $server->processes();
Expand All @@ -48,6 +49,7 @@ public function __invoke(Server $server): Attempt
/**
* @no-named-arguments
*/
#[\NoDiscard]
public static function of(Command ...$commands): self
{
return new self(Sequence::of(...$commands));
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Signal.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Signal
case alarm;
case terminate;

#[\NoDiscard]
public function toInt(): int
{
return match ($this) {
Expand All @@ -32,6 +33,7 @@ public function toInt(): int
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return (string) $this->toInt();
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Volumes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ interface Volumes
/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function mount(Name $name, Path $mountpoint): Attempt;

/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function unmount(Name $name): Attempt;
}
1 change: 1 addition & 0 deletions src/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class ServerFactory
/**
* @throws UnsupportedOperatingSystem For windows system
*/
#[\NoDiscard]
public static function build(
Clock $clock,
IO $io,
Expand Down
Loading