-
Notifications
You must be signed in to change notification settings - Fork 4.7k
orca: create ORCA producer for LB policies to use to receive OOB load reports #5669
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
Changes from all commits
ed0eb16
e1c66fa
4971070
31dd4a6
f6c6b4c
0961db3
b259326
65653a4
8aa79d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,6 +110,11 @@ type SubConn interface { | |
| UpdateAddresses([]resolver.Address) | ||
| // Connect starts the connecting for this SubConn. | ||
| Connect() | ||
| // GetOrBuildProducer returns a reference to the existing Producer for this | ||
| // ProducerBuilder in this SubConn, or, if one does not currently exist, | ||
| // creates a new one and returns it. Returns a close function which must | ||
| // be called when the Producer is no longer needed. | ||
| GetOrBuildProducer(ProducerBuilder) (p Producer, close func()) | ||
| } | ||
|
|
||
| // NewSubConnOptions contains options to create new SubConn. | ||
|
|
@@ -371,3 +376,21 @@ type ClientConnState struct { | |
| // ErrBadResolverState may be returned by UpdateClientConnState to indicate a | ||
| // problem with the provided name resolver data. | ||
| var ErrBadResolverState = errors.New("bad resolver state") | ||
|
|
||
| // A ProducerBuilder is a simple constructor for a Producer. It is used by the | ||
| // SubConn to create producers when needed. | ||
| type ProducerBuilder interface { | ||
| // Build creates a Producer. The first parameter is always a | ||
| // grpc.ClientConnInterface (a type to allow creating RPCs/streams on the | ||
| // associated SubConn), but is declared as interface{} to avoid a | ||
| // dependency cycle. Should also return a close function that will be | ||
| // called when all references to the Producer have been given up. | ||
| Build(grpcClientConnInterface interface{}) (p Producer, close func()) | ||
| } | ||
|
|
||
| // A Producer is a type shared among potentially many consumers. It is | ||
| // associated with a SubConn, and an implementation will typically contain | ||
| // other methods to provide additional functionality, e.g. configuration or | ||
| // subscription registration. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description feels very vague to me, in the sense that I can't get a good idea of when to use a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you suggest something better after our discussion today?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack. The first sentence is fine, but I don't get much technical understanding from: "and an implementation will typically contain other methods to provide additional functionality, e.g. configuration or subscription registration." Additional functionality with respect to what? There's no functionality defined before this. Do we expect this to ever be implemented by another concrete type? This comment is very specific to type producer in orca/producer. If so, why have this interface?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In addition to the builder that created it, I suppose, and the
Yes, definitely. This is intended to be generic and able to be implemented by anything. The other example we already have is the health checks, which are implemented in the other languages as a generic wrapper, but hard-coded into gRPC in Go. I'd like to move to a similar model there by using this mechanism.
Not at all. If it was, it would talk about ORCA configuration. ORCA should not be part of grpc-go directly, but instead should only be a plugin which uses this. |
||
| type Producer interface { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * | ||
| * Copyright 2022 gRPC authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package grpcsync | ||
|
|
||
| import ( | ||
| "sync" | ||
| ) | ||
|
|
||
| // OnceFunc returns a function wrapping f which ensures f is only executed | ||
| // once even if the returned function is executed multiple times. | ||
| func OnceFunc(f func()) func() { | ||
| var once sync.Once | ||
| return func() { | ||
| once.Do(f) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,15 @@ | |
| // avoid polluting the godoc of the top-level orca package. | ||
| package internal | ||
|
|
||
| import ibackoff "google.golang.org/grpc/internal/backoff" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this import to be renamed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't; I just like to keep things consistent, and we have a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Package names should ideally be self contained and self explanatory. If we are always going to rename this import, we should ideally rename the package itself. |
||
|
|
||
| // AllowAnyMinReportingInterval prevents clamping of the MinReportingInterval | ||
| // configured via ServiceOptions, to a minimum of 30s. | ||
| // | ||
| // For testing purposes only. | ||
| var AllowAnyMinReportingInterval interface{} // func(*ServiceOptions) | ||
|
|
||
| // DefaultBackoffFunc is used by the producer to control its backoff behavior. | ||
| // | ||
| // For testing purposes only. | ||
| var DefaultBackoffFunc = ibackoff.DefaultExponential.Backoff | ||
Uh oh!
There was an error while loading. Please reload this page.