router: support fetching backend list from external interface#135
router: support fetching backend list from external interface#135xhebox merged 3 commits intopingcap:mainfrom
Conversation
| } | ||
|
|
||
| // ExternalFetcher fetches backend list from a given callback. | ||
| type ExternalFetcher struct { |
There was a problem hiding this comment.
Why can not let they pass an implementation of interface BackendFetcher?
There was a problem hiding this comment.
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.
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.
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.
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.
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:
BackendFetcherBackendFetcher: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.