trivago / gollum

An n:m message multiplexer written in Go
http://gollum.readthedocs.org/en/latest/
Apache License 2.0
940 stars 74 forks source link

fixes #229: format.MetadataCopy integrity #230

Closed mahdi-hdi closed 6 years ago

mahdi-hdi commented 6 years ago

The purpose of this pull request

Fixes of issue #229

Config to verify

default-input:
    Type: producer.Console
    Streams:
        - console

default-output:
    Type: consumer.Console
    Streams:
        - console
    Modulators:
        ## Suppose that payload is 'aaaa:bb'
        ## Copy payload to metadata['key']
        ## So metadata['key'] is now 'aaaa:bb'  and payload is 'aaaa:bb' as well
        - format.MetadataCopy:
            ApplyTo: key

       ## Split the payload and pick index 1
       ## So metadata['key'] is now 'aaaa:bb' and payload is 'bb'
        - format.SplitPick:
            Index: 1
            Delimiter: ':'

       ## In order to print value of metadata prepend it to message payload
       ## So metadata['key'] must be 'aaaa:bb' and payload be 'key#payload' 
       ## which is 'aaaa:bb#bb'
        - format.MetadataCopy:
            Key: key
            Separator: '#'
            Mode: prepend

       ## Final payload must be 'aaaa:bb#bb'
        - format.Envelope:
            Postfix: "\n"

Checklist

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.04%) to 71.237% when pulling 6096eea3ee0ebdae218fd2fe7faa7c4c0d4d6093 on issue-#229-unexpected-metadata-change into 3d7deb20ed8e122987c422b03e6c7aac62fa8145 on master.