Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarjog committed Jun 20, 2017
1 parent 69c7618 commit 4d671ad
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 132 deletions.
143 changes: 11 additions & 132 deletions galley/v1/service.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2017 Istio Authors
// vim: set expandtab ts=2 sw=2:
// 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
Expand All @@ -16,21 +15,20 @@ syntax = "proto3";

package istio.galley.v1;

import "google/rpc/status.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";

// Galley follows
// the Kubenertes API server delegation and resource model.
// /apiGroup/version/objecttype/{namespace}/objectname -->
// /apiGroup/version/objecttype/{namespace}/objectname
//
// It generalizes the concept of namespace to an arbitrary grouping.
//
// /apiGroup//objecttype/version/{objectGroup}/objectname
// /apiGroup/objecttype/version/{objectGroup}/objectname
//
// api_group = /core/
// api_group = /vendor1
// apiGroup = /core/
// apiGroup = /vendor1
service Galley {
// Get a single object.
rpc GetObject(GetObjectRequest) returns (ConfigObject) {
Expand Down Expand Up @@ -90,35 +88,18 @@ service Galley {
};
};


// Watcher service is designed to efficiently watch mutiple subtrees of the resource tree.
service Watcher {
// Watch watches for events happening or that have happened. Both input and output
// are streams; the input stream is for creating and cancelling watchers and the output
// stream sends events. One watch RPC can watch on multiple key roots, streaming events
// for several watches at once.
// The watch creation call will result in returning the current state of the subtree.
rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
option (google.api.http) = {
post: "/events/v1:watch"
body: "*"
};
};
};


