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
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

# Kafka Schema Registry API Client

## What is it?
## Description
An API Client written in PHP to communicate with Kafka Schema Registry.

## What it can do?
## Installation
```bash
composer require jobcloud/php-kafka-schema-registry-client
```

## Requirements
- php: >= 7.4

## Supported API calls
Currently it supports:

* Get list of subjects
Expand All @@ -24,13 +32,7 @@ Currently it supports:
* Get Subject's latest schema version
* Setting the registry mode

## How to use it?
### Installation
```bash
composer require jobcloud/php-kafka-schema-registry-client
```

### Code example
## Code example

```php
<?php
Expand Down Expand Up @@ -85,7 +87,7 @@ $api = $container['kafka.schema.registry.client.api']);
$data = $api->getSubjects();
```

## External links?
If you want to be so kind to extend this library, make a pull request,
and whatever functionality you want to implement, this is a API reference to follow:
## Contributing
This is an open source project that welcomes pull requests and issues from anyone.
This is the API reference to follow for any new functionality:
https://docs.confluent.io/current/schema-registry/develop/api.html
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"sort-packages": true
},
"require": {
"php": ">7.3",
"php": ">=7.4",
"ext-json": "*",
"pimple/pimple": "^3.2",
"symfony/cache": "^5.0",
Expand All @@ -29,9 +29,9 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4.2",
"phpunit/phpunit": "^8.3.4",
"phpstan/phpstan": "^0.11.8",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^0.12",
"rregeer/phpunit-coverage-check": "^0.3.1",
"infection/infection": "^0.14.2"
"infection/infection": "^0.21"
}
}
1 change: 1 addition & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=php-kafka-schema-registry-client
2 changes: 1 addition & 1 deletion docker/dev/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.3-cli-alpine3.10
FROM php:7.4-cli-alpine3.10

ARG HOST_USER_ID

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameters:
paths:
- src
level: 7
level: 8
72 changes: 28 additions & 44 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php" >
<php>
<ini name="max_execution_time" value="-1"/>
<ini name="html_errors" value="false"/>
<ini name="memory_limit" value="2G"/>

<ini name="xdebug.default_enable" value="1" />
<ini name="xdebug.enable_coverage" value="1" />
<ini name="xdebug.remote_autostart" value="0" />
<ini name="xdebug.remote_enable" value="0" />
<ini name="xdebug.overload_var_dump" value="0" />
<ini name="xdebug.show_mem_delta" value="0" />

<env name="ENVIRONMENT" value="test" />
</php>

<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
<log type="coverage-clover" target="build/logs/phpunit/coverage/coverage.xml"/>
<log type="coverage-html" target="build/logs/phpunit/coverage"/>
<log type="coverage-xml" target="build/logs/phpunit/coverage/coverage-xml"/>
<log type="junit" target="build/logs/phpunit/junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="build/logs/phpunit/coverage/coverage.xml"/>
<html outputDirectory="build/logs/phpunit/coverage"/>
<text outputFile="php://stdout" showOnlySummary="true"/>
<xml outputDirectory="build/logs/phpunit/coverage/coverage-xml"/>
</report>
</coverage>
<php>
<ini name="max_execution_time" value="-1"/>
<ini name="html_errors" value="false"/>
<ini name="memory_limit" value="2G"/>
<env name="error_reporting" value="E_ALL"/>
<env name="display_errors" value="1"/>
<env name="ENVIRONMENT" value="test"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/logs/phpunit/junit.xml"/>
</logging>
</phpunit>
8 changes: 7 additions & 1 deletion src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Jobcloud\Kafka\SchemaRegistryClient;

use Buzz\Exception\ClientException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\BackendDatastoreException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\ImportException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\ClientException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\CompatibilityException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\IncompatibileAvroSchemaException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\InvalidAvroSchemaException;
Expand All @@ -13,12 +13,15 @@
use Jobcloud\Kafka\SchemaRegistryClient\Exception\PathNotFoundException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\RequestForwardException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SchemaNotFoundException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SchemaRegistryExceptionInterface;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SubjectNotFoundException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\UnauthorizedException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\UnprocessableEntityException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\VersionNotFoundException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use JsonException;

class ErrorHandler implements ErrorHandlerInterface
{
Expand All @@ -42,6 +45,9 @@ class ErrorHandler implements ErrorHandlerInterface
* @throws UnprocessableEntityException
* @throws VersionNotFoundException
* @throws ImportException
* @throws JsonException
* @throws ClientExceptionInterface
* @throws SchemaRegistryExceptionInterface
*/
public function handleError(ResponseInterface $response, string $uri = null, RequestInterface $request = null): void
{
Expand Down
6 changes: 6 additions & 0 deletions src/ErrorHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

namespace Jobcloud\Kafka\SchemaRegistryClient;

use Jobcloud\Kafka\SchemaRegistryClient\Exception\SchemaRegistryExceptionInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use JsonException;

interface ErrorHandlerInterface
{
/**
* @param ResponseInterface $response
* @param string|null $uri
* @throws ClientExceptionInterface
* @throws SchemaRegistryExceptionInterface
* @throws JsonException
*/
public function handleError(
ResponseInterface $response,
Expand Down
10 changes: 10 additions & 0 deletions src/Exception/AbstractKafkaSchemaRegistryException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

abstract class AbstractKafkaSchemaRegistryException extends Exception implements SchemaRegistryExceptionInterface
{

}
4 changes: 1 addition & 3 deletions src/Exception/BackendDatastoreException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class BackendDatastoreException extends Exception
class BackendDatastoreException extends AbstractKafkaSchemaRegistryException
{

}
10 changes: 0 additions & 10 deletions src/Exception/ClientException.php

This file was deleted.

4 changes: 1 addition & 3 deletions src/Exception/CompatibilityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class CompatibilityException extends Exception
class CompatibilityException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/ImportException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class ImportException extends Exception
class ImportException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/IncompatibileAvroSchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class IncompatibileAvroSchemaException extends Exception
class IncompatibileAvroSchemaException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/InvalidAvroSchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class InvalidAvroSchemaException extends Exception
class InvalidAvroSchemaException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/InvalidVersionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class InvalidVersionException extends Exception
class InvalidVersionException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/OperationTimeoutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class OperationTimeoutException extends Exception
class OperationTimeoutException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/PathNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class PathNotFoundException extends Exception
class PathNotFoundException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/RequestForwardException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class RequestForwardException extends Exception
class RequestForwardException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/SchemaNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class SchemaNotFoundException extends Exception
class SchemaNotFoundException extends AbstractKafkaSchemaRegistryException
{

}
10 changes: 10 additions & 0 deletions src/Exception/SchemaRegistryExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Psr\Http\Client\ClientExceptionInterface;

interface SchemaRegistryExceptionInterface extends ClientExceptionInterface
{

}
4 changes: 1 addition & 3 deletions src/Exception/SubjectNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class SubjectNotFoundException extends Exception
class SubjectNotFoundException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/UnauthorizedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class UnauthorizedException extends Exception
class UnauthorizedException extends AbstractKafkaSchemaRegistryException
{

}
4 changes: 1 addition & 3 deletions src/Exception/UnprocessableEntityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Jobcloud\Kafka\SchemaRegistryClient\Exception;

use Exception;

class UnprocessableEntityException extends Exception
class UnprocessableEntityException extends AbstractKafkaSchemaRegistryException
{

}
Loading