Giter Site home page Giter Site logo

Comments (6)

rnowling-memphis avatar rnowling-memphis commented on May 30, 2024

@Adarsh-jaiss are you interested in this?

from memphis.py.

Adarsh-jaiss avatar Adarsh-jaiss commented on May 30, 2024
  • yeah I would love to work on this!
  • could you please explain me a bit about the issue?

from memphis.py.

rnowling-memphis avatar rnowling-memphis commented on May 30, 2024

Please compare the docstrings (function documentation) for the two functions I put links to. One of them has a nice example of how to call the function, while the other does not :)

from memphis.py.

Adarsh-jaiss avatar Adarsh-jaiss commented on May 30, 2024

Will it work, kindly review this :

def consume(self, callback):
    """
    Consume events.

    This method starts consuming events from the specified station and invokes the provided callback function for each batch of messages received.

    Parameters:
        callback (function): A function that will be called with each batch of messages received. The function should have the following signature:
            - `callback(messages: List[Message], error: Optional[MemphisError], context: Dict) -> Awaitable[None]`
            - `messages`: A list of `Message` objects representing the batch of messages received.
            - `error`: An optional `MemphisError` object if there was an error while consuming the messages.
            - `context`: A dictionary representing the context that was set using the `set_context()` method.

    Example:
        import asyncio
        from memphis import Memphis

        async def message_handler(messages, error, context):
            if error:
                print(f"Error occurred: {error}")
                return

            for message in messages:
                print(f"Received message: {message}")

        async def main():
            memphis = Memphis()
            await memphis.connect(host='localhost', username='user', password='pass')
            consumer = await memphis.consumer(station_name='my_station', consumer_name='my_consumer', consumer_group='my_group')
            consumer.set_context({'key': 'value'})
            consumer.consume(callback=message_handler)

            # Keep the event loop running
            while True:
                await asyncio.sleep(1)

        asyncio.run(main())
    """

self.dls_callback_func = callback
self.t_consume = asyncio.create_task(self.__consume(callback))

from memphis.py.

rnowling-memphis avatar rnowling-memphis commented on May 30, 2024

@Adarsh-jaiss It's nearly impossible to review and comment on an issue -- can you create a PR? I think going forward, it would be best just to go directly to creating a PR if you want feedback on code. Thanks!

from memphis.py.

rnowling-memphis avatar rnowling-memphis commented on May 30, 2024

Closed by #182

from memphis.py.

Related Issues (20)

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.