Commit 7c7d634e authored by hangjun83's avatar hangjun83

openapi

parent 5b8f23d2
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Providers;
use App\Services\Kafka\KafkaService;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
use longlang\phpkafka\Broker;
use longlang\phpkafka\Consumer\ConsumerConfig;
use longlang\phpkafka\Protocol\Metadata\MetadataRequest;
class KafkaServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if( $this->app instanceof LumenApplication ){
$this->app->configure('kafka');
}
$brokerClientId = env('KAFKA_HOST').":".env('KAFKA_PORT');
$kafkaConfig = new ConsumerConfig();
$kafkaBroker = (new Broker($kafkaConfig));
$kafkaBroker->setBrokers([$brokerClientId]);
try{
$client = $kafkaBroker->getClient();
if($client){
$request = new MetadataRequest();
$request->setTopics(['test2']);
$request->setAllowAutoTopicCreation(true);
$response = $client->sendRecv($request);
var_dump($response->getTopics());
exit;
}
}catch(\Exception $exception){
var_dump($exception->getMessage());
exit;
}
}
}
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
NODE_VERSION: '10'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
- redis
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sail-redis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
sail-redis:
driver: local
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/bin/bash
# Latest-lumen 更新脚本
# @author Carlos <anzhengchao@gmail.com>
# @link http://github.com/overtrue
# latest-lumen
SCRIPT_DIR=/root/latest-lumen/scripts
ROOT_DIR=${SCRIPT_DIR}/../
#filename
MASTER_FILE="lumen-master.tar.gz"
DEVELOP_FILE="lumen-develop.tar.gz"
# 更新并安装
latest_and_install()
{
cd $ROOT_DIR/
if [[ -d "lumen" ]]; then
rm -rf lumen
fi
echo ""
echo "*** 切换分支:$1 ***"
echo "branch:$1"
git clone https://github.com/laravel/lumen --depth=1
cd lumen && git checkout $1 && composer install
return 0
}
# 清理git仓库
clean_repo()
{
cd $ROOT_DIR
echo "*** 清理文件 ***"
git pull && \
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.tar.gz' --prune-empty --tag-name-filter cat -- --all && \
git push origin --force --all && \
git push origin --force --tags && \
rm -rf .git/refs/original/ && \
git reflog expire --expire=now --all && \
git gc --prune=now
return 0
}
# 打包
make_zip()
{
latest_and_install $1
if [[ $? -eq 0 ]]; then
echo "*** 开始打包:$2 ***"
cd $ROOT_DIR && \
rm -f $2 && \
tar -zcf $2 $(find lumen/ -type f)
cd ../ && rm -rf lumen
echo "*** 打包完毕:$2 ***"
fi
}
# 提交到latest-lumen
commit_zip()
{
cd $ROOT_DIR
echo "当前目录:`pwd`"
git add *.gz && \
git commit -am "update@$(date +%Y-%m-%d_%H%M%S)" && \
git pull && \
git push
}
# 检查错误并提交
check_and_commit()
{
if [[ $? != 0 ]]; then
echo "*** 错误:$? ***"
exit
else
commit_zip
fi
}
# 报告错误(issue)
report_error()
{
cd $SCRIPT_DIR
`node reporter.js` && rm -rf output
}
clean_repo
composer selfupdate
# master
master_output=$(make_zip "master" $MASTER_FILE)
echo $master_output
if [[ $? != 0 || "stat -c %s lumen-master.tar.gz" < 3000000 ]]; then
echo "$master_output" 2>&1 | tee $SCRIPT_DIR/output
fi
# develop
develop_output=$(make_zip "develop" $DEVELOP_FILE)
echo develop_output
if [[ $? != 0 || "stat -c %s lumen-develop.tar.gz" < 3000000 ]]; then
echo "$develop_output" 2>&1 | tee $SCRIPT_DIR/output
fi
check_and_commit
if [[ -f "$SCRIPT_DIR/output" ]]; then
report_error
echo "*** 上报错误完成! ***"
rm -rf $SCRIPT_DIR/output
fi
date
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment