Documentation ¶
Overview ¶
Package rpc contains a concurrent RPC client, and handles mapping to/from the Any-typed request details so other packages do not have to concern themselves with those details.
Package rpc is a generated GoMock package.
Index ¶
- func AggregatorWeightsToAny(response map[algorithm.Limit]algorithm.HostUsage) (*types.Any, error)
- func AnyToAggregatorUpdate(request *types.Any) (algorithm.UpdateParams, error)
- func TestAnyToWeights(t *testing.T, response *types.Any) (map[shared.GlobalKey]UpdateEntry, error)
- func TestUpdateToAny(t *testing.T, host string, elapsed time.Duration, ...) (*types.Any, error)
- type Calls
- type Client
- type MockClient
- type MockClientMockRecorder
- type RPCError
- type SerializationError
- type UpdateEntry
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregatorWeightsToAny ¶
AggregatorWeightsToAny converts the algorithm.RequestWeighted.HostWeights response (for an in-bound Update request) to an Any-type compatible with RPC.
func AnyToAggregatorUpdate ¶
func AnyToAggregatorUpdate(request *types.Any) (algorithm.UpdateParams, error)
AnyToAggregatorUpdate converts an in-bound ratelimiter's Any-typed data to the structure that algorithm.RequestWeighted.Update expects.
func TestAnyToWeights ¶
TestAnyToWeights is exposed for handler tests, use anyToWeights in internal code instead
Types ¶
type Client ¶
type Client interface { // Update performs concurrent calls to all aggregating peers to send load info // and retrieve new per-key weights from the rest of the cluster. // This is intended to be called periodically in the background per process, // not synchronously or concurrently (per set of keys anyway), as it is fairly // high cost to shard keys and send so many requests. // // Currently, there are no truly fatal errors so this API does not return `error`. // Even in the presence of errors, some successful data may have been loaded, // and that will be part of the UpdateResult struct. Update(ctx context.Context, period time.Duration, load map[shared.GlobalKey]Calls) UpdateResult }
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface.
func NewMockClient ¶
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (*MockClient) EXPECT ¶
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockClientMockRecorder ¶
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient.
func (*MockClientMockRecorder) Update ¶
func (mr *MockClientMockRecorder) Update(ctx, period, load interface{}) *gomock.Call
Update indicates an expected call of Update.
type RPCError ¶
type RPCError struct {
// contains filtered or unexported fields
}
RPCError wraps errors to mark them as coming from RPC, i.e. basically expected.
type SerializationError ¶
type SerializationError struct {
// contains filtered or unexported fields
}
SerializationError wraps errors to mark them as coming from (de)serialization.
In practice this should not ever occur, as it should imply one of: - incorrect Any Value/ValueType pairing, which should not pass tests - non-backwards-compatible type changes deployed in an unsafe way - incompatible Thrift-binary changes
func (*SerializationError) Error ¶
func (e *SerializationError) Error() string
func (*SerializationError) Unwrap ¶
func (e *SerializationError) Unwrap() error
type UpdateEntry ¶ added in v1.2.13
type UpdateResult ¶
type UpdateResult struct { // all successfully-returned weights. // this may be populated and is safe to use even if Errors is present, // as some shards may have succeeded. Weights map[shared.GlobalKey]UpdateEntry // Any unexpected errors encountered, or nil if none. // Weights is valid even if this is present, though it may be empty. // // This should always be nil aside from major programming or rollout // errors, e.g. failures to serialize or deserialize data (coding errors // or incompatible server versions). Err error }
UpdateResult holds all successes and errors encountered, to be distinct from fatal errors that imply unusable results (i.e. a normal error return).