Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
armin nasiri committed Oct 13, 2020
1 parent 575c21a commit 9a611db
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 [email protected] instead of using the issue tracker.
Expand Down
35 changes: 35 additions & 0 deletions config/logUsage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* Config log usage map-ir
*/
return [
"topic" => 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")
];
9 changes: 2 additions & 7 deletions src/LaravelLogUsageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand All @@ -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;
});
}
}

0 comments on commit 9a611db

Please sign in to comment.