Giter Site home page Giter Site logo

django-logpipe's People

Contributors

crgwbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-logpipe's Issues

Always getting "Apps aren't loaded yet" error

Hi,

I think I did everything according to the readme, but everytime I try to execute python manage.py run_kafka_consumer, I get the django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Error.

This is my apps.py file:

from django.apps import AppConfig
from logpipe import Consumer, register_consumer

from lptest.serializers import MissionSerializer


class LptestConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "lptest"


@register_consumer
def build_person_consumer():
    consumer = Consumer('missions')
    consumer.register(MissionSerializer)
    return consumer

this is my serializer:

class MissionSerializer(serializers.ModelSerializer):
    MESSAGE_TYPE = 'mission'
    VERSION = 1
    KEY_FIELD = 'name'

    class Meta:
        model = Mission
        fields = "__all__"

    @classmethod
    def lookup_instance(cls, name, **kwargs):
        try:
            return Mission.objects.get(name=name)
        except Mission.DoesNotExist:
            pass

I'm not really sure what I'm missing here. The app is listed in the INSTALLED_APPS as well.

Thank you in advance!

Infinite loop in case of ProvisionedThroughputExceededException from Kinesis

Hi, thanks for your amazing package!

We use it as a consumer for Kinesis.
We use the suggested configuration with multiconsumer:

multi = MultiConsumer(people_consumer, places_consumer)
multi.run()

At some point, our Kinesis service raises a ProvisionedThroughputExceededException, multiple times a row, and it ends up with the _get_records method of the kinesis based consumer returning None.

This further leads to a StopIteration but coupled with the indefinite consumer, it ends up in an infinite loop.

For the moment we overrode the _get_records to generate a specific exception and crash for good, but there must be a cleaner solution to avoid entering this infinite loop.

Thank you very much for your advice!

How do i handle errors?

After implementing logpipe on Django, everything worked perfectly, but it happened that a message arrived with all fields empty, this caused Kafka to freeze, which remained on that message and did not let the others pass. I have implemented error handling like this, but I would like to know how I could handle the error by sending messages containing errors to another queue.

    if type == 'add':
        if topic:
            try:
                topic = f"{topic}_posts"
                producer = Producer(topic, serializers.PostCreateKafkaSerializer)
                producer.send(data)
                logger.info("Try to Send to Kafka")
            except Exception as e:
                resp = requests.post(url, headers = {"Content-Type": "application/json", "Authorization": f"Token {token}"}, data=json.dumps(data))
                print(e)
                try:
                    resp.json()
                    logger.warning("Fallback send with POST, Kafka Problems!")
                except Exception:
                    traceback.print_exc()
                    raise NotExpectedException("Error Post")
        else:
            try:
                resp = requests.post(url, headers = {"Content-Type": "application/json", "Authorization": f"Token {token}"}, data=json.dumps(data))
                resp.json()
                logger.warning("No topic send by Post")
            except Exception as error:
                traceback.print_exc()
                logger.error("Error Post")
                raise NotExpectedException("Error Post")

Basically I do a fallback with a post in case I am unable to send it via Kafka, connection problems or Kafka down, what I would like to avoid is Kafka blocking when I send a message that is not in order. Not if it is possible to manage it directly from logpipe.

Add support for localstack?

We use localstack to test our integration w/ AWS infra locally, are you interested in adding a test_mode so that users can specify the local url for kinesis/kafka in test_mode?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.