-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Proposal: Make Keyword & Json-Query generic across monitor types #3919
Draft
chakflying
wants to merge
1
commit into
louislam:master
Choose a base branch
from
chakflying:generic-keyword-and-query
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chakflying
changed the title
Proposal: Make Keyword and Json-Query generic across monitor types
Proposal: Make Keyword & Json-Query generic across monitor types
Oct 20, 2023
Yes, agree with that. However it is definitely a big changes of core features. I hope this pr should depend on #3893. Hopefully Playwright's codegen and recorder could assist me to create e2e tests easily and quickly. |
This was referenced Nov 21, 2023
7 tasks
This was referenced Dec 6, 2023
This was referenced Dec 31, 2023
This was referenced Feb 1, 2024
1 task
This was referenced Feb 17, 2024
Closed
CommanderStorm
added
the
pr:please address review comments
this PR needs a bit more work to be mergable
label
May 19, 2024
This was referenced Jun 27, 2024
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:monitor
Everything related to monitors
pr:please address review comments
this PR needs a bit more work to be mergable
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Fixes #2439
Fixes #1851
Fixes #3336
Fixes #2342
Fixes #3844
Fixes #3140
After working on #3857, it became obvious to me that the use of Keyword or Json-Query result matching would benefit many other monitor types, e.g. SQL query results, DNS results. It is also obvious that implementing them individually for each monitor type would lead to a lot of code duplication and issues with maintainability.
Given that we are migrating the code base to where each monitor type is its own file and has a self-contained
check
function, I think we can take one step further by refactoring them such that:check
function performs the actions required for each heartbeat. This function should return astring
orobject
if successful. If it fails at any stage, it can throw an Error as it does currently.check
function is successful and returns a value, it can be passed to theverify
stage, which would be independent of monitor types. We can reuse the code forKeyword
andJson-Query
, and test for positive results accordingly. This function then also produce a success or fail message.check
andverify
functions, we can set the status of the heartbeat, while handlingretries
,upsideDown
, andresentNotification
. This part should be identical to the current implementation.By making the
verify
part generic, we can remove the need for the separate monitor typeHTTP - Keyword
, and expand the ability of checking for results to any monitor types that can produce a string or object.However, this would involve quite a big refactor of the
monitor.js
file, and possibly need to handle migrations for existing users of the Keyword monitor types.Type of change
Checklist
(including JSDoc for methods)
Screenshots (if any)