-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[CCR] Update auto-follow pattern serialization #26885
[CCR] Update auto-follow pattern serialization #26885
Conversation
💔 Build Failed |
💔 Build Failed |
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.
Tested locally, code LGTM!
@@ -21,3 +21,12 @@ export const object = { | |||
return Object.keys(obj).map(k => ({ ...obj[k], __id__: k })); | |||
}, | |||
}; | |||
|
|||
export const array = { |
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.
What do you think of exporting an arrayToObject
function instead? With named exports I tend to see the module itself take the place of a namespacing object, like the array
object in this case.
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.
👍
@@ -16,7 +17,7 @@ const success = action => `${action}_SUCCESS`; | |||
export const reducer = (state = initialState, action) => { | |||
switch (action.type) { | |||
case success(t.AUTO_FOLLOW_PATTERN_LOAD): { | |||
return { ...state, byId: action.payload }; | |||
return { ...state, byId: array.toObject(action.payload.patterns, 'name') }; |
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.
Though personally, I don't think this single use of this logic merits extraction into a utility. As a reader of the code, I'd rather see the function defined in this file, e.g. as a mapPatternsToNames
function.
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.
Until we need it somewhere else, we'll need it in Follower Indices soon.
@@ -48,7 +50,7 @@ export const registerAutoFollowPatternRoutes = (server) => { | |||
}); | |||
|
|||
/** | |||
* Returns a list of all Auto follow patterns | |||
* Save an auto follow patterns |
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.
Small typo: "an auto follow patterns" should be "an auto-follow pattern" (singular) or just "auto-follow patterns" (plural).
/** | ||
* There is currently a bug in the ES API, instead of returning the auto-follow pattern, it returns | ||
* an array with a single element. Until it is fixed, we take care of it here. | ||
*/ |
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.
Per the convo today we might want to rephrase this comment to identify it as a design quirk rather than a bug?
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 will remove the comment from what we discussed with the ES team. It's by design indeed :)
💚 Build Succeeded |
💚 Build Succeeded |
ES has made a breaking change in the auto-follow pattern API: elastic/elasticsearch#36203
This PR update the server serialization and Redux state to support it.
Note: The API integration tests have been disabled as something has changed and an auto-follow pattern cannot be created anymore if the cluster has a BASIC license.