-
Notifications
You must be signed in to change notification settings - Fork 15
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
Make frontend listen for events when instances' presence changes #1779
Conversation
@@ -79,6 +81,19 @@ function* applicationInstanceHealthChanged({ payload }) { | |||
yield put(updateApplicationInstanceHealth(payload)); | |||
} | |||
|
|||
export function* applicationInstanceAbsentAtChanged({ payload }) { | |||
yield put(updateApplicationInstanceAbsentAt(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.
This may be a bit technical, but payload
will include the field sid
, that we don't strictly need to pass to updateApplicationInstanceAbsentAt()
. Thoughts on this?
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.
It doesn't really matter, it is fine this way
@@ -111,6 +113,19 @@ function* databaseInstanceSystemReplicationChanged({ payload }) { | |||
yield put(updateSAPSystemDatabaseInstanceSystemReplication(payload)); | |||
} | |||
|
|||
export function* databaseInstanceAbsentAtChanged({ payload }) { | |||
yield put(updateDatabaseInstanceAbsentAt(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.
const { sid, absent_at } = payload; | ||
yield put( | ||
notify({ | ||
text: `The application instance ${sid} is now ${ |
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.
Thoughts on this message?
assets/js/state/sagas/databases.js
Outdated
const { sid, absent_at } = payload; | ||
yield put( | ||
notify({ | ||
text: `The database instance ${sid} is now ${ |
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.
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 would put:
The database instance ${instance_number} from ${sid} is absent
and
The database instance ${instance_number} from ${sid} is present again
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.
We need to add new reducer function to update the database instances in the sap system reducer.
Besides that, some tiny details
assets/js/state/sagas/databases.js
Outdated
const { sid, absent_at } = payload; | ||
yield put( | ||
notify({ | ||
text: `The database instance ${sid} is now ${ |
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 would put:
The database instance ${instance_number} from ${sid} is absent
and
The database instance ${instance_number} from ${sid} is present again
assets/js/state/databases.js
Outdated
state.databaseInstances = updateInstance( | ||
state.databaseInstances, | ||
instance, | ||
{ absent_at } |
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 would put {absent_at: instance.absent_at}
to have the same style like the other reducer functions
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.
done
@@ -41,6 +43,53 @@ describe('SAP Systems sagas', () => { | |||
console.error.mockRestore(); | |||
}); | |||
|
|||
it('should update the absent_at field when the database instance is marked absent', async () => { |
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.
Why this now in the top of the file?
I would put it at the end as it is at the end in the prod code as well
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.
done
it('should update the absent_at field when the database instance is marked absent', async () => { | ||
const { sap_system_id, instance_number, host_id, sid } = | ||
databaseInstanceFactory.build(); | ||
const absent_at = Date.now(); |
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 bit strange this absent_at
not going in the factory itself, isn't it?
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.
done
@@ -79,6 +81,19 @@ function* applicationInstanceHealthChanged({ payload }) { | |||
yield put(updateApplicationInstanceHealth(payload)); | |||
} | |||
|
|||
export function* applicationInstanceAbsentAtChanged({ payload }) { | |||
yield put(updateApplicationInstanceAbsentAt(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.
It doesn't really matter, it is fine this way
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.
Thank you @CDimonaco
Green light.
Just added some few tiny cosmetic comments, but you don't need a new review in any case
assets/js/state/sapSystems.js
Outdated
@@ -149,6 +149,15 @@ export const sapSystemsListSlice = createSlice({ | |||
} | |||
); | |||
}, | |||
updateApplicationInstanceAbsentAt: (state, { payload: instance }) => { | |||
const { absent_at } = instance; |
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.
Could we have this like the database
reducer?
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.
done
setApplicationInstanceDeregistering, | ||
unsetApplicationInstanceDeregistering, | ||
setDatabaseInstanceDeregisteringToSAPSystem, | ||
unsetDatabaseInstanceDeregisteringToSAPSystem, | ||
updateDatabaseInstanceAbsentToSAPSystem, |
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 would put this together with the first one, in line 247, as they are related
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.
done
assets/js/state/sapSystems.js
Outdated
@@ -183,6 +192,15 @@ export const sapSystemsListSlice = createSlice({ | |||
{ deregistering: false } | |||
); | |||
}, | |||
updateDatabaseInstanceAbsentToSAPSystem: (state, { payload: instance }) => { |
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 about putting this right after the other? as they are related and to avoid scrolling
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.
done
b5c68ec
to
c9c0d8a
Compare
c9c0d8a
to
e47b0ef
Compare
Description
This PR adds the ability for the frontend to listen for
application_instance_absent_at_changed
&database_instance_absent_at_changed
websocket events when instances' presence changes.With this change, the frontend's state will update when an instance becomes absent or present.
How was this tested?
Added tests in Redux reducers and Sagas to test this behaviour.