From 9a611db9db3b5b29c1a51e8ab5ad033c6fdfa342 Mon Sep 17 00:00:00 2001 From: armin nasiri Date: Tue, 13 Oct 2020 16:03:56 +0330 Subject: [PATCH] fix bug --- README.md | 23 ++++++----------- config/logUsage.php | 35 ++++++++++++++++++++++++++ src/LaravelLogUsageServiceProvider.php | 9 ++----- 3 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 config/logUsage.php diff --git a/README.md b/README.md index ea2f3f7..e415dbc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Map.ir log usage kafka and ELK [![Latest Version on Packagist](https://img.shields.io/packagist/v/map-ir/laravel-log-usage.svg?style=flat-square)](https://packagist.org/packages/map-ir/laravel-log-usage) -[![Build Status](https://img.shields.io/travis/map-ir/laravel-log-usage/master.svg?style=flat-square)](https://travis-ci.org/map-ir/laravel-log-usage) -[![Quality Score](https://img.shields.io/scrutinizer/g/map-ir/laravel-log-usage.svg?style=flat-square)](https://scrutinizer-ci.com/g/map-ir/laravel-log-usage) [![Total Downloads](https://img.shields.io/packagist/dt/map-ir/laravel-log-usage.svg?style=flat-square)](https://packagist.org/packages/map-ir/laravel-log-usage) #### kafka @@ -27,14 +25,16 @@ php artisan vendor:publish --tag=config ``` After publish the package files you must open laravel-log-usage.php in config folder. ##lumen Installation: -add package service provider in bootstrap/app.php. +add package middleware in bootstrap/app.php. ``` php -$app->register(MapIr\LaravelLogUsage\LaravelLogUsageServiceProvider::class); + $app->middleware([ + \MapIr\LaravelLogUsage\Http\Middleware\LogUsageMiddleware::class + ]); ``` -copy package config directory `vendor/map-ir/laravel-log-usage/config` to root folder alongside with app directory. +copy package config directory `vendor/map-ir/laravel-log-usage/config/logUsage.php` to root folder alongside with app directory. update bootstrap/app.php by adding this line in `Register Config Files` section: ``` php -$app->configure('laravel-log-usage'); +$app->configure('logUsage'); ``` > you can set the keys in your .env file ``` dotenv @@ -43,7 +43,7 @@ BROKER_VERSION="version use broker" KAFKA_MRIM="Topic metadata refresh interval in milliseconds broker" REQUIRED_ACK="This field indicates how many acknowledgements the leader broker" IS_ASYNC="Whether to use asynchronous production messages" -KAFKA_KEY="key for kafka producer" +KAFKA_KEY="key for kafka producer index" ``` ## Usage for config ELK Consumer kafka @@ -52,15 +52,6 @@ KAFKA_KEY="key for kafka producer" ``` bash composer test ``` - -### Changelog - -Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. - -## Contributing - -Please see [CONTRIBUTING](CONTRIBUTING.md) for details. - ### Security If you discover any security related issues, please email a.nasiri@map.ir instead of using the issue tracker. diff --git a/config/logUsage.php b/config/logUsage.php new file mode 100644 index 0000000..16db4df --- /dev/null +++ b/config/logUsage.php @@ -0,0 +1,35 @@ + env("TOPIC","log-usage-undefined"), + + //Kafka Broker server list + "kafka_server" => env("KAFKA_HOST","localhost:9202"), + + //User supplied broker version + "broker_version" => env("BROKER_VERSION","1.0.0"), + + /** + * Topic metadata refresh interval in milliseconds. + * The metadata is automatically refreshed on error and connect. + * Use -1 to disable the intervened refresh + */ + "metadata_refresh_interval_ms" => env("KAFKA_MRIM",10000), + + /** + *This field indicates how many acknowledgements the leader broker must receive from ISR brokers before responding to the request: + * 0=Broker does not send any response/ack to client, + * 1=Only the leader broker will need to ack the message, + * -1 or all=broker will block until message is committed by all in sync replicas (ISRs) + * or broker's in.sync.replicas setting before sending response. + */ + "required_ack" => env("REQUIRED_ACK",1), + + //Whether to use asynchronous production messages + "is_async" => env("IS_ASYNC",false), + // key for kafka producer + "key" => env("KAFKA_KEY","Map-ir") +]; diff --git a/src/LaravelLogUsageServiceProvider.php b/src/LaravelLogUsageServiceProvider.php index 52d03b4..fdddb51 100644 --- a/src/LaravelLogUsageServiceProvider.php +++ b/src/LaravelLogUsageServiceProvider.php @@ -15,7 +15,7 @@ public function boot() { if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__.'/../config/config.php' => config_path('laravel-log-usage.php'), + __DIR__.'/../config/config.php' => config_path('logUsage.php'), ], 'config'); } } @@ -26,14 +26,9 @@ public function boot() public function register() { // Automatically apply the package configuration - $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-log-usage'); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'logUsage'); // Add middleware $kernel =$this->app->make(Kernel::class); - $kernel->pushMiddleware(LogUsageMiddleware::class); - // Register the main class to use with the facade - $this->app->singleton('laravel-log-usage', function () { - return new LaravelLogUsage; - }); } }