Skip to content

Commit 5ce5712

Browse files
committed
more docs
1 parent 8b7685c commit 5ce5712

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

Configuration.md

+62-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Karafka contains multiple configuration options. To keep everything organized, all the configuration options were divided into two groups:
22

3-
* `karafka` options - options directly related to the Karafka framework and its components.
3+
* root `karafka` options - options directly related to the Karafka framework and its components.
44

5-
* `librdkafka` options - options related to [librdkafka](https://karafka.io/docs/Librdkafka-Configuration)
5+
* kafka scoped `librdkafka` options - options related to [librdkafka](https://karafka.io/docs/Librdkafka-Configuration)
66

77
To apply all those configuration options, you need to use the ```#setup``` method from the `Karafka::App` class:
88

@@ -91,3 +91,63 @@ end
9191
```bash
9292
apt-get install -y libzstd-dev
9393
```
94+
95+
## Types of Configuration in Karafka
96+
97+
When working with Karafka, it is crucial to understand the different configurations available, as these settings directly influence how Karafka interacts with your application code and the underlying Kafka infrastructure.
98+
99+
### Root Configuration in the Setup Block
100+
101+
The root configuration within the `setup` block of Karafka pertains directly to the Karafka framework and its components. This includes settings that influence the behavior of your Karafka application at a fundamental level, such as client identification, logging preferences, and consumer groups details.
102+
103+
Example of root configuration:
104+
105+
```ruby
106+
class KarafkaApp < Karafka::App
107+
setup do |config|
108+
config.client_id = 'my_application'
109+
config.initial_offset = 'latest'
110+
end
111+
end
112+
```
113+
114+
### Kafka Scoped `librdkafka` Options
115+
116+
librdkafka configuration options are specified within the same setup block but scoped specifically under the `kafka` key. These settings are passed directly to the librdkafka library, the underlying Kafka client library that Karafka uses. This includes configurations for Kafka connections, such as bootstrap servers, SSL settings, and timeouts.
117+
118+
Example of `librdkafka` scoped options:
119+
120+
```ruby
121+
class KarafkaApp < Karafka::App
122+
setup do |config|
123+
config.kafka = {
124+
'bootstrap.servers': '127.0.0.1:9092',
125+
'ssl.ca.location': '/etc/ssl/certs'
126+
}
127+
end
128+
end
129+
```
130+
131+
### Admin Configs API
132+
133+
Karafka also supports the Admin Configs API, which is designed to view and manage configurations at the Kafka broker and topic levels. These settings are different from the client configurations (root and Kafka scoped) as they pertain to the infrastructure level of Kafka itself rather than how your application interacts with it.
134+
135+
Examples of these settings include:
136+
137+
- **Broker Configurations**: Like log file sizes, message sizes, and default retention policies.
138+
139+
- **Topic Configurations**: Such as partition counts, replication factors, and topic-level overrides for retention.
140+
141+
To put it in perspective, these configurations can be likened to those in a database. Just as a database has client, database, and table configurations, Kafka has its own set of configurations at different levels.
142+
143+
- **Client Configurations**: Similar to client-specific settings in SQL databases, such as query timeouts or statement timeouts.
144+
145+
- **Database Configurations**: Analogous to database-level settings such as database encoding, connection limits, or default transaction isolation levels.
146+
147+
- **Table Configurations**: Similar to table-specific settings like storage engine choices or per-table cache settings in a database.
148+
149+
These infrastructural settings are crucial for managing Kafka more efficiently. They ensure that the Kafka cluster is optimized for both performance and durability according to the needs of the applications it supports.
150+
151+
!!! Hint "Managing Topics Configuration with Declarative Topics API"
152+
153+
If you want to manage topic configurations more effectively, we recommend using Karafka's higher-level API, Declarative Topics. This API simplifies defining and managing your Kafka topics, allowing for clear and concise topic configurations within your application code. For detailed usage and examples, refer to our comprehensive guide on [Declarative Topics](https://karafka.io/docs/Librdkafka-Configuration/).

0 commit comments

Comments
 (0)