Skip to content

Instantly share code, notes, and snippets.

@AdrianRossouw
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdrianRossouw/c3fb48e56c696395ebdf to your computer and use it in GitHub Desktop.
Save AdrianRossouw/c3fb48e56c696395ebdf to your computer and use it in GitHub Desktop.
Graft.io: full-stack js-based microservices

There are some really big changes that are starting to unfold across the web ecosystem in the next few months, and we have a rare opportunity to affect a major change to the way that we perceive and build software.

Trends and Influences

This route captures all of the influences on this system

Advancements on the server

There has been a trend in the node.js community towards api's that are built around the concepts of data as streams, and in the last 2 years this has accelerated giving rise to some very expressive and powerful tools.

At the same time, war stories from the architects of distributed systems have started to filter into the collective psyche of developers everywhere, and only recently managed to settle on the name 'microservices', as a way of disseminating what is basically tribal knowledge.

Stagnation on the client

The browser environment was untouched by these advancements, because when it came down to brass tacks, the DOM is the most complex form of shared state that most developers will have to interact with in their lives.

MicroServices and Streams are basically functional in nature, and there was an impidence mismatch because of the functional avoidance of state.

Famo.us changes everything

The reason famo.us is revolutionary has almost nothing to do with it's rendering speed on mobile devices. It's definitely a good feature, but it's not even remotely what famo.us is about.

Famo.us has taken the position that any layout or positioning should not be happening in the html/css anymore, and should instead be controlled by javascript.

How famo.us works

  • Famous wraps a Surface object around each element/div it controls.

  • These Surfaces are used to build out a Scene Graph (ie: tree of surfaces )

  • By putting the layout into JS, it has flattened out the DOM almost completely.

  • Famo.us calculates the absolute positions for every surface in the graph.

  • It does these calculations fast enough so that the browser can render at 60fps

  • This calculation is a simple linear transform, that is completely composable

    oldprops | transform | newprops

Famo.us means we have a functional browser environment too.

This change has brought the server and the client into closer parity than ever before. Suddenly, approaches that worked on the server are far more viable.

It's the synergy between these three occurences that excited me the most though. This is going to allow us to deliver some very powerful solutions in the future.

Approach

We are going to reach out to the maintainers of the various libraries that we consider important, and have open and honest communication about the ways in which our individual visions align.

As we bring each set of developers into the fold, we will seek to learn and solidify our messages based on the experiences and concern they share with us, until we are confident that we have the right answers to all our questions.

Final Goal

We will build and agree on a very simple microservices implementation, that could be used to interact with all of the libraries we consider to be important.

The required code is very very simple and the entire scope begins and ends with being able to make and provide microservice calls.

We will test, and extensively document how an application that works along these terms works, but we will not enforce any of the choices that need to be made.

the 3 layers

Microservices are fundamentally about making a small asbtract between the function that accepts or generates the message, and the one that actually receives it.

  1. Transport (local function default .. REST + more)
  2. Serialization (json default, AT LEAST PROTOBUF TOO, prolly xml, csv?)
  3. Service (the function called when triggered)
// in terms of your average express route
// it's specifying the abstraction
app.get('/path', serializeJson(serviceFn))

The 3 principles

The api is very very small, but it will have these consistent guarantees, which are all convention, but not assumption

  1. Everything is based on streams, with some of the properties of vinyl / highland.js.
  2. You have some consistent way to name/route messages (probably a url)
  3. Transports are required to meet at least the capabilities of REST (so they can do uploads)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment