igorb

igorb

Fireside - Installable & Upgradable Code Templates

Hello all!

Announcing Fireside, a tool to install and upgrade code templates that are themselves Elixir apps.

Fireside allows you to bring over microservices directly into your Elixir monolith. As an example, I built and open-sourced an e-commerce core for an online store (used in a real platform), and Fireside lets you install everything it needs to run in just one command: mix fireside.install shopifex@github:ibarakaiev/shopifex. This will:

  1. Install all its dependencies (as well as their Igniter installers, if available).
  2. Import all files listed in fireside.exs of the component.
  3. Run an optional setup/1 hook that uses Igniter for custom things like modifying config.exs, running mix tasks, etc.
  4. Calculate the hash of the AST of each imported file and record it in config/fireside.exs.

Then, if the component changes in the remote, you can bring over changes with mix fireside.update shopifex. Fireside components can even expose an upgrade/3 function that can run Igniter modifications. It’s kind of like a database migration, but for your app (or, rather, for an isolated part of it).

However, if you modify the imported code, Fireside will detect it by looking at the hash of its new AST and will reject updates. This is so that you can change the imported code and not risk having your changes overwritten. For this use case, it’s recommended to “unlock” the component before editing with mix fireside.unlock {component}, more on which below.

Some use cases, like project starter templates or code from tutorials, don’t require “locking”, and can be installed with the --unlocked flag. In this case, Fireside will import the code once and forget about it. This would be useful for something like phx.new if it were created with Fireside, in which case it would be possible to add a Phoenix template to an existing Elixir app. Updating or removing (mix fireside.uninstall) would not be possible in this case.

The key difference between regular code templates and Fireside components is that Fireside is AST-aware (thanks to Igniter!) and Fireside components are themselves standalone Elixir apps that you can test and build in any way you want—“exporting” only the critical parts. I wrote a bit more about the motivations and potential use cases in a blog post: Embedded Microservices and Fireside.

If you want to take it for a spin, feel free to take a look at the README and Creating a Fireside Component. If you do like it, let me know here or by leaving a star in the repo :slight_smile:

https://github.com/ibarakaiev/fireside

Where Next?

Popular in Announcing Top

josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19870 141
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13300 120
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement