-
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
router: support fetching backend list from external interface #135
Conversation
} | ||
|
||
// ExternalFetcher fetches backend list from a given callback. | ||
type ExternalFetcher struct { |
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 can not let they pass an implementation of interface BackendFetcher
?
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's OK to pass a BackendFetcher from the Router, but it exposes map[string]*BackendInfo
.
But it's not easy to pass it from the gateway. The fetcher requires a token as the parameter, and the router can wrap 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.
But it's not easy to pass it from the gateway. The fetcher requires a token as the parameter, and the router can wrap it.
I don't understand. It is completely possible to do:
type gatewayFetcher struct {
token string
}
func (f *gatewayFetcher) GetBackendList(context.Context) map[string]*BackendInfo {
...
}
The only imperfect is that we exposed BackendInfo
.
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.
Updated, the BackendObserver receives a customFetcher. But I still think the fetcher should be passed from the router because of the token parameter.
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.
type gatewayFetcher struct {
token string
}
This is different from the interface we negotiated with them. This just makes things complicated. Besides offering a GetBackends
, they have to also create a fetcher.
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 is different from the interface we negotiated with them. This just makes things complicated. Besides offering a
GetBackends
, they have to also create a fetcher.
If the only method of the interface is GetBackendList(context.Context) map[string]*BackendInfo
, with all BackendInfo
an empty struct, what is the difference?
Three lines of code to declare gatewayFetcher
type? They will need to store that token somewhere anyway, for example, a variable captured by the lambda function.
If we want to support, grpc pushing/notification of backends changes, BackendFetcher
interface will change somehow, i.e. not just a fetcher. It is likely that ExternalFetcher
will not work anymore.
What problem does this PR solve?
Issue Number: close None
Problem Summary:
In the serverless tier, the gateway offers an interface to query the backend list.
What is changed and how it works:
BackendFetcher
BackendFetcher
:StaticFetcher
,PDFetcher
, andExternalFetcher
.Some TODOs in next PRs:
Check List
Tests
Notable changes
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.