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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ jobs:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
uses: innmind/github-workflows/.github/workflows/cs.yml@main
with:
php-version: '8.2'
12 changes: 12 additions & 0 deletions .github/workflows/extensive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Extensive CI

on:
push:
tags:
- '*'
paths:
- '.github/workflows/extensive.yml'

jobs:
blackbox:
uses: innmind/github-workflows/.github/workflows/extensive.yml@main
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [Unreleased]

### Added

- `Innmind\HttpTransport\Config`
- `Innmind\HttpTransport\Transport::map()`

### Changed

- Requires PHP `8.4`
- `Innmind\HttpTransport\Transport` is now a final class, all previous implementations are now flagged as internal
- Requires `innmind/http:~9.0`
- Requires `innmind/time:~1.0`

### Removed

- `Innmind\HttpTransport\Curl::maxConcurrency()` use `::map()` instead
- `Innmind\HttpTransport\Curl::disableSSLVerification()` use `::map()` instead
- `Innmind\HttpTransport\Curl::proxy()` use `::map()` instead
- `Innmind\HttpTransport\Curl::heartbeat()` (as it was intended for internal use)

### Fixed

- PHP `8.5` deprecation

## 8.1.0 - 2025-09-18

### Added
Expand Down
4 changes: 4 additions & 0 deletions blackbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
};

Application::new($argv)
->when(
\getenv('BLACKBOX_SET_SIZE') !== false,
static fn(Application $app) => $app->scenariiPerProof((int) \getenv('BLACKBOX_SET_SIZE')),
)
->when(
\getenv('ENABLE_COVERAGE') !== false,
static fn(Application $app) => $app
Expand Down
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
"issues": "http://github.com/Innmind/HttpTransport/issues"
},
"require": {
"php": "~8.2",
"php": "~8.4",
"ext-curl": "*",
"innmind/http": "~8.0",
"innmind/filesystem": "~8.1",
"innmind/http": "~9.0",
"innmind/filesystem": "~9.0",
"psr/log": "~3.0",
"ramsey/uuid": "^4.7",
"innmind/time-warp": "~4.0",
"innmind/time-continuum": "^4.1.1",
"innmind/immutable": "~5.14",
"innmind/url": "~4.0",
"innmind/io": "~3.2"
"innmind/time": "~1.0",
"innmind/immutable": "~6.0",
"innmind/url": "~5.0",
"innmind/io": "~4.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,8 +37,8 @@
}
},
"require-dev": {
"innmind/static-analysis": "^1.2.1",
"innmind/static-analysis": "~1.3",
"innmind/coding-standard": "~2.0",
"innmind/black-box": "~6.2"
"innmind/black-box": "~6.5"
}
}
29 changes: 22 additions & 7 deletions src/CircuitBreaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@
Header\Value,
};
use Innmind\Url\Url;
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Period,
PointInTime,
Point,
};
use Innmind\Immutable\{
Map,
Either,
};

/**
* @psalm-import-type Errors from Transport
* @internal
* @psalm-import-type Errors from Implementation
*/
final class CircuitBreaker implements Transport
final class CircuitBreaker implements Implementation
{
/**
* @param Map<string , PointInTime> $openedCircuits
* @param Map<string, Point> $openedCircuits
*/
private function __construct(
private Transport $fulfill,
private Implementation $fulfill,
private Clock $clock,
private Period $delayBeforeRetry,
private Map $openedCircuits,
Expand All @@ -54,7 +55,7 @@ public function __invoke(Request $request): Either
}

public static function of(
Transport $fulfill,
Implementation $fulfill,
Clock $clock,
Period $delayBeforeRetry,
): self {
Expand All @@ -66,6 +67,20 @@ public static function of(
);
}

/**
* @psalm-mutation-free
*/
#[\Override]
public function map(callable $map): self
{
return new self(
$this->fulfill->map($map),
$this->clock,
$this->delayBeforeRetry,
Map::of(),
);
}

private function open(
Request $request,
ServerError|ConnectionFailed $error,
Expand Down
106 changes: 106 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
declare(strict_types = 1);

namespace Innmind\HttpTransport;

use Innmind\Url\Url;
use Innmind\Immutable\Maybe;

/**
* @psalm-immutable
*/
final class Config
{
/**
* @param Maybe<int<1, max>> $maxConcurrency
* @param Maybe<Url> $proxy
*/
private function __construct(
private Maybe $maxConcurrency,
private bool $verifySSL,
private Maybe $proxy,
) {
}

/**
* @psalm-pure
*/
public static function new(): self
{
/** @var Maybe<int<1, max>> */
$maxConcurrency = Maybe::nothing();
/** @var Maybe<Url> */
$proxy = Maybe::nothing();

return new self(
$maxConcurrency,
true,
$proxy,
);
}

/**
* @param int<1, max> $max
*/
#[\NoDiscard]
public function limitConcurrencyTo(int $max): self
{
return new self(
Maybe::just($max),
$this->verifySSL,
$this->proxy,
);
}

/**
* You should use this method only when trying to call a server you own that
* uses a self signed certificate that will fail the verification.
*/
#[\NoDiscard]
public function disableSSLVerification(): self
{
return new self(
$this->maxConcurrency,
false,
$this->proxy,
);
}

#[\NoDiscard]
public function throughProxy(Url $proxy): self
{
return new self(
$this->maxConcurrency,
$this->verifySSL,
Maybe::just($proxy),
);
}

/**
* @internal
*
* @return Maybe<int<1, max>>
*/
public function maxConcurrency(): Maybe
{
return $this->maxConcurrency;
}

/**
* @internal
*/
public function verifySSL(): bool
{
return $this->verifySSL;
}

/**
* @internal
*
* @return Maybe<Url>
*/
public function proxy(): Maybe
{
return $this->proxy;
}
}
Loading