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
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Auto detect text files and perform LF normalization
* text=auto

/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.travis.sh export-ignore
/composer.lock export-ignore
/tests/ export-ignore
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"require": {
"php": "^7.1",
"ext-curl": "*",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.3.3",
"fig/http-message-util": "^1.1"
},
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Confluent KSQL Client Test Suite">
Expand Down
42 changes: 42 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);

/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace Istyle\KsqlClient;

use Istyle\KsqlClient\Query\QueryInterface;
use Istyle\KsqlClient\Mapper\ResultInterface;

/**
* Interface ClientInterface
*/
interface ClientInterface
{
const REQUEST_ACCEPT = 'application/vnd.ksql.v1+json';

/**
* @param QueryInterface $query
* @param int $timeout
* @param bool $debug
*
* @return ResultInterface
*/
public function requestQuery(
QueryInterface $query,
int $timeout = 500000,
bool $debug = false
): ResultInterface;
}
2 changes: 1 addition & 1 deletion src/Entity/CommandStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Class CommandStatus
*/
class CommandStatus implements EntityInterface
final class CommandStatus implements EntityInterface
{
/** @var string */
protected $message;
Expand Down
45 changes: 45 additions & 0 deletions src/Entity/EntityQueryId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);

/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace Istyle\KsqlClient\Entity;

use Istyle\KsqlClient\Query\QueryId;

/**
* Class EntityQueryId
*/
final class EntityQueryId
{
/** @var QueryId */
private $id;

/**
* @param QueryId $id
*/
public function __construct(QueryId $id)
{
$this->id = $id->getId();
}

/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
}
71 changes: 71 additions & 0 deletions src/Entity/FieldInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);

/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace Istyle\KsqlClient\Entity;

use function sprintf;
use function spl_object_hash;

/**
* Class FieldInfo
*/
final class FieldInfo implements EntityInterface
{
/** @var string */
private $name;

/** @var SchemaInfo|null */
private $schemaInfo;

/**
* @param string $name
* @param SchemaInfo|null $schemaInfo
*/
public function __construct(string $name, ?SchemaInfo $schemaInfo)
{
$this->name = $name;
$this->schemaInfo = $schemaInfo;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @return SchemaInfo|null
*/
public function getSchema(): ?SchemaInfo
{
return $this->schemaInfo;
}

/**
* @return string
*/
public function __toString(): string
{
return sprintf(
"FieldInfo{name='%s',schema=%s}",
$this->name,
!is_null($this->schemaInfo) ? spl_object_hash($this->schemaInfo) : ''
);
}
}
20 changes: 10 additions & 10 deletions src/Entity/KafkaTopicInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KafkaTopicInfo implements EntityInterface
/** @var string */
private $registered;

/** @var array */
/** @var array<int> */
private $replicaInfo;

/** @var int */
Expand All @@ -38,15 +38,15 @@ class KafkaTopicInfo implements EntityInterface
private $consumerGroupCount;

/**
* @param string $name
* @param string $registered
* @param array $replicaInfo
* @param int $consumerCount
* @param int $consumerGroupCount
* @param string $name
* @param bool $registered
* @param array<int> $replicaInfo
* @param int $consumerCount
* @param int $consumerGroupCount
*/
public function __construct(
string $name,
string $registered,
bool $registered,
array $replicaInfo,
int $consumerCount,
int $consumerGroupCount
Expand All @@ -67,15 +67,15 @@ public function getName(): string
}

/**
* @return string
* @return bool
*/
public function getRegistered(): string
public function getRegistered(): bool
{
return $this->registered;
}

/**
* @return array
* @return array<int>
*/
public function getReplicaInfo(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/KafkaTopics.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Class KafkaTopics
*/
class KafkaTopics extends AbstractKsql
class KafkaTopics extends KsqlEntity
{
/** @var array */
private $kafkaTopicInfoList;
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/KsqlCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
*/
class KsqlCollection implements EntityInterface
{
/** @var AbstractKsql[] */
/** @var EntityInterface[] */
protected $ksql = [];

/**
* @param AbstractKsql $ksql
* @param EntityInterface $ksql
*/
public function addKsql(AbstractKsql $ksql): void
public function addKsql(EntityInterface $ksql): void
{
$this->ksql[] = $ksql;
}

/**
* @return AbstractKsql[]
* @return EntityInterface[]
*/
public function getKsql(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/AbstractKsql.php → src/Entity/KsqlEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
namespace Istyle\KsqlClient\Entity;

/**
* Class AbstractKsql
* Class KsqlEntity
*/
abstract class AbstractKsql
abstract class KsqlEntity implements EntityInterface
{
/** @var string */
protected $statementText;
private $statementText;

/**
* @param string $statementText
Expand Down
34 changes: 30 additions & 4 deletions src/Entity/KsqlErrorMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,33 @@

namespace Istyle\KsqlClient\Entity;

use function sprintf;

/**
* Class KsqlErrorMessage
*/
class KsqlErrorMessage implements EntityInterface
class KsqlErrorMessage extends KsqlEntity
{
/** @var int */
protected $errorCode;

/** @var string */
protected $message;

/** @var array */
protected $stackTrace;

/**
* @param int $errorCode
* @param string $message
* @param array $stackTrace
*/
public function __construct(string $message, array $stackTrace)
{
public function __construct(
int $errorCode,
string $message,
array $stackTrace = []
) {
$this->errorCode = $errorCode;
$this->message = $message;
$this->stackTrace = $stackTrace;
}
Expand All @@ -45,12 +55,28 @@ public function getMessage(): string
{
return $this->message;
}

/**
* @return array
*/
public function getStackTrace(): array
{
return $this->stackTrace;
}

/**
* @return int
*/
public function getErrorCode(): int
{
return $this->errorCode;
}

/**
* @return string
*/
public function __toString(): string
{
return sprintf("%s\n%s", $this->getMessage(), implode("\n", $this->getStackTrace()));
}
}
Loading