-
Notifications
You must be signed in to change notification settings - Fork 28
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
Feature(CORE): Activity log extension #300
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
a4733c7
to
2813afe
Compare
2813afe
to
842b1d3
Compare
842b1d3
to
3563a64
Compare
3563a64
to
cf2b6ff
Compare
cf2b6ff
to
171cf1a
Compare
171cf1a
to
387a6cf
Compare
Codecov ReportPatch coverage is 📢 Thoughts on this report? Let us know!. |
… into cacheLayerLoader
387a6cf
to
c187362
Compare
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.
Beside some questions and suggestions, other LGTM
) { | ||
const { urlPath } = schema; | ||
const { sql } = cache; | ||
// if fn is not a function, return |
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 is the comment? Seems no fn
?
} | ||
} | ||
|
||
protected sendActivityLog = 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 does here use the functional expression repsentation ( xxx = () => {}
)? Is the reason to do it?
}); | ||
}; | ||
|
||
protected getUrl = (connection: HttpLoggerConnectionConfig): string => { |
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.
Same as above.
throw new Error('Http logger connection should be provided'); | ||
} | ||
const headers = option.connection.headers; | ||
const url = this.getUrl(option.connection); |
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.
Just curious seems you have provided a function called getUrl
in utils
and here you also create the same name method, but also the same code ( not using the header
), so why does not use the getUrl
in utils
directly?
const url = getUrl(connection as ConnectionConfig);
packages/core/src/lib/utils/url.ts
Outdated
ssl?: boolean | undefined; | ||
host?: string | undefined; |
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.
You have added the ?
, is means undefined, so actually, you don't need to write again by undefined
.
path?: string | undefined; | ||
} | ||
|
||
export const getUrl = (connection: ConnectionConfig): string => { |
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.
Same as above of path
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.
LGTM 👍
}), | ||
{ preventOverrun: true, id: workerId } | ||
); | ||
// add the job to schedule cache refresh task | ||
this.scheduler.addIntervalJob(refreshJob); | ||
} else { | ||
await this.cacheLoader.load(templateName, cache); | ||
await this.sendActivityLogAfterLoad(schema, cache); |
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.
Optional: Suggest renaming LoadCacheAndSendActivityLog
, if you are available
65e28db
to
ef7921f
Compare
Description
Add a activity log extension to send activity log like incoming request information and cache refreshing result.
Activity logs aim to provide a more specific and accurate information compared to the access log or debug logger stdout.
How to use
After you set your project config, vulcan server will send activity log to remote server asynchronously when cache refreshing job is done and after processed an API request.
A cache refreshing activity log will contain info
In an API request activity log will contain info
Test
unit tests
Labs:
manually create a koa server on localhost with a router "(POST)/test"
vulcan.yaml: