-
Notifications
You must be signed in to change notification settings - Fork 654
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
refactor(api): Move EventListener and dependent classes to echo-api, remove previous RestEventParser #790
Changes from all commits
7a58f88
715da08
a7987f8
7914f5e
bf3a30d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
# echo-api | ||
|
||
A module for defining plugin extension interfaces. | ||
This module provides API interfaces and models. In particular, it offers the following PF4J | ||
`ExtensionPoint` interfaces for runtime extension: | ||
|
||
WARNING: This is an Alpha module and is not stable. Consider this an experiment. | ||
|
||
Currently there is one extension point `RestEventParser` which is limited to parsing events | ||
in echo's `RestEventListener`. This is primarily for early iteration and testing purposes. | ||
|
||
The more powerful extension point for Echo is likely to be `EchoEventListener` - this would enable a plugin | ||
ecosystem for Echo and also allow us to break existing implementations of `EchoEventListener` | ||
(echo-rest, echo-notifications, echo-telemetry, etc) up into discrete plugins. | ||
- [EventListener](src/main/java/com/netflix/spinnaker/echo/api/events/EventListener.java) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.echo.api.events; | ||
|
||
import org.pf4j.ExtensionPoint; | ||
|
||
/** | ||
* This is the main touch point for Echo. Implementations of `EventListener` will, if wired up as a | ||
* Spring bean, process all events that are posted into Echo. | ||
*/ | ||
public interface EventListener extends ExtensionPoint { | ||
jonsie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** Process an Echo {@link Event} */ | ||
void processEvent(Event event); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/* | ||
* Copyright 2015 Netflix, Inc. | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
|
@@ -14,12 +14,15 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.echo.model; | ||
package com.netflix.spinnaker.echo.api.events; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import lombok.*; | ||
import org.springframework.http.HttpHeaders; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** Represents event metadata */ | ||
@Data | ||
|
@@ -33,6 +36,6 @@ public class Metadata { | |
private String project; | ||
private String application; | ||
private String _content_id; | ||
private Map attributes; | ||
private HttpHeaders requestHeaders = new HttpHeaders(); | ||
private Map<String, String> attributes; | ||
private Map<String, List<String>> requestHeaders = new HashMap<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might do the trick:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.echo.jackson; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import com.netflix.spinnaker.echo.api.events.Event; | ||
import com.netflix.spinnaker.echo.jackson.mixin.EventMixin; | ||
|
||
public class EchoObjectMapper { | ||
private EchoObjectMapper() {} | ||
|
||
private static final ObjectMapper INSTANCE = newInstance(); | ||
|
||
public static ObjectMapper newInstance() { | ||
return new ObjectMapper() | ||
.addMixIn(Event.class, EventMixin.class) | ||
.registerModule(new Jdk8Module()) | ||
.registerModule(new JavaTimeModule()) | ||
.disable(FAIL_ON_UNKNOWN_PROPERTIES) | ||
.setSerializationInclusion(NON_NULL); | ||
} | ||
|
||
/** | ||
* Return an ObjectMapper instance that can be reused. Do not change the configuration of this | ||
* instance as it will be shared across the entire application, use {@link #newInstance()} | ||
* instead. | ||
* | ||
* @return Reusable ObjectMapper instance | ||
*/ | ||
public static ObjectMapper getInstance() { | ||
return INSTANCE; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/* | ||
* Copyright 2015 Netflix, Inc. | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
|
@@ -14,10 +14,15 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.echo.events; | ||
package com.netflix.spinnaker.echo.jackson.mixin; | ||
|
||
import com.netflix.spinnaker.echo.model.Event; | ||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
|
||
public interface EchoEventListener { | ||
void processEvent(Event event); | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.Map; | ||
|
||
public abstract class EventMixin { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EventMixin' 🎧 |
||
|
||
@JsonInclude(NON_NULL) | ||
public Map<String, Object> payload; | ||
} |
There was a problem hiding this comment.
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
andpayload
being typed? I'd really like to avoid bringingM<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?There was a problem hiding this comment.
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
andpayload
could be typed. There's a lot to unwind WRT howEvent
andTriggerEvent
(and the variousTriggerEvent
types) deserialize thecontent
field and I don't feel comfortable making any changes there yet.