Skip to content

Commit 2df567a

Browse files
Martin Taillefergeeknoid
Martin Taillefer
authored andcommitted
Update quota surface to support prefetching.
Also includes attribute protocol definitions for 'duration'
1 parent 5b56d70 commit 2df567a

File tree

3 files changed

+23
-40
lines changed

3 files changed

+23
-40
lines changed

mixer/v1/attributes.proto

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package istio.mixer.v1;
1818

19+
import "google/protobuf/duration.proto";
1920
import "google/protobuf/timestamp.proto";
2021

2122
// An instance of this message is delivered to the mixer with every
@@ -98,9 +99,10 @@ message Attributes {
9899
map<int32, double> double_attributes = 6;
99100
map<int32, bool> bool_attributes = 7;
100101
map<int32, google.protobuf.Timestamp> timestamp_attributes = 8;
101-
map<int32, bytes> bytes_attributes = 9;
102+
map<int32, google.protobuf.Duration> duration_attributes = 9;
103+
map<int32, bytes> bytes_attributes = 10;
102104

103105
// Attributes that should be removed from the specified attribute context. Deleting
104106
// attributes which aren't currently in the attribute context is not considered an error.
105-
repeated int32 deleted_attributes = 10;
107+
repeated int32 deleted_attributes = 11;
106108
}

mixer/v1/config/descriptor/quota_descriptor.proto

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ syntax = "proto3";
1616

1717
package istio.mixer.v1.config.descriptor;
1818

19+
import "google/protobuf/duration.proto";
20+
import "mixer/v1/config/descriptor/label_descriptor.proto";
21+
1922
// Configuration state for a particular quota.
2023
//
2124
// Quotas are similar to metrics, except that they are mutated through method
@@ -26,34 +29,25 @@ package istio.mixer.v1.config.descriptor;
2629
// A given quota is described by a set of attributes. These attributes represent
2730
// the different dimensions to associate with the quota. A given quota holds a
2831
// unique value for potentially any combination of these attributes.
29-
//
30-
// The quota kind controls the general behavior of the quota. An allocation
31-
// quota is only adjusted through explicit method calls. A rate limit quota's
32-
// values are reset to 0 automatically at a fixed interval.
3332
message QuotaDescriptor {
3433
// The name of this descriptor.
3534
string name = 1;
3635

37-
// A optional concise name for the quota, which can be displayed in user interfaces.
38-
// Use sentence case without an ending period, for example "Request count".
36+
// An optional concise name for the quota which can be displayed in user interfaces.
3937
string display_name = 2;
4038

41-
// An optional description of the quota, which can be used in documentation.
39+
// An optional description of the quota which can be used in documentation.
4240
string description = 3;
4341

44-
// The name of the attribute that supplies the amount for a given
45-
// quota allocation or release operation.
46-
string amount_attribute = 4;
47-
48-
// The set of attributes that are necessary to describe a specific value cell
42+
// The set of labels that are necessary to describe a specific value cell
4943
// for a quota of this type.
50-
repeated string attributes = 5;
44+
repeated LabelDescriptor labels = 4;
5145

5246
// The default imposed maximum amount for values of this quota.
53-
int64 max_amount = 6;
47+
int64 max_amount = 5;
5448

5549
// The amount of time allocated quota remains valid before it is
5650
// automatically released. If this is 0, then allocated quota is
5751
// not automatically released.
58-
int32 expiration_seconds = 7;
52+
google.protobuf.Duration expiration = 6;
5953
}

mixer/v1/quota.proto

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ syntax = "proto3";
1616

1717
package istio.mixer.v1;
1818

19-
import "google/rpc/status.proto";
19+
import "google/protobuf/duration.proto";
20+
import "google/protobuf/timestamp.proto";
2021
import "mixer/v1/attributes.proto";
2122

2223
message QuotaRequest {
@@ -28,32 +29,18 @@ message QuotaRequest {
2829

2930
// Used for deduplicating quota allocation/free calls in the case of
3031
// failed RPCs and retries. This should be a UUID per call, where the same
31-
// UUID is used for retries of the same quota allocation or release call.
32-
string deduplication_id = 4;
33-
34-
enum OperationKind {
35-
QUOTA_MODE_UNSPECIFIED = 0;
36-
37-
// Allocate the specified amount, fail if insufficient resources available.
38-
ALLOC_NORMAL = 1;
39-
40-
// Allocate from 0 to the specified amount, never fails.
41-
ALLOC_BEST_EFFORT = 2;
42-
43-
// Release from 0 to the specified amount, never fails.
44-
RELEASE_BEST_EFFORT = 3;
45-
}
32+
// UUID is used for retries of the same quota allocation call.
33+
string deduplication_id = 3;
4634
}
4735

48-
// Used to update quota values before and/or after performing an action.
49-
//
50-
// A common use case for quotas is to implement rate limits within a service.
51-
// Quotas can also be used to impose upper limits on the number of specific
52-
// resources exposed by a service to its consumers.
5336
message QuotaResponse {
5437
// Index of the request this response is associated with
5538
int64 request_index = 1;
5639

57-
// Indicates whether or not the quota operation succeeded.
58-
google.rpc.Status result = 2;
40+
// The time at which the returned quota expires
41+
google.protobuf.Timestamp expiration = 2;
42+
43+
// The total amount of quota returned, can be used to satisfy
44+
// quota requests with matching attributes until the given expiration time.
45+
int64 amount = 3;
5946
}

0 commit comments

Comments
 (0)