Add a ReadLocations engine-side RPC function

This adds a ReadLocations RPC function to the engine interface, alongside
the singular ReadLocation.  The plural function takes a single token that
represents a module or class and we will then return all of the module
or class (static) properties that are currently known.
This commit is contained in:
joeduffy 2017-07-01 13:26:49 -07:00
parent 5d9f7918e9
commit 06ad983541
11 changed files with 500 additions and 36 deletions

View file

@ -28,19 +28,20 @@ var _ Symbol = (*Class)(nil)
var _ Type = (*Class)(nil)
var _ ModuleMember = (*Class)(nil)
func (node *Class) Name() tokens.Name { return tokens.Name(node.Nm) }
func (node *Class) Token() tokens.Token { return tokens.Token(node.Tok) }
func (node *Class) Special() bool { return false }
func (node *Class) Tree() diag.Diagable { return node.Node }
func (node *Class) moduleMember() {}
func (node *Class) MemberNode() ast.ModuleMember { return node.Node }
func (node *Class) MemberName() tokens.ModuleMemberName { return tokens.ModuleMemberName(node.Name()) }
func (node *Class) MemberParent() *Module { return node.Parent }
func (node *Class) typesym() {}
func (node *Class) Base() Type { return node.Extends }
func (node *Class) TypeName() tokens.TypeName { return node.Nm }
func (node *Class) TypeToken() tokens.Type { return node.Tok }
func (node *Class) TypeMembers() ClassMemberMap { return node.Members }
func (node *Class) Name() tokens.Name { return tokens.Name(node.Nm) }
func (node *Class) Token() tokens.Token { return tokens.Token(node.Tok) }
func (node *Class) Special() bool { return false }
func (node *Class) Tree() diag.Diagable { return node.Node }
func (node *Class) moduleMember() {}
func (node *Class) MemberNode() ast.ModuleMember { return node.Node }
func (node *Class) MemberName() tokens.ModuleMemberName { return tokens.ModuleMemberName(node.Name()) }
func (node *Class) MemberParent() *Module { return node.Parent }
func (node *Class) typesym() {}
func (node *Class) Base() Type { return node.Extends }
func (node *Class) TypeName() tokens.TypeName { return node.Nm }
func (node *Class) TypeToken() tokens.Type { return node.Tok }
func (node *Class) TypeMembers() ClassMemberMap { return node.Members }
func (node *Class) StableMembers() []tokens.ClassMemberName { return StableClassMemberMap(node.Members) }
func (node *Class) Ctor() Function {
if ctor, has := node.TypeMembers()[tokens.ClassConstructorFunction]; has {
ctormeth, ismeth := ctor.(*ClassMethod)

View file

@ -23,7 +23,10 @@ func (node *Module) Name() tokens.Name { return node.Node.Name.Ident }
func (node *Module) Token() tokens.Token { return tokens.Token(node.Tok) }
func (node *Module) Tree() diag.Diagable { return node.Node }
func (node *Module) Special() bool { return false }
func (node *Module) String() string { return string(node.Token()) }
func (node *Module) StableMembers() []tokens.ModuleMemberName {
return StableModuleMemberMap(node.Members)
}
func (node *Module) String() string { return string(node.Token()) }
// HasInit returns true if this module has an initialzer associated with it.
func (node *Module) HasInit() bool { return node.GetInit() != nil }

View file

@ -384,6 +384,9 @@ func (host *testProviderHost) Log(sev diag.Severity, msg string) {
func (host *testProviderHost) ReadLocation(tok tokens.Token) (resource.PropertyValue, error) {
return resource.PropertyValue{}, errors.New("Invalid location")
}
func (host *testProviderHost) ReadLocations(tok tokens.Token) (resource.PropertyMap, error) {
return nil, errors.New("Invalid location")
}
func (host *testProviderHost) Analyzer(nm tokens.QName) (plugin.Analyzer, error) {
return host.analyzer(nm)
}

View file

@ -6,6 +6,7 @@ import (
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/pulumi/lumi/pkg/compiler/symbols"
"github.com/pulumi/lumi/pkg/diag"
"github.com/pulumi/lumi/pkg/eval/rt"
"github.com/pulumi/lumi/pkg/resource"
@ -22,6 +23,8 @@ type Host interface {
Log(sev diag.Severity, msg string)
// ReadLocation reads the value from a static or module property.
ReadLocation(tok tokens.Token) (resource.PropertyValue, error)
// ReadLocations reads takes a class or module token and reads all (static) properties belonging to it.
ReadLocations(tok tokens.Token) (resource.PropertyMap, error)
// Analyzer fetches the analyzer with a given name, possibly lazily allocating the plugins for it. If an analyzer
// could not be found, or an error occurred while creating it, a non-nil error is returned.
@ -69,12 +72,14 @@ func (host *defaultHost) Log(sev diag.Severity, msg string) {
}
func (host *defaultHost) ReadLocation(tok tokens.Token) (resource.PropertyValue, error) {
// First lookup the symbol. If it's missing, just return nil, so that this is "dynamic-like".
e := host.ctx.E
sym := e.Ctx().LookupSymbol(nil, tok, false)
if sym == nil {
return resource.PropertyValue{}, errors.Errorf("Location '%v' was not found", tok)
return resource.NewNullProperty(), nil
}
// Next do a read of the location. This may trigger code (initializers), and so it might fail.
var obj *rt.Object
loc, uw := e.LoadLocation(nil, sym, nil, false)
if uw == nil {
@ -83,12 +88,49 @@ func (host *defaultHost) ReadLocation(tok tokens.Token) (resource.PropertyValue,
if uw != nil {
contract.Assert(uw.Throw())
return resource.PropertyValue{},
errors.Errorf("An error occurred reading location '%v': %v", tok, uw.Thrown().Message(host.ctx.Diag))
errors.Errorf("An error occurred reading property '%v': %v", tok, uw.Thrown().Message(host.ctx.Diag))
}
return resource.CopyObject(obj), nil
}
func (host *defaultHost) ReadLocations(tok tokens.Token) (resource.PropertyMap, error) {
props := make(resource.PropertyMap)
// First load up the class or module object. If missing, return an empty map.
e := host.ctx.E
sym := e.Ctx().LookupSymbol(nil, tok, false)
if sym == nil {
return props, nil
}
// Now, for each (static) property, read it and add it to the list.
switch t := sym.(type) {
case *symbols.Class:
for _, pname := range t.StableMembers() {
prop := t.Members[pname]
v, err := host.ReadLocation(prop.Token())
if err != nil {
return nil, err
}
props[resource.PropertyKey(pname)] = v
}
case *symbols.Module:
for _, pname := range t.StableMembers() {
prop := t.Members[pname]
v, err := host.ReadLocation(prop.Token())
if err != nil {
return nil, err
}
props[resource.PropertyKey(pname)] = v
}
default:
return nil, errors.Errorf("Only reads of class or module properties supported; '%v' is neither", tok)
}
return props, nil
}
func (host *defaultHost) Analyzer(name tokens.QName) (Analyzer, error) {
// First see if we already loaded this plugin.
if plug, has := host.analyzers[name]; has {

View file

@ -97,3 +97,18 @@ func (eng *hostServer) ReadLocation(ctx context.Context,
}
return m, nil
}
// ReadLocations reads takes a class or module token and reads all (static) properties belonging to it.
func (eng *hostServer) ReadLocations(ctx context.Context,
req *lumirpc.ReadLocationsRequest) (*lumirpc.ReadLocationsResponse, error) {
tok := tokens.Token(req.Token)
locs, err := eng.host.ReadLocations(tok)
if err != nil {
return nil, err
}
props, unks := MarshalPropertiesWithUnknowns(eng.ctx, locs, MarshalOptions{})
if len(unks) > 0 {
return nil, errors.Errorf("Location %v contained %v unknown computed value(s)", tok, len(unks))
}
return &lumirpc.ReadLocationsResponse{Properties: props}, nil
}

View file

@ -685,3 +685,9 @@ func (v PropertyValue) String() string {
// For all others, just display the underlying property value.
return fmt.Sprintf("{%v}", v.V)
}
// Property is a pair of key and value.
type Property struct {
Key PropertyKey
Value PropertyValue
}

View file

@ -65,7 +65,7 @@ func (host *HostClient) ReadLocation(tok tokens.Token) (resource.PropertyValue,
req := &lumirpc.ReadLocationRequest{Token: string(tok)}
resp, err := host.client.ReadLocation(context.TODO(), req)
if err != nil {
return resource.PropertyValue{}, nil
return resource.PropertyValue{}, err
}
return plugin.UnmarshalPropertyValue(nil, resp, plugin.MarshalOptions{}), nil
}
@ -134,3 +134,13 @@ func (host *HostClient) ReadObjectLocation(tok tokens.Token) (resource.PropertyM
}
return v.ObjectValue(), nil
}
// ReadLocations takes a class or module token and reads all of its statics or module properties.
func (host *HostClient) ReadLocations(tok tokens.Token) (resource.PropertyMap, error) {
req := &lumirpc.ReadLocationsRequest{Token: string(tok)}
resp, err := host.client.ReadLocations(context.TODO(), req)
if err != nil {
return nil, err
}
return plugin.UnmarshalProperties(nil, resp.GetProperties(), plugin.MarshalOptions{}), nil
}

View file

@ -16,6 +16,8 @@ It has these top-level messages:
AnalyzeFailure
LogRequest
ReadLocationRequest
ReadLocationsRequest
ReadLocationsResponse
CheckRequest
CheckResponse
CheckFailure

View file

@ -88,9 +88,43 @@ func (m *ReadLocationRequest) GetToken() string {
return ""
}
type ReadLocationsRequest struct {
Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"`
}
func (m *ReadLocationsRequest) Reset() { *m = ReadLocationsRequest{} }
func (m *ReadLocationsRequest) String() string { return proto.CompactTextString(m) }
func (*ReadLocationsRequest) ProtoMessage() {}
func (*ReadLocationsRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
func (m *ReadLocationsRequest) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
type ReadLocationsResponse struct {
Properties *google_protobuf.Struct `protobuf:"bytes,1,opt,name=properties" json:"properties,omitempty"`
}
func (m *ReadLocationsResponse) Reset() { *m = ReadLocationsResponse{} }
func (m *ReadLocationsResponse) String() string { return proto.CompactTextString(m) }
func (*ReadLocationsResponse) ProtoMessage() {}
func (*ReadLocationsResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
func (m *ReadLocationsResponse) GetProperties() *google_protobuf.Struct {
if m != nil {
return m.Properties
}
return nil
}
func init() {
proto.RegisterType((*LogRequest)(nil), "lumirpc.LogRequest")
proto.RegisterType((*ReadLocationRequest)(nil), "lumirpc.ReadLocationRequest")
proto.RegisterType((*ReadLocationsRequest)(nil), "lumirpc.ReadLocationsRequest")
proto.RegisterType((*ReadLocationsResponse)(nil), "lumirpc.ReadLocationsResponse")
proto.RegisterEnum("lumirpc.LogSeverity", LogSeverity_name, LogSeverity_value)
}
@ -109,6 +143,8 @@ type EngineClient interface {
Log(ctx context.Context, in *LogRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
// ReadLocation reads the value from a location identified by a token in the current program.
ReadLocation(ctx context.Context, in *ReadLocationRequest, opts ...grpc.CallOption) (*google_protobuf.Value, error)
// ReadLocations reads a list of static or module variables from a single parent token.
ReadLocations(ctx context.Context, in *ReadLocationsRequest, opts ...grpc.CallOption) (*ReadLocationsResponse, error)
}
type engineClient struct {
@ -137,6 +173,15 @@ func (c *engineClient) ReadLocation(ctx context.Context, in *ReadLocationRequest
return out, nil
}
func (c *engineClient) ReadLocations(ctx context.Context, in *ReadLocationsRequest, opts ...grpc.CallOption) (*ReadLocationsResponse, error) {
out := new(ReadLocationsResponse)
err := grpc.Invoke(ctx, "/lumirpc.Engine/ReadLocations", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Engine service
type EngineServer interface {
@ -144,6 +189,8 @@ type EngineServer interface {
Log(context.Context, *LogRequest) (*google_protobuf1.Empty, error)
// ReadLocation reads the value from a location identified by a token in the current program.
ReadLocation(context.Context, *ReadLocationRequest) (*google_protobuf.Value, error)
// ReadLocations reads a list of static or module variables from a single parent token.
ReadLocations(context.Context, *ReadLocationsRequest) (*ReadLocationsResponse, error)
}
func RegisterEngineServer(s *grpc.Server, srv EngineServer) {
@ -186,6 +233,24 @@ func _Engine_ReadLocation_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Engine_ReadLocations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ReadLocationsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EngineServer).ReadLocations(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/lumirpc.Engine/ReadLocations",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EngineServer).ReadLocations(ctx, req.(*ReadLocationsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Engine_serviceDesc = grpc.ServiceDesc{
ServiceName: "lumirpc.Engine",
HandlerType: (*EngineServer)(nil),
@ -198,6 +263,10 @@ var _Engine_serviceDesc = grpc.ServiceDesc{
MethodName: "ReadLocation",
Handler: _Engine_ReadLocation_Handler,
},
{
MethodName: "ReadLocations",
Handler: _Engine_ReadLocations_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "engine.proto",
@ -206,23 +275,27 @@ var _Engine_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("engine.proto", fileDescriptor1) }
var fileDescriptor1 = []byte{
// 287 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x90, 0x4f, 0x4b, 0xc3, 0x40,
0x10, 0xc5, 0x93, 0xd6, 0x36, 0xcd, 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xd1, 0x0f, 0x7e, 0xfc,
0x87, 0xb5, 0xbe, 0x92, 0xa1, 0x90, 0x3e, 0xd4, 0xd2, 0xeb, 0x90, 0xd6, 0xb6, 0x3c, 0x43, 0x60,
0x46, 0x9f, 0x47, 0x67, 0x11, 0xa2, 0xa1, 0x90, 0x09, 0xfc, 0xff, 0xa6, 0x85, 0x1c, 0x67, 0x36,
0x4a, 0xe4, 0xea, 0x27, 0xbf, 0xc5, 0xb1, 0x4d, 0x43, 0x99, 0x15, 0xa3, 0x19, 0x97, 0x5f, 0x01,
0x00, 0x00, 0xff, 0xff, 0xa5, 0xfe, 0x5a, 0xba, 0x78, 0x02, 0x00, 0x00,
}

View file

@ -14,6 +14,8 @@ var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_
goog.exportSymbol('proto.lumirpc.LogRequest', null, global);
goog.exportSymbol('proto.lumirpc.LogSeverity', null, global);
goog.exportSymbol('proto.lumirpc.ReadLocationRequest', null, global);
goog.exportSymbol('proto.lumirpc.ReadLocationsRequest', null, global);
goog.exportSymbol('proto.lumirpc.ReadLocationsResponse', null, global);
/**
* Generated by JsPbCodeGenerator.
@ -321,6 +323,303 @@ proto.lumirpc.ReadLocationRequest.prototype.setToken = function(value) {
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.lumirpc.ReadLocationsRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.lumirpc.ReadLocationsRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.lumirpc.ReadLocationsRequest.displayName = 'proto.lumirpc.ReadLocationsRequest';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.lumirpc.ReadLocationsRequest.prototype.toObject = function(opt_includeInstance) {
return proto.lumirpc.ReadLocationsRequest.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.lumirpc.ReadLocationsRequest} msg The msg instance to transform.
* @return {!Object}
*/
proto.lumirpc.ReadLocationsRequest.toObject = function(includeInstance, msg) {
var f, obj = {
token: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.lumirpc.ReadLocationsRequest}
*/
proto.lumirpc.ReadLocationsRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.lumirpc.ReadLocationsRequest;
return proto.lumirpc.ReadLocationsRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.lumirpc.ReadLocationsRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.lumirpc.ReadLocationsRequest}
*/
proto.lumirpc.ReadLocationsRequest.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setToken(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.lumirpc.ReadLocationsRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.lumirpc.ReadLocationsRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.lumirpc.ReadLocationsRequest} message
* @param {!jspb.BinaryWriter} writer
*/
proto.lumirpc.ReadLocationsRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getToken();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
};
/**
* optional string token = 1;
* @return {string}
*/
proto.lumirpc.ReadLocationsRequest.prototype.getToken = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.lumirpc.ReadLocationsRequest.prototype.setToken = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.lumirpc.ReadLocationsResponse = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.lumirpc.ReadLocationsResponse, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.lumirpc.ReadLocationsResponse.displayName = 'proto.lumirpc.ReadLocationsResponse';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.lumirpc.ReadLocationsResponse.prototype.toObject = function(opt_includeInstance) {
return proto.lumirpc.ReadLocationsResponse.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.lumirpc.ReadLocationsResponse} msg The msg instance to transform.
* @return {!Object}
*/
proto.lumirpc.ReadLocationsResponse.toObject = function(includeInstance, msg) {
var f, obj = {
properties: (f = msg.getProperties()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.lumirpc.ReadLocationsResponse}
*/
proto.lumirpc.ReadLocationsResponse.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.lumirpc.ReadLocationsResponse;
return proto.lumirpc.ReadLocationsResponse.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.lumirpc.ReadLocationsResponse} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.lumirpc.ReadLocationsResponse}
*/
proto.lumirpc.ReadLocationsResponse.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new google_protobuf_struct_pb.Struct;
reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader);
msg.setProperties(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.lumirpc.ReadLocationsResponse.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.lumirpc.ReadLocationsResponse.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.lumirpc.ReadLocationsResponse} message
* @param {!jspb.BinaryWriter} writer
*/
proto.lumirpc.ReadLocationsResponse.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getProperties();
if (f != null) {
writer.writeMessage(
1,
f,
google_protobuf_struct_pb.Struct.serializeBinaryToWriter
);
}
};
/**
* optional google.protobuf.Struct properties = 1;
* @return {?proto.google.protobuf.Struct}
*/
proto.lumirpc.ReadLocationsResponse.prototype.getProperties = function() {
return /** @type{?proto.google.protobuf.Struct} */ (
jspb.Message.getWrapperField(this, google_protobuf_struct_pb.Struct, 1));
};
/** @param {?proto.google.protobuf.Struct|undefined} value */
proto.lumirpc.ReadLocationsResponse.prototype.setProperties = function(value) {
jspb.Message.setWrapperField(this, 1, value);
};
proto.lumirpc.ReadLocationsResponse.prototype.clearProperties = function() {
this.setProperties(undefined);
};
/**
* Returns whether this field is set.
* @return {!boolean}
*/
proto.lumirpc.ReadLocationsResponse.prototype.hasProperties = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* @enum {number}
*/

View file

@ -13,6 +13,8 @@ service Engine {
rpc Log(LogRequest) returns (google.protobuf.Empty) {}
// ReadLocation reads the value from a location identified by a token in the current program.
rpc ReadLocation(ReadLocationRequest) returns (google.protobuf.Value) {}
// ReadLocations reads a list of static or module variables from a single parent token.
rpc ReadLocations(ReadLocationsRequest) returns (ReadLocationsResponse) {}
}
// LogSeverity is the severity level of a log message. Errors are fatal; all others are informational.
@ -32,3 +34,11 @@ message ReadLocationRequest {
string token = 1; // the static or module variable whose value to read.
}
message ReadLocationsRequest {
string token = 1; // the class or module token whose static or property values to read.
}
message ReadLocationsResponse {
google.protobuf.Struct properties = 1; // the resulting static or module properties.
}