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

feat: Use custom HTTP Client, custom Logger, PHPStan #13

Merged
merged 24 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e57099f
feat: Allow custom HTTP client and PSR-logger
tyiuhc Dec 21, 2023
0faa2e7
remove murmur3 hash dependency
tyiuhc Dec 21, 2023
4a187eb
update test.yml with additional PHP versions
tyiuhc Dec 21, 2023
dca6c02
Update to use PHPStan
tyiuhc Dec 28, 2023
6d5149d
Update comments and README
tyiuhc Dec 29, 2023
ffad979
nit: improve description
tyiuhc Dec 29, 2023
1e5d2ce
update return type of build() in amplitude and assignment config
tyiuhc Dec 30, 2023
ba3ca2b
fix assignment tracking
tyiuhc Dec 30, 2023
c888204
fix unit test utils
tyiuhc Dec 30, 2023
4d5ab89
improve FetchClientInterface comments
tyiuhc Dec 30, 2023
3e6117a
nit: code style
tyiuhc Dec 31, 2023
b6bfd50
fix: GuzzleFetchClient delay function
tyiuhc Jan 8, 2024
a0d7a11
docs: update descriptions
tyiuhc Jan 8, 2024
af5d592
nit: remove echo
tyiuhc Jan 9, 2024
b416164
refactor: custom HTTP client params naming
tyiuhc Jan 9, 2024
939c1ec
refactor: rename fetchClient vars to httpClient
tyiuhc Jan 9, 2024
ac58d23
refactor: update log levels
tyiuhc Jan 9, 2024
942bccf
refactor: update log level default
tyiuhc Jan 9, 2024
24dd6bf
docs: improve HttpClientInterface descriptions
tyiuhc Jan 11, 2024
48815ef
refactor: update log level name
tyiuhc Jan 16, 2024
cb35c52
refactor: remove unneeded import
tyiuhc Jan 16, 2024
48f682a
Allow all versions of PSR log
tyiuhc Jan 23, 2024
505c633
update LocalEvaluationClient - add getFlagConfigs method, change meth…
tyiuhc Jan 24, 2024
5aa4295
fix: update hashCode util function to use explicit int cast
tyiuhc Jan 24, 2024
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
37 changes: 21 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,43 @@ name: Test
on:
pull_request:
push:
branches: [ "main" ]

permissions:
contents: read
branches:
- main

jobs:
build:

runs-on: ubuntu-latest
test:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Checkout
uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test

- name: Run PHPStan
run: vendor/bin/phpstan analyse --ansi
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $user = \AmplitudeExperiment\User::builder()
->userProperties(['premium' => True])
->build();

$variants = $client->fetch($user)->wait();
$variants = $client->fetch($user);

// (3) Access a flag's variant
$variant = $variants['FLAG_KEY'] ?? null;
Expand All @@ -48,8 +48,8 @@ if ($variant) {
$experiment = new \AmplitudeExperiment\Experiment();
$client = $experiment->initializeLocal('<DEPLOYMENT_KEY>');

// (2) Start the local evaluation client.
$client->start()->wait();
// (2) Fetch latest flag configurations for the local evaluation client.
$client->refreshFlagConfigs();

// (3) Evaluate a user.
$user = \AmplitudeExperiment\User::builder()
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8",
"lastguest/murmurhash": "^1",
"ext-json": "*",
"guzzlehttp/guzzle": "^7",
"monolog/monolog": "^2"
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"phpunit/phpunit": "9.*"
"phpunit/phpunit": "9.*",
"phpstan/phpstan": "^1"
},
"suggest": {
"monolog/monolog": "Allows more advanced logging of the application flow"
},
"autoload": {
"psr-4": {
Expand Down
Loading
Loading