php ksql
changed namespace
Apache kafka / 适用于 php 的 Confluence KSQL REST 客户端
KSQL 是 Apache Kafka 的流式 SQL 引擎。
什么是 KSQL?
需要 >= PHP 7.1
$ composer require ytake/php-ksql
班级 |
---|
YtakeKsqlClientQueryCommandStatus |
YtakeKsqlClient查询状态 |
YtakeKsqlClientQueryServerInfo |
YtakeKsqlClientQueryKsql |
YtakeKsqlClientQueryStream(对于流) |
语法参考
<?php
use Ytake KsqlClient RestClient ;
use Ytake KsqlClient Query CommandStatus ;
use Ytake KsqlClient Computation CommandId ;
$ client = new RestClient (
" http://localhost:8088 "
);
$ result = $ client -> requestQuery (
new CommandStatus (CommandId:: fromString ( ' stream/MESSAGE_STREAM/create ' ))
)-> result ();
<?php
use Ytake KsqlClient RestClient ;
use Ytake KsqlClient Query Status ;
$ client = new RestClient (
" http://localhost:8088 "
);
$ result = $ client -> requestQuery ( new Status ())-> result ();
<?php
use Ytake KsqlClient RestClient ;
use Ytake KsqlClient Query ServerInfo ;
$ client = new RestClient (
" http://localhost:8088 "
);
$ result = $ client -> requestQuery ( new ServerInfo ())-> result ();
<?php
use Ytake KsqlClient RestClient ;
use Ytake KsqlClient Query Ksql ;
$ client = new RestClient (
" http://localhost:8088 "
);
$ result = $ client -> requestQuery (
new Ksql ( ' DESCRIBE users_original; ' )
)-> result ();
<?php
use Ytake KsqlClient StreamClient ;
use Ytake KsqlClient Query Stream ;
use Ytake KsqlClient StreamConsumable ;
use Ytake KsqlClient Entity StreamedRow ;
$ client = new StreamClient (
" http://localhost:8088 "
);
$ result = $ client -> requestQuery (
new Stream (
' SELECT * FROM testing ' ,
new class () implements StreamConsumable {
public function __invoke ( StreamedRow $ row )
{
// stream response consumer
}
}
)
)-> result ();