pulumi/sdk/proto/engine.proto

84 lines
3.1 KiB
Protocol Buffer
Raw Normal View History

2018-05-22 21:43:36 +02:00
// Copyright 2016-2018, Pulumi Corporation.
//
// 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";
import "google/protobuf/empty.proto";
package pulumirpc;
// Engine is an auxiliary service offered to language and resource provider plugins. Its main purpose today is
// to serve as a common logging endpoint, but it also serves as a state storage mechanism for language hosts
// that can't store their own global state.
service Engine {
// Log logs a global message in the engine, including errors and warnings.
rpc Log(LogRequest) returns (google.protobuf.Empty) {}
// GetRootResource gets the URN of the root resource, the resource that should be the root of all
// otherwise-unparented resources.
rpc GetRootResource(GetRootResourceRequest) returns (GetRootResourceResponse) {}
// SetRootResource sets the URN of the root resource.
rpc SetRootResource(SetRootResourceRequest) returns (SetRootResourceResponse) {}
Implement initial Lumi-as-a-library This is the initial step towards redefining Lumi as a library that runs atop vanilla Node.js/V8, rather than as its own runtime. This change is woefully incomplete but this includes some of the more stable pieces of my current work-in-progress. The new structure is that within the sdk/ directory we will have a client library per language. This client library contains the object model for Lumi (resources, properties, assets, config, etc), in addition to the "language runtime host" components required to interoperate with the Lumi resource monitor. This resource monitor is effectively what we call "Lumi" today, in that it's the thing orchestrating plans and deployments. Inside the sdk/ directory, you will find nodejs/, the Node.js client library, alongside proto/, the definitions for RPC interop between the different pieces of the system. This includes existing RPC definitions for resource providers, etc., in addition to the new ones for hosting different language runtimes from within Lumi. These new interfaces are surprisingly simple. There is effectively a bidirectional RPC channel between the Lumi resource monitor, represented by the lumirpc.ResourceMonitor interface, and each language runtime, represented by the lumirpc.LanguageRuntime interface. The overall orchestration goes as follows: 1) Lumi decides it needs to run a program written in language X, so it dynamically loads the language runtime plugin for language X. 2) Lumi passes that runtime a loopback address to its ResourceMonitor service, while language X will publish a connection back to its LanguageRuntime service, which Lumi will talk to. 3) Lumi then invokes LanguageRuntime.Run, passing information like the desired working directory, program name, arguments, and optional configuration variables to make available to the program. 4) The language X runtime receives this, unpacks it and sets up the necessary context, and then invokes the program. The program then calls into Lumi object model abstractions that internally communicate back to Lumi using the ResourceMonitor interface. 5) The key here is ResourceMonitor.NewResource, which Lumi uses to serialize state about newly allocated resources. Lumi receives these and registers them as part of the plan, doing the usual diffing, etc., to decide how to proceed. This interface is perhaps one of the most subtle parts of the new design, as it necessitates the use of promises internally to allow parallel evaluation of the resource plan, letting dataflow determine the available concurrency. 6) The program exits, and Lumi continues on its merry way. If the program fails, the RunResponse will include information about the failure. Due to (5), all properties on resources are now instances of a new Property<T> type. A Property<T> is just a thin wrapper over a T, but it encodes the special properties of Lumi resource properties. Namely, it is possible to create one out of a T, other Property<T>, Promise<T>, or to freshly allocate one. In all cases, the Property<T> does not "settle" until its final state is known. This cannot occur before the deployment actually completes, and so in general it's not safe to depend on concrete resolutions of values (unlike ordinary Promise<T>s which are usually expected to resolve). As a result, all derived computations are meant to use the `then` function (as in `someValue.then(v => v+x)`). Although this change includes tests that may be run in isolation to test the various RPC interactions, we are nowhere near finished. The remaining work primarily boils down to three things: 1) Wiring all of this up to the Lumi code. 2) Fixing the handful of known loose ends required to make this work, primarily around the serialization of properties (waiting on unresolved ones, serializing assets properly, etc). 3) Implementing lambda closure serialization as a native extension. This ongoing work is part of pulumi/pulumi-fabric#311.
2017-08-26 21:07:54 +02:00
}
// LogSeverity is the severity level of a log message. Errors are fatal; all others are informational.
enum LogSeverity {
DEBUG = 0; // a debug-level message not displayed to end-users (the default).
INFO = 1; // an informational message printed to output during resource operations.
WARNING = 2; // a warning to indicate that something went wrong.
ERROR = 3; // a fatal error indicating that the tool should stop processing subsequent resource operations.
}
message LogRequest {
// the logging level of this message.
LogSeverity severity = 1;
// the contents of the logged message.
string message = 2;
// the (optional) resource urn this log is associated with.
string urn = 3;
// the (optional) stream id that a stream of log messages can be associated with. This allows
// clients to not have to buffer a large set of log messages that they all want to be
// conceptually connected. Instead the messages can be sent as chunks (with the same stream id)
// and the end display can show the messages as they arrive, while still stitching them together
// into one total log message.
//
// 0/not-given means: do not associate with any stream.
int32 streamId = 4;
// Optional value indicating whether this is a status message.
bool ephemeral = 5;
}
message GetRootResourceRequest {
// empty.
}
message GetRootResourceResponse {
// the URN of the root resource, or the empty string if one was not set.
string urn = 1;
}
message SetRootResourceRequest {
// the URN of the root resource, or the empty string.
string urn = 1;
}
message SetRootResourceResponse {
// empty.
}