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

Add clone_message() function #153

Merged
merged 2 commits into from Jan 4, 2017

Conversation

Projects
None yet
2 participants
@joschi
Contributor

joschi commented Jan 3, 2017

Closes #138

@joschi joschi added this to the 2.2.0 milestone Jan 3, 2017

public FunctionDescriptor<Message> descriptor() {
return FunctionDescriptor.<Message>builder()
.name(NAME)
.params(new ParameterDescriptor[0])

This comment has been minimized.

@kroepke

kroepke Jan 4, 2017

Member

Can we add an optional message parameter here (analogous to https://github.com/Graylog2/graylog-plugin-pipeline-processor/blob/master/plugin/src/main/java/org/graylog/plugins/pipelineprocessor/functions/messages/RemoveField.java#L34)?

That way we could support cloning other messages than the one from the context, as well:

let x = create_message("foo", "source");
let y = clone_message(x);
let z = clone_message();

This comment has been minimized.

@joschi

joschi Jan 4, 2017

Contributor

Totally makes sense.

final Message origMessage = context.currentMessage();
final Message newMessage = Iterables.getOnlyElement(context.createdMessages());
assertThat(origMessage).isNotSameAs(newMessage);
assertThat(newMessage.getMessage()).isEqualTo("new");
assertThat(newMessage.getSource()).isEqualTo("synthetic");
assertThat(newMessage.getStreams()).isEmpty();

This comment has been minimized.

@kroepke
@kroepke

kroepke approved these changes Jan 4, 2017

@kroepke

This comment has been minimized.

Member

kroepke commented Jan 4, 2017

lgtm!

@kroepke kroepke merged commit d58accf into master Jan 4, 2017

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details

@kroepke kroepke deleted the issue-138 branch Jan 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment