-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rewrote the interfaces of the Splunk object to follow the hierarchy of the Javascript SplunkSDK #79
Conversation
9ecb106
to
e1da2b7
Compare
@@ -58,44 +58,60 @@ function createService(): SplunkService { | |||
return service; | |||
} | |||
|
|||
function handleHTTPScriptError(error: any): Promise<boolean> { |
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.
Would it make sense to extract this in a SplunkHTTPClient
somewhere?
Otherwise we have to copy paste this handler's pointer everywhere?
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 are actually using the Splunk SDK's HTTP Client, that's why I'm adding the error handling in the Promise directly. Also, the script error handling only apply to the four endpoints we defined in the flare_external_requests script file, not the other HTTP request that are done on the Splunk SDK objects
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.
So then my suggestion is to wrap the Splunk SDK's client?
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.
Not sure how I would do that, I'm not working directly with their HTTP client, they already have a wrapper above it to expose their interface, they just append to also have the methods get
and post
available to do requests with your authentication. The Splunk SDK is injected in the page, it's not a dependency that we have in the project.
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.
Similar to this?:
const splunkClient = () => {
const post = (url, data) => Promise {
return promisify(service.post)(url, data).catch(handleHTTPServiceError)
}
return {
post,
};
}();
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.
Got it. It's not a small refactor, I might finish this PR during the cooldown or if I have downtime during the cycle.
128bd95
to
e9e720f
Compare
This PR is now a refactor of the Splunk interface typing on top of the JS SplunkSDK. I will create two other PRs on top of this one: one for the wrapper that will promisify the functions and another one that will actually do the error handling |
update: (properties: Record<string, string>) => SplunkRequestResponse; | ||
list: () => Array<{ name: string }>; | ||
export interface Resource extends Endpoint { | ||
fetch: () => 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.
Does this need to be redeclared here if it's declared in Endpoint that this interface extends from?
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're right!
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 the one question. Otherwise, LGTM
…f the Javascript SplunkSDK Will be used to simplify the creation of a wrapper to generate Promises on top of the JS SDK
e9e720f
to
ed7ddda
Compare
Based on @aviau 's comment, a wrapper would be better to do better error handling in the future.
Will be used to simplify the creation of a wrapper to generate Promises on top of the JS SDK