Skip to content

Commit

Permalink
Update docs on setting global settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges committed Jan 22, 2024
1 parent ca8abf2 commit f87bbd3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/advanced-usage/8-setting-global-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Setting global configurations
weight: 8
---

At this moment, there is no way of setting global configuration for producers/consumers, but you can use laravel `macro` functionality
to achieve that. Here's an example:


```php
// In a service provider:

\Junges\Kafka\Facades\Kafka::macro('myProducer', function () {
return $this->publishOn('my-awesome-topic')
->withConfigOption('key', 'value');
});
```

Now, you can call `\Junges\Kafka\Facades\Kafka::myProducer()`, which will always apply the configs you defined in your service provider.

0 comments on commit f87bbd3

Please sign in to comment.