fig

module
v0.0.0-...-fad2219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2019 License: MIT

README

fig

Status GoDoc codecov Go Report Card

Fig is a simple config server written in Go.

Fig takes the idea of config as code one step further by considering every configuration or rollout flag a function.

Such functions are parameterized by things like current user or environment. For example, rolling out to 10 percent of users can be thought of as a boolean function strings.hash(user.email) < 0.1

This moves away from traditional configuration (seen as JSON) into a richer, more dynamic but still structured form.

Unlike a general purpose programming language, the configuration language is meant to be rendered in UI well. The same rollout example above, if written as strings.hash(user.email) < ui.slider.percent(0.1) would automatically render a slider for the configuration.

Architecture

  1. The data is stored in a persistent store with a simple interface allowing multiple backend implementations
  2. The store is a effectively a key value store with the value being the parsed functions. Parsing results in a simple JSON list-expression that can be easily evaluated on any client.
  3. The server exposes a simple HTTP api to fetch the current value on a key. The server can also evaluate expressions if the parameters are provided in JSON. Any app specific global extensions would only work if the code for the server is modified to host these.
  4. Client libraries cache the fetched values but interpret the functions on each call. Client libraries allow arbitrary extensions (injected as global variables) in the native language. A proxy server is a server that uses a client for the backend (and so gets in-memory caching).
  5. Both the regular server and proxy server support authentication modes (github initially).
  6. Both the server and proxy server come with UI for administering the key, value store. The UI for any particular config involves interpreting the same config code but with a UI runtime (where functions get rendered). Custom renderers (as with the ui.slider example) have access to the AST of the node and can freely mutate them. The current plan is to only support custom renderers within the Fig language itself. For example, the app can expose the ui.myslider by simply using the ui.myslider key to store the underlying UI code.

Status

  • REDIS backed store
  • Basic API server
  • API key auth
  • Basic edit UI
  • UI auth
  • API GH auth
  • UI code parser
  • UI code viewer
  • UI history
  • UI differ
  • js client
  • rb clienta
  • py client
  • proxy server

Directories

Path Synopsis
cmd
fig
pkg
cache
Package cache implements a simple cached store
Package cache implements a simple cached store
fig
Package fig implements the Golang client for fig The typical use of fig to fetch configuration is something like this; import "github.com/rameshvk/fig/pkg/fig" ...
Package fig implements the Golang client for fig The typical use of fig to fetch configuration is something like this; import "github.com/rameshvk/fig/pkg/fig" ...
fire
Package fire is the fig runtime
Package fire is the fig runtime
match
Package match is a tiny pattern matching and capture library This can be seen as equivalent to Erlang's pattern matching but in semi-idiomatic Go: http://erlang.org/doc/reference_manual/patterns.html Patterns are setup to be composed of other patterns using And, Or, Not and list primitives.
Package match is a tiny pattern matching and capture library This can be seen as equivalent to Erlang's pattern matching but in semi-idiomatic Go: http://erlang.org/doc/reference_manual/patterns.html Patterns are setup to be composed of other patterns using And, Or, Not and list primitives.
parse
Package parse implements a simple expression parser.
Package parse implements a simple expression parser.
server
Package server implements the config server The server consists of an API handler and a store.
Package server implements the config server The server consists of an API handler and a store.
vm
Package vm implements a stack machine A Machine has the following sections: - Code has the byte code.
Package vm implements a stack machine A Machine has the following sections: - Code has the byte code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL