Skip to content

Instantly share code, notes, and snippets.

View johnhamelink's full-sized avatar
🔨
Building

John Hamelink johnhamelink

🔨
Building
View GitHub Profile
if play.players.find_by_session_id(current_user.id)
return uhoh!('Player with session ID is already on the play roster', 409)
end
player = play.players.new(
session_id: current_user.id,
origin: 'Session',
state: Player.states[:requested_to_join],
name: current_user.name
def parse_packet({:xmlel, "message", [{"to", _to_jid}, {"id", _msg_id}, {"type", "chat"}], [{:xmlel, "body", _something, [xmlcdata: msg]}]}) do
msg
end
{:ok, session = %Session{user_token: _}} = %Session{
email: Faker.Internet.email,
type: "User",
user_token: "DUMMY123"
}
|> Session.changeset(%{})
|> DB.Repo.insert

My Elixir Deployment Wishlist

Foreward

Based on my recent experience of deployment, I've become rather frustrated with the deployment tooling in Elixir. This document is the result of me thinking to myself, "I wish we had x...". This document isn't meant to dishearten anyone who has built tooling for elixir - thank you so much for what you've done. This is meant more as what I personally see as something that would help a lot of Erlang/Elixir newbies like myself to be able to get deploying quickly and efficiently.

1. Release files should be templates

It should be possible to add in custom configuration to the bootstrap scripts. This would allow plugins to be able to add extra steps to the startup / shutdown / upgrade procedure. One way to implement this would be to make all scripts which handle bootstrapping or controlling the machine [.eex][1] templates. This would allow other parts of the release system to inject new functionality where needed.

defmodule DB.Mixfile do
use Mix.Project
def project do
[app: :db,
version: "0.0.2",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
defmodule Slack.Mixfile do
use Mix.Project
def project do
[app: :slack,
version: "0.0.3",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
defmodule Api.Mixfile do
use Mix.Project
def project do
[app: :api,
version: "0.3.1",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
defmodule Api.SessionTest do
use Api.ModelCase
alias Api.Session
alias Api.Services.Sessions.Sign
import Joken
@signature hs256(Application.get_env(:api, :auth_signature))
test "Valid JWT" do
{:ok, %Session{user_token: user_token}} = %Session{
defmodule Api.ConnCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
Such tests rely on `Phoenix.ConnTest` and also
imports other functionality to make it easier
to build and query models.
Finally, if the test case interacts with the database,
⏚ [john:~/Public/fap/api/findaplayer/apps/api] master(+16/-18)* ± mix hex.outdated
==> erlware_commons
Error evaluating rebar config script ./rebar.config.script:16: evaluation failed with reason error:{badmatch,undefined} and stacktrace [{erl_eval,expr,3,[]}]
Any dependency defined in the script won't be available unless you add them to your Mix project
==> api
Dependency Current Latest Requirement
apns 0.0.11 0.0.11 ~> 0.0.11
consul 1.0.3 1.0.3 ~> 1.0.0
cowboy 1.0.4 1.0.4 ~> 1.0
discovery 0.5.7 0.5.7 ~> 0.5.0