Files
kumomta/crates/message
Wez Furlong d6203f6eff Allow logging via a lua hook
Still need to write up some proper docs, but the gist is that
the example below will enqueue a message holding the content
of the JsonRecord for each log event, and that message will be
dispatched via a custom lua delivery mechanism.

```lua
kumo.on('init', function()
  kumo.configure_log_hook {}
end)

kumo.on('make.lua-sender', function(domain, tenant, campaign)
  print 'making lua sender'
  local sender = {}
  function sender:send(message)
    print('Sending a message!', message:get_data())
    return 'Super!'
  end
  return sender
end)

kumo.on('should_enqueue_log_record', function(msg)
  local log_record = msg:get_meta 'log_record'
  print('should_enqueue_log_record', log_record)
  -- avoid an infinite loop caused by logging that we logged
  if log_record.queue ~= 'lua-stuff' then
    msg:set_meta('queue', 'lua-stuff')
    return true
  end
  return false
end)

kumo.on('get_queue_config', function(domain, tenant, campaign)
  print('get_queue_config', domain, tenant, campaign)
  if domain == 'lua-stuff' then
    return kumo.make_queue_config {
      protocol = {
        custom_lua = {
          constructor = 'make.lua-sender',
        },
      },
    }
  end

  return kumo.make_queue_config {}
end)
```
2023-05-04 16:20:29 -07:00
..
2023-05-04 16:20:29 -07:00