On 06/30/2015 11:59 AM, David Birdsong wrote:
On Tue, Jun 30, 2015 at 11:56 AM Rob Miller <[email protected]
<mailto:[email protected]>> wrote:

    Encoders don't emit message structs, they emit byte streams. If a
    Lua encoder uses the `inject_message` API call then it will emit the
    protobuf encoding for the full message, but if the `inject_payload`
    API is used then it will emit the string contents of the provided
    payload.

oh, this is interesting.

so `inject_message` in an encoder can serve to scribble on the message
just before it hits the wire, but as a protobuf?
TL;DR: Yes.

Long version: If you just want to scribble on the message, say to remove 
personally identifying information (PII), you can use `write_message` one or 
more times and then *not* call inject_message. This will create a copy of the 
incoming message, apply your changes, and (when it notices that inject hasn't 
been called) emit a protobuf encoding of the new message after process_message 
exits.

You'd get an equivalent result by calling `read_message("raw")` to get the 
protobuf encoding for the input message, then calling `decode_message` to turn that into 
a Lua table, mutating the table, and finally calling inject_message to inject the mutated 
version. For now, if you're making only small changes to the outgoing message, the 
write_message API is probably going to be more efficient. We're discussing changes that 
may make that no longer true going forward, in which case we may reduce this to a single 
API, but that's still unsettled.

Of course you can also create a message-shaped Lua table by hand, however you 
want to, and then use inject_message to emit a protobuf encoding of that 
message.

-r
_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka

Reply via email to