// Object validator service validates objects before they are committed to storage.
// Galley maintains a map of object_types to validators. A single validator may validate many types.
// For example MixerValidator Service should validate all Mixer resources.
service ObjectValidatorAndConverter {
service ObjectValidatorAndTransformer {
// Validate the resource and convert it to typed proto if applicable
// if Object.source_data is specified, it should be converted
// to the appropriate proto representation.
// Every attempt should be made to do a deep validation.
// If full validation requires referential integrity checks, this service should use the
// GalleyWatch Service to maintain current view of configuration.
//
// For example A Mixer rule consists of a selector expression and a named handler amongst other things.
// For example a Mixer rule consists of a selector expression and a named handler amongst other things.
// Mixer validator should check
// 1. expression syntax is valid
// 2. expression uses known attributes
Expand All @@ -128,7 +109,7 @@ service ObjectValidatorAndConverter {
// It should convert untyped proto into typed proto and return binary encoding of it in Object.data.
//
// On validation failure, it should return a validation error with text.
rpc ValidateAndConvert(ValidationRequest) returns (ConfigObject) {
rpc ValidateAndTransform(ValidationRequest) returns (ConfigObject) {
option (google.api.http) = {
post: "/resources/v1:validate"
body: "*"
Expand Down Expand Up @@ -191,7 +172,10 @@ message ObjectRequest {
// source_data is the data as it was specified in json / yaml format.
google.protobuf.Struct source_data = 2;

// data is protos encoded as bytes.
// data is the binary encoded protobuf data
// For example:
// If `source_data` contains an expressions in text form
// `data` may contain a parsed AST
bytes data = 3;
}

Expand All @@ -214,7 +198,6 @@ message ConfigObject {
google.protobuf.Struct source_data = 2;

// data is the binary encoded protobuf data
// Both representations are useful.
// For example:
// If `source_data` contains an expressions in text form
// `data` may contain a parsed AST
Expand Down Expand Up @@ -278,107 +261,3 @@ message Meta {
map<string, string> labels = 8;
}

// WatchRequest creates on cancels a watch.
// Create and cancel are part of the same message because the WatchRequest message
// is used in a streaming API. The client may add new watchers and remove old watchers
// on an existing stream.
message WatchRequest {
// request_union indicates whether to create a new watcher or cancel an existing watcher.
oneof request_union {
WatchCreateRequest create_request = 1;
WatchCancelRequest cancel_request = 2;
}
}

message WatchCreateRequest {
// used to identify the watched subtree
Meta subtree = 1;

// start watching from this revision of the repository.
// If the requested revision is not available, the watch request should fail.
// if not specified "now" is used.
int64 start_revision = 2;
}

message WatchCancelRequest {
// watch_id is the watcher id to cancel so that no more events are transmitted.
int64 watch_id = 1;
}

// Indicates that watch was successfully canceled.
message WatchCanceled {
}

// Indicates that a watch was successfully created.
message WatchCreated {
// returns the initial_state of the specified subtree. Watch stream will begin
// at the revision.
repeated ConfigObject initial_state = 1;

// Revision of the repository when the initial state was produced.
int64 current_revision = 2;
}

// WatchEvents indicates that this message contains events from the watch stream.
message WatchEvents {
// returns events for the specified watch id.
repeated Event events = 4;
}

// WatchProgress message is sent periodically.
message WatchProgress {
// Revision of the repository when this event was sent.
int64 current_revision = 1;
}


// The client should WatchResponse
message WatchResponse {
// watch_id is the ID of the watcher that corresponds to the response.
// watch_id does not apply to the unsolicited "Progress" message.
int64 watch_id = 1;

// if a watcher could not be created or had to be aborted status is NON-OK.
// client should not look at other fields if status is not OK and remove
// watch_id from the watch set.
google.rpc.Status status = 2;

oneof response_union {
// Watch was successfully created. Client should record the watch_id for this watch.
// The response also contains the current state of the watched subtree.
WatchCreated created = 3;

// response contains events from a watched subtree.
WatchEvents events = 4;

// a previous watch was successfully canceled.
// No further events will be sent to the canceled watcher.
WatchCanceled canceled = 5;

// Server sends periodic messages of progress when no actual watches fire.
// The client knows it is caught up to a certain revision of the repository.
WatchProgress progress = 6;
};
};


message Event {
enum EventType {
PUT = 0; // ADD and UPDATE
DELETE = 1;
}
// type is the kind of event. If type is a PUT, it indicates
// new data has been stored to the key. If type is a DELETE,
// it indicates the key was deleted.
EventType type = 1;

// kv holds the KeyValue for the event.
// A PUT event contains current kv pair.
// A PUT event with kv.Version=1 indicates the creation of a key.
// A DELETE event contains the deleted key with
// its modification revision set to the revision of deletion.
ConfigObject kv = 2;

// prev_kv holds the key-value pair before the event happens.
ConfigObject prev_kv = 3;
}
142 changes: 142 additions & 0 deletions galley/v1/watcher.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright 2017 Istio 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.

syntax = "proto3";

package istio.galley.v1;

import "google/rpc/status.proto";
import "google/api/annotations.proto";

import "service.proto";

// Galley Watcher service is designed to efficiently watch mutiple subtrees of the resource tree.
service Watcher {
// Watch watches for events happening or that have happened. Both input and output
// are streams; the input stream is for creating and cancelling watchers and the output
// stream sends events. One watch RPC can watch on multiple key roots, streaming events
// for several watches at once.
// The watch creation call will result in returning the current state of the subtree.
rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
option (google.api.http) = {
post: "/events/v1:watch"
body: "*"
};
};
};


// WatchRequest creates on cancels a watch.
// Create and cancel are part of the same message because the WatchRequest message
// is used in a streaming API. The client may add new watchers and remove old watchers
// on an existing stream.
message WatchRequest {
// request_union indicates whether to create a new watcher or cancel an existing watcher.
oneof request_union {
WatchCreateRequest create_request = 1;
WatchCancelRequest cancel_request = 2;
}
}

message WatchCreateRequest {
// used to identify the watched subtree
Meta subtree = 1;

// start watching from this revision of the repository.
// If the requested revision is not available, the watch request should fail.
// if not specified "now" is used.
int64 start_revision = 2;
}

message WatchCancelRequest {
// watch_id is the watcher id to cancel so that no more events are transmitted.
int64 watch_id = 1;
}

// Indicates that watch was successfully canceled.
message WatchCanceled {
}

// Indicates that a watch was successfully created.
message WatchCreated {
// returns the initial_state of the specified subtree. Watch stream will begin
// at the revision.
repeated ConfigObject initial_state = 1;

// Revision of the repository when the initial state was produced.
int64 current_revision = 2;
}

// WatchEvents indicates that this message contains events from the watch stream.
message WatchEvents {
// returns events for the specified watch id.
repeated Event events = 4;
}

// WatchProgress message is sent periodically.
message WatchProgress {
// Revision of the repository when this event was sent.
int64 current_revision = 1;
}


// The client should WatchResponse
message WatchResponse {
// watch_id is the ID of the watcher that corresponds to the response.
// watch_id does not apply to the unsolicited "Progress" message.
int64 watch_id = 1;

// if a watcher could not be created or had to be aborted status is NON-OK.
// client should not look at other fields if status is not OK and remove
// watch_id from the watch set.
google.rpc.Status status = 2;

oneof response_union {
// Watch was successfully created. Client should record the watch_id for this watch.
// The response also contains the current state of the watched subtree.
WatchCreated created = 3;

// response contains events from a watched subtree.
WatchEvents events = 4;

// a previous watch was successfully canceled.
// No further events will be sent to the canceled watcher.
WatchCanceled canceled = 5;

// Server sends periodic messages of progress when no actual watches fire.
// The client knows it is caught up to a certain revision of the repository.
WatchProgress progress = 6;
};
};


message Event {
enum EventType {
PUT = 0; // ADD and UPDATE
DELETE = 1;
}
// type is the kind of event. If type is a PUT, it indicates
// new data has been stored to the key. If type is a DELETE,
// it indicates the key was deleted.
EventType type = 1;

// kv holds the KeyValue for the event.
// A PUT event contains current kv pair.
// A PUT event with kv.Version=1 indicates the creation of a key.
// A DELETE event contains the deleted key with
// its modification revision set to the revision of deletion.
ConfigObject kv = 2;

// prev_kv holds the key-value pair before the event happens.
ConfigObject prev_kv = 3;
}

0 comments on commit 4d671ad

Please sign in to comment.