Happyr / message-serializer

Serialize messages for transport over the wire
MIT License
77 stars 12 forks source link

Message structure not consistent with sample in the readme #40

Closed Deamon closed 4 years ago

Deamon commented 4 years ago

Hi @Nyholm, first of all, thank you for this serializer. Very helpfull to start quickly to communicate with third parties.

here is my issue, when I send a message from a command and I get a message looking like this:

{
    "version": 1,
    "identifier": "foo",
    "timestamp": 1566491957,
    "payload": {
        "bar": "test string"
    },
    "_meta": []
}

see the _meta ? I wasn't expected it.

In order to make my POC work, I edit line 63 of the Serializer.php from :

        $message['_meta'] = $this->getMetaFromEnvelope($envelope);

to

        $meta = $this->getMetaFromEnvelope($envelope);
        if(!empty($meta)){
            $message['_meta'] = $meta;
        }

making this change brakes tests so you expected this result when writing your code.

So what is the good edit for you? Updating the doc or updating tests?

I can take time to fix both depending on your answer.

Nyholm commented 4 years ago

Oh, interesting. Thank you for pointing this out.

The _meta key was added in #31 because we wanted to better support retry and possible other features.

I would rather have a key that is always there because it makes it easier to handle for the consumer.

I think #31 just forgot to update the documentation explaining this.

Deamon commented 4 years ago

You're welcome. can't we add thoses keys in messageHeader ?
In all cases, I'm preparing a docEdit.