Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Temporal Connection Configuration with SSL Support and Flexibility #83

Merged
merged 20 commits into from
Aug 30, 2024

Conversation

butschster
Copy link
Member

@butschster butschster commented Mar 22, 2024

This PR introduces the ability to configure multiple connections to Temporal servers, including SSL-enabled connections. It aims to provide greater flexibility and security in connection setup, improving upon the previous single-address configuration approach.

What was changed

  • Added support for defining multiple connection options, including SSL configurations, in a structured array format.
  • Introduced secure connection config including Temporal Cloud.
  • Enabled dynamic connection selection based on environment variables.
  • The previous methods address, clientOptions, temporalNamespace still work, but a deprecation warning will be issued.
  • Added ability to configure the default client context.

Previous Configuration:

<?php

return [
   'address' => env('TEMPORAL_ADDRESS', '127.0.0.1:7233'),
];

**New Configuration:

<?php

use Spiral\TemporalBridge\Config\ClientConfig;
use Spiral\TemporalBridge\Config\ConnectionConfig;

return [
    'client' => env('TEMPORAL_CONNECTION', 'default'),
    'clients' => [
        'default' => new ClientConfig(
            connection: new ConnectionConfig('localhost:7233')
        ),
        'secure' => new ClientConfig(
            connection: new ConnectionConfig(
                address: 'localhost:7233',
                tlsConfig: new TlsConfig(
                    privateKey: '/my-project.key',
                    certChain: '/my-project.pem',
                ),
            ),
            options: (new ClientOptions())
                ->withNamespace('default'),
            context: Context::default()
                ->withTimeout(4.5)
                ->withRetryOptions(
                    RpcRetryOptions::new()
                        ->withMaximumAttempts(5)
                        ->withInitialInterval(3)
                        ->withMaximumInterval(10)
                        ->withBackoffCoefficient(1.6)
                ),
            ),
        ),
    ],
];

…pport

This commit significantly overhauls the Temporal connection configuration system. The previous configuration was limited to specifying a single Temporal address with no support for SSL connections. With the new setup, developers can now define multiple connection options, including SSL-enabled connections.

Changes include:
- Introduction of a 'connections' array to specify multiple connection types (e.g., `default`, `SSL`).
- Addition of the `SslConnection` class to handle SSL connection parameters such as certificates and keys.
- Preservation of backward compatibility by supporting the previous `address` configuration under the `default` connection type.
@butschster butschster added the enhancement New feature or request label Mar 22, 2024
@butschster butschster added this to the 3.x milestone Mar 22, 2024
@butschster butschster requested a review from roxblnfk March 22, 2024 06:36
@butschster butschster self-assigned this Mar 22, 2024
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 86.27451% with 7 lines in your changes missing coverage. Please review.

Project coverage is 95.82%. Comparing base (38be446) to head (acd773d).
Report is 14 commits behind head on 3.x.

Files with missing lines Patch % Lines
src/Bootloader/TemporalBridgeBootloader.php 64.70% 6 Missing ⚠️
src/Config/TemporalConfig.php 93.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.x      #83      +/-   ##
============================================
- Coverage     99.14%   95.82%   -3.33%     
- Complexity      103      121      +18     
============================================
  Files            15       18       +3     
  Lines           352      431      +79     
============================================
+ Hits            349      413      +64     
- Misses            3       18      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@butschster butschster linked an issue Mar 22, 2024 that may be closed by this pull request
@butschster butschster requested a review from wolfy-j March 22, 2024 06:43
src/Connection/TemporalCloudConnection.php Outdated Show resolved Hide resolved
src/Connection/SslConnection.php Outdated Show resolved Hide resolved
src/Connection/Connection.php Outdated Show resolved Hide resolved
src/Connection/Connection.php Outdated Show resolved Hide resolved
src/Connection/Connection.php Outdated Show resolved Hide resolved
@roxblnfk
Copy link
Member

See temporalio/sdk-php#410
Consider incorporating a new authentication method - Bearer Token

@roxblnfk
Copy link
Member

See temporalio/sdk-php#418

butschster and others added 3 commits May 20, 2024 11:17
# Conflicts:
#	composer.json
#	src/Bootloader/TemporalBridgeBootloader.php
@roxblnfk roxblnfk force-pushed the feature/ssl-conection-support branch from c97bbc3 to a00adcf Compare August 28, 2024 11:46
@roxblnfk roxblnfk force-pushed the feature/ssl-conection-support branch from acd773d to d94eb74 Compare August 29, 2024 08:05
@roxblnfk roxblnfk merged commit ffa7f4d into 3.x Aug 30, 2024
4 checks passed
@roxblnfk roxblnfk deleted the feature/ssl-conection-support branch August 30, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SSL connection support
2 participants