Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement context load, context save, and context reset #3908

Merged
merged 1 commit into from Feb 13, 2024

Conversation

eliaskosunen
Copy link
Contributor

@eliaskosunen eliaskosunen commented Feb 5, 2024

Closes https://github.com/tenzir/issues/issues/1523, companion PR: https://github.com/tenzir/tenzir-plugins/pull/175

  • context update was previously overloaded on its input type. Now it only accepts events. The bytes-overload is removed (it wasn't implemented by contexts), and the void-overload is called context reset.
  • context load and context save are added, that load from and serialize to bytes, respectively.
    • They are transformations on bytes<->events, and don't perform I/O themselves: the most common use case is probably that load <serialized-binary-file> is piped to context load, and context save is piped to save <serialized-binary-file>. A carbon-copy of a context can be created with context save foo | context load bar.
    • The contexts already implemented this functionality, the necessary plumbing to call them just wasn't there, yet

As a table:

Before After Description
<events> | context update <ctx> (unchanged) Update context with events
<bytes> | context update <ctx> (removed, wasn't implemented) Update context with bytes
context update <ctx> [flags] context reset <ctx> [flags] Reset context state
N/A context save | <bytes> Serialize context save into bytes
N/A <bytes> | context load Load context state from bytes

@eliaskosunen eliaskosunen added feature New functionality operator Source, transformation, and sink labels Feb 5, 2024
@eliaskosunen eliaskosunen changed the title [WIP] Implement context load, context save, and context reset Implement context load, context save, and context reset Feb 6, 2024
@eliaskosunen eliaskosunen marked this pull request as ready for review February 6, 2024 09:07
@eliaskosunen eliaskosunen force-pushed the topic/context-load-save branch 4 times, most recently from 1ac1935 to 4051fec Compare February 12, 2024 11:05
Copy link
Member

@Dakostu Dakostu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

libtenzir/include/tenzir/plugin.hpp Show resolved Hide resolved
web/docs/operators/context.md Outdated Show resolved Hide resolved
web/docs/operators/context.md Outdated Show resolved Hide resolved
web/docs/operators/context.md Outdated Show resolved Hide resolved
libtenzir/include/tenzir/plugin.hpp Outdated Show resolved Hide resolved
Copy link
Member

@Dakostu Dakostu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preemptively approve now, with some small suggestions remaining.

libtenzir/builtins/contexts/geoip.cpp Outdated Show resolved Hide resolved
libtenzir/builtins/contexts/bloom_filter.cpp Outdated Show resolved Hide resolved
@Dakostu
Copy link
Member

Dakostu commented Feb 13, 2024

@eliaskosunen Please also add a changelog item regarding the new subcommands.

@eliaskosunen eliaskosunen force-pushed the topic/context-load-save branch 2 times, most recently from 30cb32d to 2008e64 Compare February 13, 2024 12:03
@eliaskosunen eliaskosunen merged commit ee013eb into main Feb 13, 2024
57 checks passed
@eliaskosunen eliaskosunen deleted the topic/context-load-save branch February 13, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality operator Source, transformation, and sink
Projects
None yet
2 participants