Comments (6)
@Adarsh-jaiss are you interested in this?
from memphis.py.
- yeah I would love to work on this!
- could you please explain me a bit about the issue?
from memphis.py.
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.
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.
@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.
Closed by #182
from memphis.py.
Related Issues (20)
- [Discussion] Typing, tests, formatting, pre-commit HOT 4
- Stop consume functionality HOT 7
- Create formal documentation HOT 3
- Bug: Improve error description HOT 6
- Bug: Tries to access property of None instance HOT 2
- Bug: Missing method HOT 2
- Setup automated tests for PRs
- Bug: Review no-member error for ProtoBuf HOT 4
- Bug: Review no-member error for Exception status_code member HOT 6
- Re-enable E1101 message from Pylint
- Raise MemphisSchemaError rather then MemphisError HOT 1
- lint project using Ruff HOT 3
- Use separate connections for producers, consumers, etc.
- Inconsistent consumer name HOT 1
- Add task count limit to async produce
- Add error handling for async produce
- Drain or cancel waiting tasks when the producer is destroyed
- Support destroying existing consumers
- Change name of async producer parameter to "non-blocking"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memphis.py.