Repository navigation
Refactor[OBE-12143] - Build stateful decoders per unit from a DecoderFactory - #182
Open
janmejay-s1 wants to merge 2 commits into
Open
janmejay-s1 wants to merge 2 commits into
janmejay-s1 wants to merge 2 commits into
Conversation
…Factory DecodingConfig::build() now returns a cloneable DecoderFactory<Stream | Datagram>, and sources build a fresh Decoder from it per unit (connection, datagram, message, request, object). Deserializer::parse takes &mut self, the Framer and Deserializer traits drop DynClone and Sync, and Decoder, Framer and Deserializer are no longer Clone; static assertions keep them Send, !Clone and !Sync. Expensive preparation (VRL compile, protobuf descriptor load, avro schema parse, json_paths rules) happens once in the factory, and state shared across units (netflow's template cache, chunked GELF's partial-message map) lives there too. json_paths owns its parser state directly, and the VRL deserializer reuses one runtime per decoder. aws_s3 now builds a decoder per object instead of sharing one deserializer across objects and concurrent SQS tasks, and amqp builds its factory once instead of rebuilding the decoding config per delivery. Bumps the private submodule for the matching Observo source changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The HTTP client loop no longer clones its context builder per request: build() takes &self, so neither the clone nor the Clone bounds on call() and HttpClientContextBuilder are needed. - Netflow, chunked GELF and protobuf factories are built directly instead of constructing a throwaway decoder (which, for netflow, also consumed a connection id) and taking its parts; the instance constructors now delegate to the factories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jsbalis1
approved these changes
Nov 7, 2026
jsbalis1
reviewed
Nov 7, 2026
| NetflowDecoder::new_with_max_length(max_length) | ||
| } else { | ||
| NetflowDecoder::new() | ||
| /// Build a `NetflowDecoderFactory` from this configuration. |
Contributor
There was a problem hiding this comment.
Netflow seems like a misfit in framing. The way it works is it receives packet of types data as well as templates And in a data packet you ref those templates to get final values.
We should actually move this to a proper source and move it from framing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Decoders are now built per unit from a factory instead of being cloned.
DecodingConfig::build()returns a cloneableDecoderFactory<Stream | Datagram>.build()on it once per unit (connection, datagram, message, request, S3/GCS object) to get a freshDecoder.format::Deserializer::parsetakes&mut self.Framer/Deserializertraits dropDynCloneandSync.Decoder,FramerandDeserializerare no longerClone.static_assertionskeeps themSend + !Clone + !Sync, with the reasoning written next to the assertions.FramerFactoryandDeserializerFactorymirror the existing enums.DecoderFactory<Datagram>::build(peer)scopes netflow templates per exporter;Streamdecoders get a fresh scope.DecoderFactory<S>is bounded by a sealedScopetrait.Arc<Mutex>, and no hand-written state-resettingClone.Runtimeper decoder and clears it after each parse.build_unix_stream_sourcenow takes a per-connection builder)Why
Stateful deserializers needed interior mutability and a hand-written
Clonethat reset their state. Whether a clone copied, reset or shared state was decided implicitly by each codec'sCloneimpl, and two sources got it wrong. Making decoders built per unit, and impossible to clone, puts that decision in one place: the factory.How to Test
TMPDIR=/tmp cargo nextest run -p codecs(including--features syslog,observo).cargo nextest run --no-default-features --features sources-heroku_logs,sources-datadog_agent,sources-aws_kinesis_firehose,sources-http_client,sources-socket,sources-exec,transforms-route --lib -- do_not_share_json_paths_statefactory,chunked_gelf_*_decoders_*andnetflow_*_decoders_*.FEATURES=observo,observo-test,transforms-route make test.transforms-routeis needed to avoid an existingis_indexabledead-code error that this branch doesn't touch.Verification notes
make test: passes, except for compliance tests with fixed 1–5 s windows that fail under full-run load and pass on their own:excludes_matchesconsolesink that isn't compiled into the Observo feature set.make check-clippyreports existing errors under the 1.88 toolchain; the new lines add no findings.Breaking Changes
Public
codecsAPI changes, for code outside this repo that uses the decoding API:DecodingConfig::build(),DeserializerConfig::build()andFramingConfig::build(limits)return factories. The configs for VRL, protobuf, avro, json_paths, netflow and chunked GELF also return factories frombuild().Decoder,Framer,Deserializer,NetflowDecoderandChunkedGelfDecoderare no longerClone.Decoder::clone_for_connection,Decoder::clone_for_datagram_peer,NetflowDecoder::set_datagram_peerandNetflowDecoder::set_new_connection_scopeare removed. UseDecoderFactory::build.format::Deserializer::parsetakes&mut self.build_unix_stream_sourcetakesimpl Fn() -> Decoderinstead of aDecoder.Jira: OBE-12143
🤖 Generated with Claude Code