Programming Elixir Chapter 20 Notes


OTP: Applications

Ran into significant issues between outdated Distillery information and incompatibility with OTP 25.

  1. Need to use the ~S sigil when writing a DocTest for the Stack.Stash.update function because I need to maintain state across two statements.

    @doc ~S"""
    Replace the current stashed value with new stack.
    
    ## Examples
      iex> Stack.Stash.update([42,24])
      ...> Stack.Stash.get()
      [42, 24]
    """

    Without the sigil, Stack.Stash.get() returns [1, 2, 3] and the test fails. With the sigil, we get the expected [42, 24] returned. This is not mentioned in the ExUnit documentation.

Releasing

The book is significantly out of date. Refer to the online documentation.

  1. Install Distillery.

  2. Create release information in the ./rel directory:

    mix distillery.init

  3. Make release configuration changes if necessary. No changes necessary for our build.

  4. Create a release:

    # Development
    mix distillery.release
    
    # Production
    MIX_ENV=prod mix distillery.release

  5. Production release fails with latest OTP 25. A known problem being addressed.

OTP-Applications-1

Turn the stack server into an OTP application. Source

OTP-Applications-2

Wrote DocTests for Stack.Impl and Stack.Stash. Source

OTP-Applications-3

Package the release and make a change to the sequence application. Source for my stack application.

I’ve not been keeping the sequence application up to date so skipped the versioning woSource

All notes and comments are my own opinion. Follow me at @rgacote@genserver.social