Skip to main content

flasfka

Build Status Coverage

Push/Pull on Kafka over HTTP

Installation

You can install kafka with pip:

pip install kafka

Alternatively, you can build and use the debian package.

Configuration

To set up flasfka to talk to the Kafka cluster, the following variables are available. Put this in a file (for example /etc/flasfka.conf.py):

# Hosts in the kafka cluster (list of ip:port)
HOSTS=["localhost:9092"]

# You probably don't need to change these

# How long to wait when polling a topic for new messages
CONSUMER_TIMEOUT=0.1

# Maximum of messages returned when consuming from a topic
CONSUMER_LIMIT=100

# When you don't specify a group for listening to a topic, flasfka
# will use this one
DEFAULT_GROUP="flasfka"

The file will be read at flasfka startup, provided it is in the environment variable FLASFKA_CONFIG:

export FLASFKA_CONFIG=/etc/flasfka.conf.py

Running flasfka is then just a matter of launching:

flasfka-serve

By default, it runs on the port 5000. Use flasfka-serve -h to learn how to change that. The debian package wraps flasfka into a uwsgi service, so you don’t need to worry about this if you are using it.

Usage

Now, assuming flasfka is configured and running:

send

curl -X POST --data-binary '{"messages": ["msg1", "msg2"]}' "http://127.0.0.1:5000/my-topic/"

This pushes msg1 then msg2 to the topic my-topic.

curl -X POST --data-binary '{"messages": ["msg3"]}' "http://127.0.0.1:5000/my-topic/my-key/"

This pushes msg3 to the topic my-topic with the key my-key.

fetch

curl http://127.0.0.1:5000/my-topic/

This retrieves a maximum of 100 of the last messages posted to my-topic, from the default group flasfka.

curl http://127.0.0.1:5000/my-topic/my-group/

This retrieves a maximum of 100 of the last messages posted to my-topic, from the group my-group.

curl http://127.0.0.1:5000/my-topic/?limit=20

This retrieves a maximum of 20 of the last messages posted to my-topic, from the default group flasfka.

Limitations

Flafska only accepts json data, so your messages need to be in utf-8. If you want to pass arbitrary data, it is recommended to encode them to a suitable format before (e.g. base64).

Metadata

Release files for flasfka 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flasfka 1.1.6
File Size Uploaded Provenance Actions
flasfka-1.1.6.tar.gz 5.2 kB Without provenance Details for flasfka-1.1.6.tar.gz

Release files / flasfka-1.1.6.tar.gz

Download URL flasfka-1.1.6.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
01a407ee764f37da633611ac883e6f7cfd1a69026c382f89a07ffcdd8cbb58e3
BLAKE2b-256 checksum
How to use checksums
3176fcd549523c0d1bb601bec457e07b8f9accd91c6e62540ee141372b4c56e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for flasfka 1.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page