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

refactor(api): Move EventListener and dependent classes to echo-api, remove previous RestEventParser #790

Merged
merged 5 commits into from
Feb 29, 2020

Conversation

jonsie
Copy link
Contributor

@jonsie jonsie commented Feb 27, 2020

Todo:

  • Jackson serializer/deserializer for Event (to remove @JsonInclude(NON_NULL) from echo-api). Likely will be in the module echo-api-jackson.
  • Unify ObjectMapper configuration (so custom serializers/deserializers are always configured)

I also took the opportunity to rename EchoEventListener to just EventListener.

@jonsie jonsie added the WIP Work in progress, feedback appreciated, do not merge label Feb 27, 2020
@jonsie jonsie removed the WIP Work in progress, feedback appreciated, do not merge label Feb 27, 2020
@jonsie jonsie changed the title WIP - refactor(api): Move EventListener and dependent classes to echo-api, remove previous RestEventParser refactor(api): Move EventListener and dependent classes to echo-api, remove previous RestEventParser Feb 27, 2020
@jonsie jonsie requested review from robzienert, srekapalli and a team February 27, 2020 23:41
Copy link
Contributor

@srekapalli srekapalli left a comment

Choose a reason for hiding this comment

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

LGTM

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Map;

public abstract class EventMixin {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

EventMixin' 🎧


@JsonInclude(JsonInclude.Include.NON_NULL)
public Map payload;
public Map<String, Object> payload;

public String eventId = UUID.randomUUID().toString();
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there value in content and payload being typed? I'd really like to avoid bringing M<S, O> into the -api modules if possible. Perhaps for Echo, we can't really do anything about it until the other services sending events in are well-defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll merge as is and then explore how content and payload could be typed. There's a lot to unwind WRT how Event and TriggerEvent (and the various TriggerEvent types) deserialize the content field and I don't feel comfortable making any changes there yet.

eventMap =
restEventParser
.get()
.parseEvent(mapper.convertValue(event, RestEventParser.Event.class));
Copy link
Member

Choose a reason for hiding this comment

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

I see this code being removed here, but I don't recall seeing it put somewhere else. It's concerning to me that this didn't break any tests, either?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the integration for the first extension point I added to echo (RestEventParser), but I think there's more value in pulling it out and redesigning how we build the echo-api. It's not being used at all right now.

@jonsie jonsie merged commit 784909e into spinnaker:master Feb 29, 2020
@jonsie jonsie deleted the refactor-api branch February 29, 2020 19:23
private Map attributes;
private HttpHeaders requestHeaders = new HttpHeaders();
private Map<String, String> attributes;
private Map<String, List<String>> requestHeaders = new HashMap<>();
Copy link
Contributor

@luispollo luispollo Apr 20, 2020

Choose a reason for hiding this comment

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

@jonsie It looks like this broke code that relied on the assumption of headers being converted to lowercase by HttpHeaders, as discussed in #840. I think it might be best to revert this line instead of fixing each specific downstream issue that comes up as a result, unless there was a good reason to convert this particular property to a Map.

Copy link
Contributor Author

@jonsie jonsie Apr 20, 2020

Choose a reason for hiding this comment

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

Ah sorry, I didn't catch this. Unfortunately, we can't pull in the Spring dependency into echo-api as this module needs to be dependency free (basically, just Java), which is why I removed HttpHeaders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might do the trick:

private Map<String, List<String>> requestHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

5 participants