generated from spiral-packages/package-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Connection classes with single ConnectionConfig class
- Loading branch information
Showing
9 changed files
with
111 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\TemporalBridge\Config; | ||
|
||
/** | ||
* Temporal connection configuration. | ||
* | ||
* How to connect to local Temporal server: | ||
* | ||
* ```php | ||
* ConnectionConfig::createInsecure('localhost:7233') | ||
* ``` | ||
* | ||
* How to connect to Temporal Cloud: | ||
* | ||
* ```php | ||
* ConnectionConfig::createCloud( | ||
* address: 'foo-bar-default.baz.tmprl.cloud:7233', | ||
* privateKey: '/my-project.key', | ||
* certChain: '/my-project.pem', | ||
* ) | ||
* ``` | ||
*/ | ||
final class ConnectionConfig | ||
{ | ||
private function __construct( | ||
public readonly string $address, | ||
public readonly bool $secure = false, | ||
public readonly ?string $rootCerts = null, | ||
public readonly ?string $privateKey = null, | ||
public readonly ?string $certChain = null, | ||
) {} | ||
|
||
/** | ||
* @param non-empty-string $address | ||
*/ | ||
public static function createInsecure( | ||
string $address, | ||
): self { | ||
return new self($address); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $address | ||
* @param non-empty-string|null $rootCerts Root certificates string or file in PEM format. | ||
* If null provided, default gRPC root certificates are used. | ||
* @param non-empty-string|null $privateKey Client private key string or file in PEM format. | ||
* @param non-empty-string|null $certChain Client certificate chain string or file in PEM format. | ||
*/ | ||
public static function createSecure( | ||
string $address, | ||
?string $rootCerts = null, | ||
?string $privateKey = null, | ||
?string $certChain = null, | ||
): self { | ||
return new self($address, true, $rootCerts, $privateKey, $certChain); | ||
} | ||
|
||
/** | ||
* Used to connect to Temporal Cloud. | ||
* | ||
* @link https://docs.temporal.io/cloud/get-started | ||
* | ||
* @param non-empty-string $address | ||
* @param non-empty-string $privateKey Client private key string or file in PEM format. | ||
* @param non-empty-string $certChain Client certificate chain string or file in PEM format. | ||
*/ | ||
public static function createCloud( | ||
string $address, | ||
string $privateKey, | ||
string $certChain, | ||
): self { | ||
return new self($address, true, null, $privateKey, $certChain); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters