msggen: RequestStructs for notification-streams

I'm working to expose a stream of notifications over grpc.
This requries me to define structs that can be used to request
a stream of notifications.

These structs are all empty.
This commit is contained in:
Erik De Smedt 2024-02-13 10:46:55 +01:00 committed by Christian Decker
parent 6b34c722f3
commit c5a47c3149
3 changed files with 32 additions and 1 deletions

View file

@ -82,3 +82,27 @@ pub struct CustomMsgNotification {
pub peer_id: PublicKey,
}
pub mod requests{
use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StreamBlockAddedRequest {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StreamChannelOpenFailedRequest {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StreamChannelOpenedRequest {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StreamConnectRequest {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StreamCustomMsgRequest {
}
}

View file

@ -152,7 +152,7 @@ class GrpcConverterGenerator(IGenerator):
camel_case += word.capitalize()
return camel_case
def generate_requests(self, service):
def generate_requests(self, service: Service):
for meth in service.methods:
req = meth.request
self.generate_composite("requests", req)

View file

@ -45,3 +45,10 @@ class NotificationGenerator(IGenerator):
for notification in service.notifications:
_, resp_decl = gen_composite(notification.response, self.meta)
self.write(resp_decl)
self.write("pub mod requests{\n")
self.write(" use serde::{Serialize, Deserialize};\n\n")
for notification in service.notifications:
_, req_decl = gen_composite(notification.request, self.meta)
self.write(req_decl, numindent=1)
self.write("}\n")