-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dvl/klaus/webadm readable msg #85
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review not yet finished.
@@ -455,6 +457,28 @@ def graph_dot(self, end=''): | |||
for end, sub in after: | |||
sub.graph_dot(end=end) | |||
|
|||
def jsonable_msg_info_for_admin(self, msg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is not a Message
method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each channel handles different kinds of messages.
I imagine the usecase where a channel wants to have a different representation of a message.
Let's say an MLLP channel would prefer to have perhaps a partially preparsed representation for the web interface,
A file watcher channel might not display the contents of the file, but more stats about the file.
An alternative would of course be to put this method into the channel and let certain endpoints / channels subclass the Message object. (Though this might imply more data copies)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fair.
New proposal : you add the method to the Message
class but you allow to redefine default payload_encoder with an argument. Then you add a method to the channel that call the Message
method with the appropriate encoder. Later (i.e. in another PR) we can add a way to custom encoder by a channel argument.
What do you think ?
I think you can use current .to_dict()
method and add the correct argument to achieve that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After more thinking, more details :
- You can create two messages serializer (at least) in the serializer file :
b64picklerEncoder
andJsonableEncoder
, - Add
payload_encoder
option toMessage.to_json()
method withb64picklerEncoder
as default encoder (to keep compatibility) and propagate the option to.to_dict()
method, - Add a
message_payload_encoder
property to channel with b64 default encoder with default value to b64encoder, - Use this encoder in the
.list_message()
while calling.to_json()
to get your formatted message.
Do I miss something ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the param for message_payload_encoder be
a class, an instance (which must have the method encode or just a function that encodes).
Will make a first start with an instance, but I am open.
and the more I think the less I wonder why not just passing a function, except we want to group the encode and decode function in the same office.
In that case we should perhaps call the param
payload_codec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. pushed only to local gitlab server and not to github
Just check klausfmh@297b219
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact best to recheck all the deltas of this MR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder to continue review :-)
I think I handled all the FB. pls correct me if wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's what i think for message but part :
- Add a message_payload_encoder property to channel with b64 default encoder with default value to b64encoder,
- Use this encoder in the .list_message() while calling .to_json() to get your formatted message.
is not yet done ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think jsonable_msg_info_for_admin
channel method should not exists anymore at the end.
pypeman/remoteadmin.py
Outdated
""" | ||
List first `count` messages from message store of specified channel. | ||
|
||
:params channel: The channel name. | ||
:param mk_b64pickle: if True (yield payload / ctx fields as b64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we create an payload_serializer
param that can be what we want ? The default one is a b64pickle, but we can specify the "jsonable" one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an option.
Another one would be to just pass a 'name' of a serializer and allow to register other ones if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with your proposal.
res['message'] = res['message'].to_json() | ||
else: | ||
msg = res['message'] | ||
res['message'] = chan.jsonable_msg_info_for_admin(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, why is this not a message method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above
72864c9
to
4a8053d
Compare
1309368
to
680517e
Compare
680517e
to
e83e63b
Compare
e83e63b
to
e62b4f7
Compare
e62b4f7
to
b2d4706
Compare
b2d4706
to
6de03e9
Compare
The goal is to have adapt the web interface such, that the messages that are posted are a little better readable.