#4259 allow setting ttl in protonmsg
Opened 4 months ago by mikem. Modified 7 hours ago
mikem/koji proton-ttl  into  master

file modified
+1 -1
@@ -224,12 +224,12 @@ 

    before timing out

  

  The ``[message]`` section sets parameters for how messages are formed.

- Currently only one field is understood:

  

  * ``extra_limit`` -- the maximum allowed size for ``build.extra`` fields that

    appear in messages. If the ``build.extra`` field is longer (in terms of 

    json-encoded length), then it will be omitted. The default value is ``0``

    which means no limit.

+ * ``ttl`` -- The time to live to set for messages. Measured in seconds

  

  The ``[queue]`` section controls how (or if) the plugin will use the database

  to queue messages when they cannot be immediately sent.

@@ -11,6 +11,8 @@ 

  # if field is longer (json.dumps), ignore it

  # default value is 0 - unlimited size

  extra_limit = 0

+ # message ttl can be specified in seconds, default is no ttl

+ # ttl = 86400

  

  [queue]

  # enable persistent database queue

@@ -93,6 +93,7 @@ 

          return 'topic://' + koji_topic_prefix

  

      def send_msgs(self, event):

+         ttl = self.conf.getfloat('message', 'ttl', fallback=None)

          for msg in self.msgs:

              # address is like "topic://koji.package.add"

              address = self.topic_prefix + '.' + msg['address']
@@ -104,6 +105,9 @@ 

                  self.log.debug('created new sender for %s', address)

                  self.senders[address] = sender

              pmsg = Message(properties=msg['props'], body=msg['body'])

+             if ttl:

+                 # The message class expects seconds, even though the c api uses milliseconds

+                 pmsg.ttl = ttl

              delivery = sender.send(pmsg)

              self.log.debug('sent message: %s', msg['props'])

              self.pending[delivery] = msg

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

4 months ago

Metadata Update from @tkopecek:
- Pull-request untagged with: testing-ready
- Pull-request tagged with: testing-basic

7 hours ago