memphis
memphis copied to clipboard
Feature: schemaverse schema introspection/autogenerated types for typescritpt.
Current behavior
This would be a nice to have feature. Atm we have to explicitly define type in typescript on the consumer/producer side attached to station. For eg:
// this part could be automated and schemaverse should implicitly tell us the type of messageData.
type JsonMessage = {
id: string;
}
consumer.on('message', (message: Message) => {
const messageData = message.getData();
const jsonMessage: JsonMessage = JSON.parse(messageData.toString());
console.log(jsonMessage);
message.ack();
});
type JsonMessage could be automated here.
Suggested solution
One of the solution could be: We have introspection on the schemas defined in schemaverse. We can then generate attached schema of a particular station to typescript types on the fly. So both the consumer and producer have typesafety for the message being sent to the station. For eg:
consumer.on('message', (message: Message) => {
const messageData = message.getData();
// do something with messageData
console.log(messageData);
message.ack();
});
We should implicitly know that messageData would be of type/shape.
{
id: string;
}
Additional context
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Contributing Docs
- [X] I agree to follow this project's Contribution Docs
Thanks @damngamerz ! It added to the near backlog and will be handled soon.
Apologies for the late response, @damngamerz. Somehow missed.
@yanivbh1 No problem. Glad to hear this is being taken forward. <3 This would make memphis very seamless to work with, if implemented correctly. I can say this would be a USP to memphis and i would prefer it to use over anything else out there. Kudos guys :+1:
@Big-Vi Would you like to work on that together?
Would love to see this! I usually had to implement a wrapper around the client to have a similar effect
@Big-Vi Would you like to work on that together?
Yep. I can take a look.
This would be huge. Thank you for taking this forward. Atm we created a package to share types between our microservices. Solving this one would make it obsolete. :heart: Please don't hesitate to ask for input :tada:
This would be huge. Thank you for taking this forward. Atm we created a package to share types between our microservices. Solving this one would make it obsolete. ❤️ Please don't hesitate to ask for input 🎉
Thanks @damngamerz. 🙂
How are you @Big-Vi ? Did you manage to work on it?
Not yet. I'm working on other issue. I'll work on this next.
@yanivbh1 I'm busy lately. I'll come back and start contributing again once i find the time. Meanwhile if somebody wants to work on this, they can go for it.
Thank you @Big-Vi, that is completely understood. We will do our best to prioritize it for the next release.