Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): create Kafka plugin #364

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

orandin
Copy link
Member

@orandin orandin commented Oct 5, 2022

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Feature : add a Kafka plugin to produce messages (see #3)

  • What is the current behavior? (You can also link to an open issue here)

uTask can't publish directly a message to a Kafka topic.

  • What is the new behavior (if this is a feature change)?

Now, uTask can do it. A task can publish a message to a Kafka topic via this plugin.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Nothing.

Template used to test the plugin (click me)

Required: a kafka broker that listens on localhost:9092. How to Install Apache Kafka Using Docker — The Easy Way

name:             kafka
description:      Send message into kafka topic
long_description: Send message into kafka topic

title_format:     Send Kafka message
result_format:
  echo_message: 'ok'

allowed_resolver_usernames:   []
allow_all_resolver_usernames: true
auto_runnable: true
blocked:       false
hidden:        false

steps:
  sendKafka:
    description: Send message into kafka topic
    action:
      type: kafka
      configuration:
        brokers:
          - localhost:9092
        timeout: 20s
        message:
          topic: "utask"
          key: 'test'
          value: |
              {
                "message": "hello world"
              }

Result (click me)

Consumer

$ kaf consume utask
Key:         test
Partition:   0
Offset:      11
Timestamp:   2022-10-05 16:47:07.267 +0200 CEST
{
  "message": "hello world"
}

kaf is a CLI for Apache Kafka: https://github.com/birdayz/kaf

Step output

{
  "name": "sendKafka",
  "description": "Send message into kafka topic",
  "idempotent": false,
  "action": {
    "type": "kafka",
    "configuration": {
      "brokers": [
        "localhost:9092"
      ],
      "message": {
        "key": "test",
        "topic": "utask",
        "value": "{\n  \"message\": \"hello world\"\n}\n"
      }
    },
    "output": null
  },
  "output": {
    "offset": 11,
    "partition": 0
  },
  "state": "DONE",
  "try_count": 1,
  "max_retries": 10000,
  "last_run": "2022-10-05T16:47:07.279139+02:00",
  "foreach_strategy": "",
  "resources": null,
  "tags": null
}

rbeuque74
rbeuque74 previously approved these changes Oct 15, 2022
Copy link
Member

@rbeuque74 rbeuque74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.
Will run the CI on monday

rclsilver
rclsilver previously approved these changes Oct 17, 2022
@orandin
Copy link
Member Author

orandin commented Apr 26, 2023

Update: conflict resolved

pkg/plugins/builtin/kafka/kafka.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
pkg/plugins/builtin/kafka/kafka.go Outdated Show resolved Hide resolved
pkg/plugins/builtin/kafka/kafka.go Outdated Show resolved Hide resolved
pkg/plugins/builtin/kafka/README.md Outdated Show resolved Hide resolved
Signed-off-by: Simon Delberghe <open-source@orandin.fr>
- Update Sarama version
- Check type assertion
- Add tests
- Add documentation (README)

Signed-off-by: Simon Delberghe <open-source@orandin.fr>
@orandin
Copy link
Member Author

orandin commented Jun 11, 2023

Don't merge before squashing commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Action plugin: Kafka producer
4 participants