Go to file
joeduffy 200fecbbaa 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-09-04 11:35:20 -07:00
cmd Adopt github.com/pkg/errors in a few more places 2017-08-31 10:28:20 -07:00
docs Rename pulumi/lumi to pulumi/pulumi-fabric 2017-08-02 09:25:22 -07:00
examples Run integration tests 2017-08-06 08:26:20 -07:00
lib Add support for serializaing captured arrays 2017-08-19 13:34:47 -07:00
pkg Avoid concurrent map updates in default sink 2017-08-31 14:36:19 -07:00
scripts Make install_release.sh script executable 2017-07-24 22:54:42 -07:00
sdk Implement initial Lumi-as-a-library 2017-09-04 11:35:20 -07:00
.gitignore Revert "The Go vendoring saga continues" 2017-08-01 17:51:38 -07:00
.gitmodules Remove stale submodules 2017-05-15 10:33:22 -07:00
.travis.yml Adopt Go 1.9 in Travis 2017-09-02 12:10:28 -07:00
CONTRIBUTING.md Redirect to the main Pulumi repo's CONTRIBUTING.md 2017-08-02 07:49:47 -07:00
Gometalinter.json Disable aligncheck linter 2017-08-30 16:47:33 -07:00
Gopkg.lock Convert to Dep 2017-08-01 18:37:06 -07:00
Gopkg.toml Convert to Dep 2017-08-01 18:37:06 -07:00
LICENSE Clarify aspects of using the DCO 2017-06-26 14:46:34 -07:00
Makefile Fix Makefile on Fedora 2017-08-24 18:09:37 -07:00
README.md Rename pulumi/lumi to pulumi/pulumi-fabric 2017-08-02 09:25:22 -07:00
tslint.json Added specified changes 2017-06-09 12:51:31 -07:00

Build Status

Lumi

Lumi is a framework and toolset for creating reusable cloud services.

If you are learning about Lumi for the first time, please see the overview document.

Installing

To install Lumi from source, simply run:

$ go get -u github.com/pulumi/pulumi-fabric/cmd/lumi

A GOPATH must be set. A good default value is ~/go. In fact, this is the default in Go 1.8.

This installs the lumi binary to $GOPATH/bin.

At this moment, libraries must be manually installed. See below. Eventually we will have an installer.

Compilers

The Lumi compilers are independent from the core Lumi tools.

Please see the respective pages for details on how to install, build, and test each compiler:

Development

This section is for Lumi developers.

Prerequisites

Lumi is written in Go, uses Dep for dependency management, and GoMetaLinter for linting:

Building and Testing

To build Lumi, ensure $GOPATH is set, and clone into a standard Go workspace:

$ git clone git@github.com:pulumi/pulumi-fabric $GOPATH/src/github.com/pulumi/pulumi-fabric
$ cd $GOPATH/src/github.com/pulumi/pulumi-fabric

Before building, you will need to ensure dependencies have been restored to your enlistment:

$ dep ensure

At this point you can run make to build and run tests:

$ make

This installs the lumi binary into $GOPATH/bin, which may now be run provided make exited successfully.

The Makefile also supports just running tests (make test), just running the linter (make lint), just running Govet (make vet), and so on. Please just refer to the Makefile for the full list of targets.

Installing the Runtime Libraries

By default, Lumi looks for its runtime libraries underneath /usr/local/lumi. $LUMIPATH overrides this. Please refer to the libraries README for details on additional installation requirements.

Debugging

The Lumi tools have extensive logging built in. In fact, we encourage liberal logging in new code, and adding new logging when debugging problems. This helps to ensure future debugging endeavors benefit from your sleuthing.

All logging is done using Google's Glog library. It is relatively bare-bones, and adds basic leveled logging, stack dumping, and other capabilities beyond what Go's built-in logging routines offer.

The Lumi command line has two flags that control this logging and that can come in handy when debugging problems. The --logtostderr flag spews directly to stderr, rather than the default of logging to files in your temp directory. And the --verbose=n flag (-v=n for short) sets the logging level to n. Anything greater than 3 is reserved for debug-level logging, greater than 5 is going to be quite verbose, and anything beyond 7 is extremely noisy.

For example, the command

$ lumi eval --logtostderr -v=5

is a pretty standard starting point during debugging that will show a fairly comprehensive trace log of a compilation.