README.md in karafka-sidekiq-backend-1.2.0.beta2 vs README.md in karafka-sidekiq-backend-1.2.0.beta3
- old
+ new
@@ -83,41 +83,18 @@
Note that even then, you need to specify a controller that will schedule a background task.
Custom workers need to provide a ```#perform_async``` method. It needs to accept two arguments:
- ```topic_id``` - first argument is a current topic id from which a given message comes
- - ```params``` - all the params that came from Kafka + additional metadata. This data format might be changed if you use custom interchangers. Otherwise it will be an instance of Karafka::Params::Params.
+ - ```params_batch``` - all the params that came from Kafka + additional metadata. This data format might be changed if you use custom interchangers. Otherwise it will be an instance of Karafka::Params::ParamsBatch.
-Keep in mind, that params might be in two states: parsed or unparsed when passed to #perform_async. This means, that if you use custom interchangers and/or custom workers, you might want to look into Karafka's sources to see exactly how it works.
+**Note**: If you use custom interchangers, keep in mind, that params inside params batch might be in two states: parsed or unparsed when passed to #perform_async. This means, that if you use custom interchangers and/or custom workers, you might want to look into Karafka's sources to see exactly how it works.
### Interchangers
Custom interchangers target issues with non-standard (binary, etc.) data that we want to store when we do ```#perform_async```. This data might be corrupted when fetched in a worker (see [this](https://github.com/karafka/karafka/issues/30) issue). With custom interchangers, you can encode/compress data before it is being passed to scheduling and decode/decompress it when it gets into the worker.
**Warning**: if you decide to use slow interchangers, they might significantly slow down Karafka.
-
-```ruby
-class Base64Interchanger
- class << self
- def load(params_batch)
- params_batch.map do |params|
- Base64.encode64(Marshal.dump(params))
- end
- end
-
- def parse(params_batch)
- params_batch.map do |params|
- Marshal.load(Base64.decode64(params))
- end
- end
- end
-end
-
-topic :binary_video_details do
- controller Videos::DetailsController
- interchanger Base64Interchanger
-end
-```
## References
* [Karafka framework](https://github.com/karafka/karafka)
* [Karafka Sidekiq Backend Travis CI](https://travis-ci.org/karafka/karafka-sidekiq-backend)